From ea455a89e01c846cea2e5681c822fb878dbfc7f3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martin?= Date: Wed, 7 Nov 2018 15:30:59 +0100 Subject: [PATCH 1/2] feat(oui-modal): allow disabling oui-modal buttons --- packages/oui-modal/README.md | 20 +++++++++++++++ packages/oui-modal/src/index.spec.js | 29 ++++++++++++++++++++++ packages/oui-modal/src/modal.component.js | 2 ++ packages/oui-modal/src/modal.controller.js | 2 ++ packages/oui-modal/src/modal.html | 4 +-- 5 files changed, 55 insertions(+), 2 deletions(-) diff --git a/packages/oui-modal/README.md b/packages/oui-modal/README.md index 6cc3d121..0bb9ff36 100644 --- a/packages/oui-modal/README.md +++ b/packages/oui-modal/README.md @@ -74,6 +74,24 @@ ``` +### Disabled buttons + +```html:preview +
+ + You shall not pass! + +
+``` + ## API | Attribute | Type | Binding | One-time Binding | Values | Default | Description @@ -83,8 +101,10 @@ | `loading` | boolean | { expect($secondaryButton.attr("disabled")).toBe("disabled"); }); + it("should disable buttons when the conditions are met", () => { + const primaryDisabled = true; + const secondaryDisabled = false; + + const element = TestUtils.compileTemplate(` + + + `, { + primaryLabel, + secondaryLabel, + primaryDisabled, + secondaryDisabled + }); + + const $footer = getFooter(element); + const $primaryButton = getPrimaryButton($footer); + const $secondaryButton = getSecondaryButton($footer); + + expect($primaryButton).toBeDefined(); + expect($primaryButton.attr("disabled")).toBe("disabled"); + expect($secondaryButton).toBeDefined(); + expect($secondaryButton.attr("disabled")).toBe("disabled"); + }); + it("should trigger secondary action", () => { const secondarySpy = jasmine.createSpy("secondaryClick"); const element = TestUtils.compileTemplate(` diff --git a/packages/oui-modal/src/modal.component.js b/packages/oui-modal/src/modal.component.js index 5a656647..2576c362 100644 --- a/packages/oui-modal/src/modal.component.js +++ b/packages/oui-modal/src/modal.component.js @@ -11,8 +11,10 @@ export default { loading: " + ng-disabled="$ctrl.loading || $ctrl.secondaryDisabled"> From 483878679992a21e9e57e99a54cc8625dc374bf2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=A9r=C3=B4me=20Martin?= Date: Wed, 7 Nov 2018 16:34:14 +0100 Subject: [PATCH 2/2] feat(oui-modal): fix test and clean up the doc --- packages/oui-modal/README.md | 19 ++++++------------- packages/oui-modal/src/index.spec.js | 2 +- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/packages/oui-modal/README.md b/packages/oui-modal/README.md index 0bb9ff36..ab008655 100644 --- a/packages/oui-modal/README.md +++ b/packages/oui-modal/README.md @@ -44,11 +44,10 @@
@@ -61,24 +60,19 @@ ### Warning modal ```html:preview -
Modal content -
``` ### Disabled buttons ```html:preview -
You shall not pass! -
``` ## API @@ -101,10 +94,10 @@ | `loading` | boolean | { it("should disable buttons when the conditions are met", () => { const primaryDisabled = true; - const secondaryDisabled = false; + const secondaryDisabled = true; const element = TestUtils.compileTemplate(`