Last active
July 5, 2016 01:06
-
-
Save benoror/88dcd0c0f44058c92c9d8e5914bca995 to your computer and use it in GitHub Desktop.
modal-message actions pattern - part of post: https://medium.com/p/dc024bfa203c
This file contains hidden or 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
//... | |
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 file contains hidden or 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
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 file contains hidden or 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
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