Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix model close #8

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
11 changes: 10 additions & 1 deletion addon/components/s-modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,15 @@ import layout from '../templates/components/s-modal';

export default Component.extend({
layout,
classNames: ['s-modal']
classNames: ['s-modal'],
isVisible: true,
actions: {
onCancel() {
this.set('isVisible', false);
if (this.get('onCancelAction')) {
this.get('onCancelAction')();
}
}
}

});
12 changes: 6 additions & 6 deletions addon/templates/components/s-modal.hbs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@

<div
data-test-id={{data-test-id}}
class="modal fade show d-block"
class="modal fade {{if isVisible "show d-block"}}"
role="dialog"
style="{{unless isVisible "display:none;"}}"
aria-labelledby="exampleModalLabel"
aria-hidden="true">
<div
Expand All @@ -12,25 +14,23 @@
{{#if header}}
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">{{header}}</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<button type="button" onClick={{action 'onCancel'}} class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
{{/if}}
<div class="modal-body">
<div class="modal-body">
{{yield}}
</div>
<div class="modal-footer">
{{#if onCancel }}
{{#s-button
onClick=(action onCancel)
onClick=(action 'onCancel')
cssClasses="float-left"
color= "secondary"
data-dismiss="modal"
}}
{{cancelText}}
{{/s-button}}
{{/if}}
{{#if onOK }}
{{#s-button
color="primary"
Expand Down
3 changes: 1 addition & 2 deletions tests/dummy/app/templates/docs/modal.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
header="Modal Header"
onOK=(action "onOk")
okText="OK"
onCancel=(action "toggleModal")
cancelText="Close"
}}
{{pressed}}
Expand All @@ -36,6 +35,6 @@
| header | Modal header | String | "" |
| onOK | action callback on ok click | event | null |
| okText |Ok button text | String | "" |
| onCancel | action callback on ok cancel | event | null |
| onCancelAction | action callback on ok cancel | event | null |
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, onCancel looks better than onCancelAction.

| cancelText | Cancel button text | event | null |
| modelDialogClassNames | css Class on container | String | "" |