Ghost/core/client/app/controllers/modals/delete-user.js
cobbspur f67147a685 Move users routes out of settings & change to team
issue #5434

- move users routes/views/controllers out of settings
- rename users team
- update nav-menu.hbs
- remove legacy routes
- fix up tests
2015-06-18 19:46:46 +01:00

56 lines
1.6 KiB
JavaScript

import Ember from 'ember';
export default Ember.Controller.extend({
notifications: Ember.inject.service(),
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('team');
self.get('notifications').showSuccess('The user has been deleted.', {delayed: true});
}, function () {
self.get('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'
}
}
});