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