2018-01-31 05:31:29 +08:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2019-10-31 04:13:48 +08:00
|
|
|
import Mixin from "@ember/object/mixin";
|
2019-11-06 00:37:32 +08:00
|
|
|
import { Promise } from "rsvp";
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2019-10-31 03:03:08 +08:00
|
|
|
export default Mixin.create(ModalFunctionality, {
|
2018-01-31 05:31:29 +08:00
|
|
|
reason: null,
|
|
|
|
message: null,
|
|
|
|
postEdit: null,
|
|
|
|
postAction: null,
|
|
|
|
user: null,
|
2019-01-04 01:03:01 +08:00
|
|
|
postId: null,
|
2018-01-31 05:31:29 +08:00
|
|
|
successCallback: null,
|
|
|
|
|
|
|
|
resetModal() {
|
|
|
|
this.setProperties({
|
|
|
|
reason: null,
|
|
|
|
message: null,
|
|
|
|
loadingUser: true,
|
2019-01-04 01:03:01 +08:00
|
|
|
postId: null,
|
2018-01-31 05:31:29 +08:00
|
|
|
postEdit: null,
|
|
|
|
postAction: "delete",
|
|
|
|
before: null,
|
2020-03-06 09:29:51 +08:00
|
|
|
successCallback: null
|
2018-01-31 05:31:29 +08:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
penalize(cb) {
|
2019-05-27 16:15:39 +08:00
|
|
|
let before = this.before;
|
2019-11-06 00:37:32 +08:00
|
|
|
let promise = before ? before() : Promise.resolve();
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
return promise
|
|
|
|
.then(() => cb())
|
|
|
|
.then(result => {
|
|
|
|
this.send("closeModal");
|
2019-05-27 16:15:39 +08:00
|
|
|
let callback = this.successCallback;
|
2018-01-31 05:31:29 +08:00
|
|
|
if (callback) {
|
|
|
|
callback(result);
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
}
|
|
|
|
});
|