0
Fork 0
mirror of https://github.com/TryGhost/Ghost.git synced 2025-01-27 22:49:56 -05:00
ghost/core/client/app/controllers/modals/delete-user.js

57 lines
1.5 KiB
JavaScript
Raw Normal View History

2015-02-12 21:22:32 -07:00
import Ember from 'ember';
const {Controller, PromiseProxyMixin, computed, inject} = Ember;
const {alias} = computed;
export default Controller.extend({
notifications: inject.service(),
userPostCount: computed('model.id', function () {
let query = {
filter: `author:${this.get('model.slug')}`,
status: 'all'
};
let promise = this.store.query('post', query).then((results) => {
return results.meta.pagination.total;
});
return Ember.Object.extend(PromiseProxyMixin, {
count: alias('content'),
inflection: computed('count', function () {
return this.get('count') > 1 ? 'posts' : 'post';
})
}).create({promise});
}),
confirm: {
accept: {
text: 'Delete User',
2014-08-06 14:34:08 +03:00
buttonClass: 'btn btn-red'
},
reject: {
text: 'Cancel',
2014-08-06 14:34:08 +03:00
buttonClass: 'btn btn-default btn-minor'
}
},
actions: {
confirmAccept() {
let user = this.get('model');
user.destroyRecord().then(() => {
this.get('notifications').closeAlerts('user.delete');
this.store.unloadAll('post');
this.transitionToRoute('team');
}, () => {
this.get('notifications').showAlert('The user could not be deleted. Please try again.', {type: 'error', key: 'user.delete.failed'});
});
},
confirmReject() {
return false;
}
}
});