Ghost/ghost/admin/controllers/modals/delete-post.js
David Arvelo 2dd5c5218a Fix deletion of Post Model in Editor and Content screens
fixes #2999
- handle undefined argument in openModal function
- catch whether a model is deleted in Editor routes to aid transition
- move updateTags function to the PostModel
- add call to updateTags in delete-post modal
2014-06-19 14:31:56 -04:00

37 lines
1.0 KiB
JavaScript

var DeletePostController = Ember.Controller.extend({
actions: {
confirmAccept: function () {
var self = this,
model = this.get('model');
// definitely want to clear the data store and post of any unsaved, client-generated tags
model.updateTags();
model.destroyRecord().then(function () {
self.get('popover').closePopovers();
self.notifications.showSuccess('Your post has been deleted.');
self.transitionToRoute('posts.index');
}, function () {
self.notifications.showError('Your post could not be deleted. Please try again.');
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'Delete',
buttonClass: 'button-delete'
},
reject: {
text: 'Cancel',
buttonClass: 'button'
}
}
});
export default DeletePostController;