mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-13 22:41:32 -05:00
a1ed9adf92
Ember.ObjectController (and Ember.ArrayController) will be deprecated in Ember 1.11 (and removed from core in Ember 2.0). The reasoning is detailed in the Ember 2.0 RFC. This PR does the following: * Updates templates/controllers/views to explicitly reference model properties (instead of relying on proxying behavior). * Clearly delineate where certain properties are being set or retrieved from (for example it was not clear exactly where `scratch` and `titleScratch` were stored). * Remove usage of `Ember.ObjectController`. * Add JSCS rule to prevent future PR's from adding regressions.
53 lines
1.5 KiB
JavaScript
53 lines
1.5 KiB
JavaScript
var DeleteUserController = Ember.Controller.extend({
|
|
userPostCount: Ember.computed('model.id', function () {
|
|
var promise,
|
|
query = {
|
|
author: this.get('model.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;
|