2015-02-13 07:22:32 +03:00
|
|
|
import Ember from 'ember';
|
2015-05-26 05:10:50 +03:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
|
|
|
notifications: Ember.inject.service(),
|
|
|
|
|
2014-12-30 05:11:24 +03:00
|
|
|
userPostCount: Ember.computed('model.id', function () {
|
2014-12-10 04:44:36 +03:00
|
|
|
var promise,
|
|
|
|
query = {
|
2014-12-30 05:11:24 +03:00
|
|
|
author: this.get('model.slug'),
|
2014-12-10 04:44:36 +03:00
|
|
|
status: 'all'
|
|
|
|
};
|
|
|
|
|
2015-09-03 14:06:50 +03:00
|
|
|
promise = this.store.query('post', query).then(function (results) {
|
2014-12-10 04:44:36 +03:00
|
|
|
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});
|
|
|
|
}),
|
|
|
|
|
2014-08-04 22:36:45 +04:00
|
|
|
actions: {
|
|
|
|
confirmAccept: function () {
|
|
|
|
var self = this,
|
|
|
|
user = this.get('model');
|
|
|
|
|
|
|
|
user.destroyRecord().then(function () {
|
|
|
|
self.store.unloadAll('post');
|
2015-06-18 13:59:08 +03:00
|
|
|
self.transitionToRoute('team');
|
2014-08-04 22:36:45 +04:00
|
|
|
}, function () {
|
2015-06-19 00:56:18 +03:00
|
|
|
self.get('notifications').showAlert('The user could not be deleted. Please try again.', {type: 'error'});
|
2014-08-04 22:36:45 +04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
confirmReject: function () {
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
},
|
2014-10-25 01:09:50 +04:00
|
|
|
|
2014-08-04 22:36:45 +04:00
|
|
|
confirm: {
|
|
|
|
accept: {
|
|
|
|
text: 'Delete User',
|
2014-08-06 15:34:08 +04:00
|
|
|
buttonClass: 'btn btn-red'
|
2014-08-04 22:36:45 +04:00
|
|
|
},
|
|
|
|
reject: {
|
|
|
|
text: 'Cancel',
|
2014-08-06 15:34:08 +04:00
|
|
|
buttonClass: 'btn btn-default btn-minor'
|
2014-08-04 22:36:45 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|