2013-11-01 22:47:03 +08:00
|
|
|
/**
|
2013-11-08 02:53:32 +08:00
|
|
|
The modal for suspending a user.
|
2013-11-01 22:47:03 +08:00
|
|
|
|
2013-11-08 02:53:32 +08:00
|
|
|
@class AdminSuspendUserController
|
2013-11-01 22:47:03 +08:00
|
|
|
@extends Discourse.Controller
|
|
|
|
@namespace Discourse
|
|
|
|
@uses Discourse.ModalFunctionality
|
|
|
|
@module Discourse
|
|
|
|
**/
|
2014-07-23 11:20:45 +08:00
|
|
|
export default Discourse.ObjectController.extend(Discourse.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 });
|
2013-11-02 00:13:09 +08:00
|
|
|
bootbox.alert(error, function() { self.send('showModal'); });
|
2013-11-01 22:47:03 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|