Ghost/core/client/app/controllers/modals/delete-post.js
Kevin Ansfield 156260343b Avoid duplicate alerts, clear alerts on successful retry or sign-in
closes #5903, refs #5409
- switch alert/notification component tests from unit to integration where appropriate
- rename `notifications.closeAll` to `notifications.clearAll` to better represent it's behaviour
- add concept of a "key" to alerts/notifications and ability to close only specified keys through notifications service
- close duplicate alerts/notifications before showing a new one
- specify a key for all existing alerts
- close failure alerts on successful retries
- clear all currently displayed alerts on successful sign-in
2015-10-12 19:21:30 +01:00

40 lines
1.1 KiB
JavaScript

import Ember from 'ember';
export default Ember.Controller.extend({
dropdown: Ember.inject.service(),
notifications: Ember.inject.service(),
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('dropdown').closeDropdowns();
self.get('notifications').closeAlerts('post.delete');
self.transitionToRoute('posts.index');
}, function () {
self.get('notifications').showAlert('Your post could not be deleted. Please try again.', {type: 'error', key: 'post.delete.failed'});
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'Delete',
buttonClass: 'btn btn-red'
},
reject: {
text: 'Cancel',
buttonClass: 'btn btn-default btn-minor'
}
}
});