Many enhancements to the flagging / suspending interface.

This commit is contained in:
Robin Ward
2018-01-30 16:31:29 -05:00
parent f7df68c9a3
commit 8ff4104555
18 changed files with 255 additions and 120 deletions

View File

@ -1,26 +1,14 @@
import ModalFunctionality from 'discourse/mixins/modal-functionality';
import computed from 'ember-addons/ember-computed-decorators';
import { popupAjaxError } from 'discourse/lib/ajax-error';
import PenaltyController from 'admin/mixins/penalty-controller';
export default Ember.Controller.extend(ModalFunctionality, {
export default Ember.Controller.extend(PenaltyController, {
silenceUntil: null,
reason: null,
message: null,
silencing: false,
user: null,
post: null,
successCallback: null,
onShow() {
this.setProperties({
silenceUntil: null,
reason: null,
message: null,
silencing: false,
loadingUser: true,
post: null,
successCallback: null,
});
this.resetModal();
this.setProperties({ silenceUntil: null, silencing: false });
},
@computed('silenceUntil', 'reason', 'silencing')
@ -33,18 +21,16 @@ export default Ember.Controller.extend(ModalFunctionality, {
if (this.get('submitDisabled')) { return; }
this.set('silencing', true);
this.get('user').silence({
silenced_till: this.get('silenceUntil'),
reason: this.get('reason'),
message: this.get('message'),
post_id: this.get('post.id')
}).then(result => {
this.send('closeModal');
let callback = this.get('successCallback');
if (callback) {
callback(result);
}
}).catch(popupAjaxError).finally(() => this.set('silencing', false));
this.penalize(() => {
return this.get('user').silence({
silenced_till: this.get('silenceUntil'),
reason: this.get('reason'),
message: this.get('message'),
post_id: this.get('post.id'),
post_action: this.get('postAction'),
post_edit: this.get('postEdit')
});
}).finally(() => this.set('silencing', false));
}
}
});