2017-11-14 02:41:36 +08:00
|
|
|
import computed from 'ember-addons/ember-computed-decorators';
|
2018-01-31 05:31:29 +08:00
|
|
|
import PenaltyController from 'admin/mixins/penalty-controller';
|
2017-11-14 02:41:36 +08:00
|
|
|
|
2018-01-31 05:31:29 +08:00
|
|
|
export default Ember.Controller.extend(PenaltyController, {
|
2017-11-14 02:41:36 +08:00
|
|
|
silenceUntil: null,
|
|
|
|
silencing: false,
|
|
|
|
|
|
|
|
onShow() {
|
2018-01-31 05:31:29 +08:00
|
|
|
this.resetModal();
|
|
|
|
this.setProperties({ silenceUntil: null, silencing: false });
|
2017-11-14 02:41:36 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@computed('silenceUntil', 'reason', 'silencing')
|
|
|
|
submitDisabled(silenceUntil, reason, silencing) {
|
|
|
|
return (silencing || Ember.isEmpty(silenceUntil) || !reason || reason.length < 1);
|
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
silence() {
|
|
|
|
if (this.get('submitDisabled')) { return; }
|
|
|
|
|
|
|
|
this.set('silencing', true);
|
2018-01-31 05:31:29 +08:00
|
|
|
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));
|
2017-11-14 02:41:36 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|