2017-09-14 02:11:33 +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';
|
2014-08-13 07:04:36 +08:00
|
|
|
|
2018-01-31 05:31:29 +08:00
|
|
|
export default Ember.Controller.extend(PenaltyController, {
|
2017-09-14 04:44:47 +08:00
|
|
|
suspendUntil: null,
|
2017-09-15 02:10:39 +08:00
|
|
|
suspending: false,
|
2013-11-01 22:47:03 +08:00
|
|
|
|
2017-09-14 02:11:33 +08:00
|
|
|
onShow() {
|
2018-01-31 05:31:29 +08:00
|
|
|
this.resetModal();
|
|
|
|
this.setProperties({ suspendUntil: null, suspending: false });
|
2017-09-14 02:11:33 +08:00
|
|
|
},
|
|
|
|
|
2017-09-15 02:10:39 +08:00
|
|
|
@computed('suspendUntil', 'reason', 'suspending')
|
|
|
|
submitDisabled(suspendUntil, reason, suspending) {
|
|
|
|
return (suspending || Ember.isEmpty(suspendUntil) || !reason || reason.length < 1);
|
2017-09-14 02:11:33 +08:00
|
|
|
},
|
2014-02-05 00:03:35 +08:00
|
|
|
|
2013-11-01 22:47:03 +08:00
|
|
|
actions: {
|
2017-09-14 02:11:33 +08:00
|
|
|
suspend() {
|
|
|
|
if (this.get('submitDisabled')) { return; }
|
|
|
|
|
2017-09-15 02:10:39 +08:00
|
|
|
this.set('suspending', true);
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
this.penalize(() => {
|
|
|
|
return this.get('user').suspend({
|
|
|
|
suspend_until: this.get('suspendUntil'),
|
|
|
|
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('suspending', false));
|
2013-11-01 22:47:03 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|