Last active
June 15, 2016 21:41
-
-
Save DavidVotrubec/65cc94941751915a2c4b79b6b2deecd2 to your computer and use it in GitHub Desktop.
Confirmation-Dialog-3
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.Controller.extend({ | |
appName: 'Ember Twiddle', | |
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'} | |
], | |
itemToDelete: null, | |
hasItemToDelete: Ember.computed('itemToDelete', function(){ | |
return this.get('itemToDelete') != null; | |
}), | |
_closeConfirmationDialog: function() { | |
this.set('itemToDelete', null); | |
}, | |
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.get('items').removeObject(itemToDelete); | |
this._closeConfirmationDialog(); | |
}, | |
closeConfirmationDialog: function() { | |
this._closeConfirmationDialog(); | |
} | |
} | |
}); |
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", | |
"ember": "2.6.0", | |
"ember-data": "2.6.0", | |
"ember-template-compiler": "2.6.0", | |
"ember-modal-dialog": "0.8.3" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment