Last active
June 15, 2016 21:43
-
-
Save DavidVotrubec/bb87d9caa304f58985c5d94985bcb379 to your computer and use it in GitHub Desktop.
Confirmation-Dialog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Ember from 'ember'; | |
export default Ember.Component.extend({ | |
itemToDelete: null, | |
hasItemToDelete: Ember.computed('itemToDelete', function(){ | |
return this.get('itemToDelete') != null; | |
}), | |
_closeConfirmationDialog: function() { | |
this.set('itemToDelete', null); | |
}, | |
items: [ | |
{id: 1, name: 'first item'}, | |
{id: 2, name: 'second item'}, | |
{id: 3, name: 'third item'}, | |
{id: 4, name: 'fourth item'}, | |
{id: 5, name: 'fifth item'} | |
], | |
actions: { | |
removeItem: function(item) { | |
this.set('itemToDelete', item); | |
}, | |
/** | |
* DO NOT CALL THIS METHOD DIRECTLY | |
* BUT ALWAYS VIA CONFIRMATION DIALOG | |
*/ | |
doRemoveItem: function() { | |
const itemToDelete = this.get('itemToDelete'); | |
if (!itemToDelete){ | |
return; | |
} | |
// normally you would call something like itemToDelete.destroyRecord() | |
// but this just a simplified example .... | |
this | |
}, | |
} | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"version": "0.9.2", | |
"EmberENV": { | |
"FEATURES": {} | |
}, | |
"options": { | |
"use_pods": false, | |
"enable-testing": false | |
}, | |
"dependencies": { | |
"jquery": "https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.js", | |
"underscore": "https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js", | |
"ember": "2.5.1", | |
"ember-data": "2.6.0", | |
"ember-template-compiler": "2.5.1", | |
"ember-modal-dialog": "0.8.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment