Skip to content

Instantly share code, notes, and snippets.

@benoror
Last active July 5, 2016 01:06
Show Gist options
  • Save benoror/88dcd0c0f44058c92c9d8e5914bca995 to your computer and use it in GitHub Desktop.
Save benoror/88dcd0c0f44058c92c9d8e5914bca995 to your computer and use it in GitHub Desktop.
modal-message actions pattern - part of post: https://medium.com/p/dc024bfa203c
//...
export default Route.extend({
//...
actions: {
//...
showModalDialog(options) {
set(this.controllerFor('application'), 'modalOptions', options);
set(this.controllerFor('application'), 'isShowingModal', true);
},
closeModalDialog() {
set(this.controllerFor('application'), 'isShowingModal', false);
}
//...
}
});
this.send('showModalDialog', {
type: 'confirm',
title: 'Delete record?',
label: 'The record will be deleted, re you sure?',
mainActionText: 'Delete',
mainActionPendingText: 'Deleting...',
mainAction(confirm) {
if (confirm) {
// ... proceed to delete logic
}
}
});
this.send('showModalDialog', {
type: 'prompt',
title: 'What\'s your name?',
mainActionText: 'Save',
mainActionPendingText: 'Saving...',
mainAction(name) {
if (!isEmpty(name)) {
//... do whatever you want with name
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment