2020-05-14 04:23:41 +08:00
|
|
|
import I18n from "I18n";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-31 04:28:29 +08:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2020-03-04 22:32:15 +08:00
|
|
|
import { afterRender } from "discourse-common/utils/decorators";
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2019-05-28 00:27:16 +08:00
|
|
|
const ACTIONS = ["delete", "delete_replies", "edit", "none"];
|
|
|
|
|
2019-10-24 00:30:52 +08:00
|
|
|
export default Component.extend({
|
2019-01-04 01:03:01 +08:00
|
|
|
postId: null,
|
2018-01-31 05:31:29 +08:00
|
|
|
postAction: null,
|
|
|
|
postEdit: null,
|
|
|
|
|
2019-11-08 05:38:28 +08:00
|
|
|
@discourseComputed
|
2018-01-31 05:31:29 +08:00
|
|
|
penaltyActions() {
|
|
|
|
return ACTIONS.map(id => {
|
|
|
|
return { id, name: I18n.t(`admin.user.penalty_post_${id}`) };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-10-31 04:28:29 +08:00
|
|
|
editing: equal("postAction", "edit"),
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
actions: {
|
2020-03-04 22:32:15 +08:00
|
|
|
penaltyChanged(postAction) {
|
|
|
|
this.set("postAction", postAction);
|
|
|
|
|
2018-01-31 05:31:29 +08:00
|
|
|
// If we switch to edit mode, jump to the edit textarea
|
2020-03-04 22:32:15 +08:00
|
|
|
if (postAction === "edit") {
|
|
|
|
this._focusEditTextarea();
|
2018-01-31 05:31:29 +08:00
|
|
|
}
|
|
|
|
}
|
2020-03-04 22:32:15 +08:00
|
|
|
},
|
|
|
|
|
|
|
|
@afterRender
|
|
|
|
_focusEditTextarea() {
|
|
|
|
const elem = this.element;
|
|
|
|
const body = elem.closest(".modal-body");
|
|
|
|
body.scrollTo(0, body.clientHeight);
|
|
|
|
elem.querySelector(".post-editor").focus();
|
2018-01-31 05:31:29 +08:00
|
|
|
}
|
|
|
|
});
|