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