2014-08-13 07:04:36 +08:00
|
|
|
import ModalFunctionality from 'discourse/mixins/modal-functionality';
|
|
|
|
|
2015-08-12 00:27:07 +08:00
|
|
|
export default Ember.Controller.extend(ModalFunctionality, {
|
2013-11-01 22:47:03 +08:00
|
|
|
|
2014-02-05 00:03:35 +08:00
|
|
|
submitDisabled: function() {
|
|
|
|
return (!this.get('reason') || this.get('reason').length < 1);
|
|
|
|
}.property('reason'),
|
|
|
|
|
2013-11-01 22:47:03 +08:00
|
|
|
actions: {
|
2013-11-08 02:53:32 +08:00
|
|
|
suspend: function() {
|
2014-02-05 00:03:35 +08:00
|
|
|
if (this.get('submitDisabled')) return;
|
2013-11-01 22:47:03 +08:00
|
|
|
var duration = parseInt(this.get('duration'), 10);
|
|
|
|
if (duration > 0) {
|
2013-11-02 00:13:09 +08:00
|
|
|
var self = this;
|
|
|
|
this.send('hideModal');
|
2013-11-08 02:53:32 +08:00
|
|
|
this.get('model').suspend(duration, this.get('reason')).then(function() {
|
2013-11-01 22:47:03 +08:00
|
|
|
window.location.reload();
|
|
|
|
}, function(e) {
|
2013-11-08 02:53:32 +08:00
|
|
|
var error = I18n.t('admin.user.suspend_failed', { error: "http: " + e.status + " - " + e.body });
|
2015-03-11 03:01:15 +08:00
|
|
|
bootbox.alert(error, function() { self.send('reopenModal'); });
|
2013-11-01 22:47:03 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|