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

44 lines
980 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";
import Mixin from "@ember/object/mixin";
2019-11-06 00:37:32 +08:00
import { Promise } from "rsvp";
export default Mixin.create(ModalFunctionality, {
reason: null,
message: null,
postEdit: null,
postAction: null,
user: null,
postId: null,
successCallback: null,
resetModal() {
this.setProperties({
reason: null,
message: null,
loadingUser: true,
postId: null,
postEdit: null,
2018-06-15 23:03:24 +08:00
postAction: "delete",
before: null,
successCallback: null
});
},
penalize(cb) {
let before = this.before;
2019-11-06 00:37:32 +08:00
let promise = before ? before() : Promise.resolve();
return promise
.then(() => cb())
.then(result => {
2018-06-15 23:03:24 +08:00
this.send("closeModal");
let callback = this.successCallback;
if (callback) {
callback(result);
}
})
.catch(popupAjaxError);
}
});