Skip to content
This repository was archived by the owner on Aug 7, 2020. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,18 @@
<a name="2.26.0"></a>
# [2.26.0](https://github.com/ovh-ux/ovh-ui-angular/compare/v2.25.1...v2.26.0) (2019-03-26)


### Bug Fixes

* **oui-modal:** hide content when loading ([#373](https://github.com/ovh-ux/ovh-ui-angular/issues/373)) ([411e594](https://github.com/ovh-ux/ovh-ui-angular/commit/411e594))


### Features

* **oui-collapsible:** add on-toggle event ([#372](https://github.com/ovh-ux/ovh-ui-angular/issues/372)) ([6b1adda](https://github.com/ovh-ux/ovh-ui-angular/commit/6b1adda))



<a name="2.25.1"></a>
## [2.25.1](https://github.com/ovh-ux/ovh-ui-angular/compare/v2.25.0...v2.25.1) (2019-03-04)

Expand Down
4 changes: 2 additions & 2 deletions dist/oui-angular.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/oui-angular.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"description": "A set of maintainable components for the OVH ecosystem (Angular).",
"license": "BSD-3-Clause",
"author": "OVH SAS",
"version": "2.25.1",
"version": "2.26.0",
"keywords": [
"angular"
],
Expand Down
9 changes: 9 additions & 0 deletions packages/oui-collapsible/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@
</oui-collapsible>
```

### Event handler

```html:preview
<oui-collapsible heading="Title" aria-label="Action" expanded="true" on-toggle="$ctrl.onToggle(expanded)">
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Duis semper ligula nec fringilla tempor. In rhoncus ullamcorper feugiat. Phasellus vel ipsum vitae neque varius luctus. Proin id iaculis arcu. Fusce justo arcu, egestas vel nulla nec, dictum cursus lacus. Aenean elementum vel odio quis rutrum. In quis tellus in neque vulputate rhoncus vitae ut justo. Ut dignissim varius est in consequat. Donec nisi mauris, pellentesque condimentum congue in, blandit ut arcu. In et elit ipsum.
</oui-collapsible>
```

## API

### oui-collapsible
Expand All @@ -29,3 +37,4 @@
| `heading` | string | @ | no | n/a | n/a | text of the heading
| `aria-label` | string | @? | yes | n/a | n/a | accessibility label
| `expanded` | boolean | <? | yes | n/a | `false` | initial expanded state
| `on-toggle` | function | & | no | n/a | n/a | on collapsible state changed event handler
3 changes: 2 additions & 1 deletion packages/oui-collapsible/src/collapsible.component.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,8 @@ export default {
id: "@",
heading: "@",
ariaLabel: "@?",
expanded: "<?"
expanded: "<?",
onToggle: "&"
},
transclude: true
};
1 change: 1 addition & 0 deletions packages/oui-collapsible/src/collapsible.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@ export default class {

toggle () {
this.expanded = !this.expanded;
this.onToggle({ expanded: this.expanded });
}
}
18 changes: 18 additions & 0 deletions packages/oui-collapsible/src/index.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,5 +75,23 @@ describe("ouiCollapsible", () => {
const contentEl = bodyEl.querySelector(".custom-content");
expect(contentEl).toBeTruthy();
});

it("should call ontoggle when defined into attributes", () => {
const onToggle = jasmine.createSpy("onToggle");
const element = TestUtils.compileTemplate(`
<oui-collapsible heading="Title" aria-label="Action" on-toggle="$ctrl.onToggle(expanded)"></oui-collapsible>`, {
onToggle
});

const headerEl = angular.element(getHeaderElement(element));

// Expand
headerEl.triggerHandler("click");
expect(onToggle).toHaveBeenCalledWith(true);

// Collapse
headerEl.triggerHandler("click");
expect(onToggle).toHaveBeenCalledWith(false);
});
});
});