mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-27 22:49:56 -05:00
3d6856614f
no issue - add ember-suave dependency - upgrade grunt-jscs dependency - add a new .jscsrc for the client's tests directory that extends from client's base .jscsrc - separate client tests in Gruntfile jscs task so they pick up the test's .jscsrc - standardize es6 usage across client
56 lines
1.5 KiB
JavaScript
56 lines
1.5 KiB
JavaScript
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',
|
|
buttonClass: 'btn btn-red'
|
|
},
|
|
reject: {
|
|
text: 'Cancel',
|
|
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;
|
|
}
|
|
}
|
|
});
|