2023-10-11 02:38:59 +08:00
|
|
|
import Component from "@ember/component";
|
2023-02-23 23:32:53 +08:00
|
|
|
import { action } from "@ember/object";
|
2022-12-20 01:36:03 +08:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-11-08 05:38:28 +08:00
|
|
|
import discourseComputed, {
|
2020-03-04 22:32:15 +08:00
|
|
|
afterRender,
|
2019-11-08 05:38:28 +08:00
|
|
|
} from "discourse-common/utils/decorators";
|
2020-05-14 04:23:41 +08:00
|
|
|
import I18n from "I18n";
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2019-05-28 00:27:16 +08:00
|
|
|
const ACTIONS = ["delete", "delete_replies", "edit", "none"];
|
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
export default class AdminPenaltyPostAction extends Component {
|
|
|
|
postId = null;
|
|
|
|
postAction = null;
|
|
|
|
postEdit = null;
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
@equal("postAction", "edit") editing;
|
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}`) };
|
|
|
|
});
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
@action
|
|
|
|
penaltyChanged(postAction) {
|
|
|
|
this.set("postAction", postAction);
|
2020-03-04 22:32:15 +08:00
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
// If we switch to edit mode, jump to the edit textarea
|
|
|
|
if (postAction === "edit") {
|
|
|
|
this._focusEditTextarea();
|
|
|
|
}
|
|
|
|
}
|
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();
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
|
|
|
}
|