Change user deletion warning to be more explicit.

Issue #4583
- If a user has posts, show the count in the deletion warning.
This commit is contained in:
Jason Williams 2014-12-10 01:44:36 +00:00
parent 5cfebb3e50
commit 90043cd28d
2 changed files with 29 additions and 4 deletions

View File

@ -1,4 +1,24 @@
var DeleteUserController = Ember.Controller.extend({
var DeleteUserController = Ember.ObjectController.extend({
userPostCount: Ember.computed('id', function () {
var promise,
query = {
author: this.get('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,

View File

@ -1,7 +1,12 @@
{{#gh-modal-dialog action="closeModal" showClose=true type="action" style="wide,centered" animation="fade"
title="Are you sure you want to delete this user?" confirm=confirm}}
<p>All posts and associated data will also be deleted. There is no way to recover this data.
</p>
{{#unless userPostCount.isPending}}
{{#if userPostCount.count}}
<strong>WARNING:</strong> <span class="red">This user is the author of {{userPostCount.count}} {{userPostCount.inflection}}.</span> All posts and user data will be deleted. There is no way to recover this.
{{else}}
<strong>WARNING:</strong> All user data will be deleted. There is no way to recover this.
{{/if}}
{{/unless}}
{{/gh-modal-dialog}}