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";
|
2024-11-20 04:45:18 +08:00
|
|
|
import { i18n } from "discourse-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) => {
|
2024-11-20 04:45:18 +08:00
|
|
|
return { id, name: i18n(`admin.user.penalty_post_${id}`) };
|
2018-01-31 05:31:29 +08:00
|
|
|
});
|
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;
|
2024-07-25 00:07:17 +08:00
|
|
|
const body = elem.closest(".d-modal__body");
|
2020-03-04 22:32:15 +08:00
|
|
|
body.scrollTo(0, body.clientHeight);
|
|
|
|
elem.querySelector(".post-editor").focus();
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
|
|
|
}
|