discourse/app/assets/javascripts/admin/mixins/penalty-controller.js.es6

42 lines
926 B
Plaintext
Raw Normal View History

2018-06-15 23:03:24 +08:00
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
export default Ember.Mixin.create(ModalFunctionality, {
reason: null,
message: null,
postEdit: null,
postAction: null,
user: null,
post: null,
successCallback: null,
resetModal() {
this.setProperties({
reason: null,
message: null,
loadingUser: true,
post: null,
postEdit: null,
2018-06-15 23:03:24 +08:00
postAction: "delete",
before: null,
successCallback: null
});
},
penalize(cb) {
2018-06-15 23:03:24 +08:00
let before = this.get("before");
let promise = before ? before() : Ember.RSVP.resolve();
return promise
.then(() => cb())
.then(result => {
2018-06-15 23:03:24 +08:00
this.send("closeModal");
let callback = this.get("successCallback");
if (callback) {
callback(result);
}
})
.catch(popupAjaxError);
}
});