Skip to content

Commit

Permalink
Impelment a confirmation delete modal dialog for Delete button
Browse files Browse the repository at this point in the history
  • Loading branch information
zoltan-nz committed Jul 16, 2015
1 parent 650b27e commit 485d305
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 0 deletions.
4 changes: 4 additions & 0 deletions app/components/contacts/contact-row.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ export default Ember.Component.extend({

actions: {
deleteItem() {
this.$('.modal').modal();
},

deleteConfirmed() {
var item = this.get('item');
item.destroyRecord();
}
Expand Down
17 changes: 17 additions & 0 deletions app/components/modal-dialog.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import Ember from 'ember';

export default Ember.Component.extend({

tagName: 'div',
classNames: ['modal', 'fade'],

title: 'Default title',
cancelButtonLabel: 'Cancel',
primerButtonLabel: 'Save',

actions: {
primerButtonClicked() {
this.sendAction();
}
}
});
4 changes: 4 additions & 0 deletions app/templates/components/contacts/contact-row.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -5,3 +5,7 @@
<td>
<button class="btn btn-xs btn-danger" {{action "deleteItem"}}>Delete</button>
</td>

{{#modal-dialog action="deleteConfirmed" title="Confirmation" primerButtonLabel="Delete"}}
<p>Are you really sure?</p>
{{/modal-dialog}}
15 changes: 15 additions & 0 deletions app/templates/components/modal-dialog.hbs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<div class="modal-dialog">
<div class="modal-content">
<div class="modal-header">
<button type="button" class="close" data-dismiss="modal"><span aria-hidden="true">&times;</span></button>
<h4 class="modal-title">{{title}}</h4>
</div>
<div class="modal-body">
{{yield}}
</div>
<div class="modal-footer">
<button type="button" class="btn btn-default" data-dismiss="modal">{{cancelButtonLabel}}</button>
<button type="button" class="btn btn-primary" data-dismiss="modal" {{action 'primerButtonClicked'}}>{{primerButtonLabel}}</button>
</div>
</div>
</div>

0 comments on commit 485d305

Please sign in to comment.