2019-11-07 16:38:28 -05:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
2019-10-30 16:28:29 -04:00
|
|
|
import { equal } from "@ember/object/computed";
|
2019-10-23 12:30:52 -04:00
|
|
|
import Component from "@ember/component";
|
2020-03-04 09:32:15 -05:00
|
|
|
import { afterRender } from "discourse-common/utils/decorators";
|
2018-01-30 16:31:29 -05:00
|
|
|
|
2019-05-27 12:27:16 -04:00
|
|
|
const ACTIONS = ["delete", "delete_replies", "edit", "none"];
|
|
|
|
|
2019-10-23 12:30:52 -04:00
|
|
|
export default Component.extend({
|
2019-01-03 12:03:01 -05:00
|
|
|
postId: null,
|
2018-01-30 16:31:29 -05:00
|
|
|
postAction: null,
|
|
|
|
postEdit: null,
|
|
|
|
|
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}`) };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2019-10-30 16:28:29 -04:00
|
|
|
editing: equal("postAction", "edit"),
|
2018-01-30 16:31:29 -05:00
|
|
|
|
|
|
|
actions: {
|
2020-03-04 09:32:15 -05:00
|
|
|
penaltyChanged(postAction) {
|
|
|
|
this.set("postAction", postAction);
|
|
|
|
|
2018-01-30 16:31:29 -05:00
|
|
|
// If we switch to edit mode, jump to the edit textarea
|
2020-03-04 09:32:15 -05:00
|
|
|
if (postAction === "edit") {
|
|
|
|
this._focusEditTextarea();
|
2018-01-30 16:31:29 -05:00
|
|
|
}
|
|
|
|
}
|
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();
|
2018-01-30 16:31:29 -05:00
|
|
|
}
|
|
|
|
});
|