2018-06-15 23:03:24 +08:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
export default Ember.Mixin.create(ModalFunctionality, {
|
|
|
|
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,
|
2018-06-15 23:03:24 +08:00
|
|
|
postAction: "delete",
|
2018-01-31 05:31:29 +08:00
|
|
|
before: null,
|
|
|
|
successCallback: null
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
penalize(cb) {
|
2019-05-27 16:15:39 +08:00
|
|
|
let before = this.before;
|
2018-01-31 05:31:29 +08:00
|
|
|
let promise = before ? before() : Ember.RSVP.resolve();
|
|
|
|
|
|
|
|
return promise
|
|
|
|
.then(() => cb())
|
|
|
|
.then(result => {
|
2018-06-15 23:03:24 +08:00
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|