Ghost/ghost/admin/controllers/modals/delete-user.js
Jason Williams 90043cd28d Change user deletion warning to be more explicit.
Issue #4583
- If a user has posts, show the count in the deletion warning.
2014-12-10 01:44:36 +00:00

54 lines
1.5 KiB
JavaScript

var DeleteUserController = Ember.ObjectController.extend({
userPostCount: Ember.computed('id', function () {
var promise,
query = {
author: this.get('slug'),
status: 'all'
};
promise = this.store.find('post', query).then(function (results) {
return results.meta.pagination.total;
});
return Ember.Object.extend(Ember.PromiseProxyMixin, {
count: Ember.computed.alias('content'),
inflection: Ember.computed('count', function () {
return this.get('count') > 1 ? 'posts' : 'post';
})
}).create({promise: promise});
}),
actions: {
confirmAccept: function () {
var self = this,
user = this.get('model');
user.destroyRecord().then(function () {
self.store.unloadAll('post');
self.transitionToRoute('settings.users');
self.notifications.showSuccess('The user has been deleted.', {delayed: true});
}, function () {
self.notifications.showError('The user could not be deleted. Please try again.');
});
},
confirmReject: function () {
return false;
}
},
confirm: {
accept: {
text: 'Delete User',
buttonClass: 'btn btn-red'
},
reject: {
text: 'Cancel',
buttonClass: 'btn btn-default btn-minor'
}
}
});
export default DeleteUserController;