2018-06-15 23:03:24 +08:00
|
|
|
import computed from "ember-addons/ember-computed-decorators";
|
2018-01-31 05:31:29 +08:00
|
|
|
|
2019-05-28 00:27:16 +08:00
|
|
|
const ACTIONS = ["delete", "delete_replies", "edit", "none"];
|
|
|
|
|
2018-01-31 05:31:29 +08:00
|
|
|
export default Ember.Component.extend({
|
2019-01-04 01:03:01 +08:00
|
|
|
postId: null,
|
2018-01-31 05:31:29 +08:00
|
|
|
postAction: null,
|
|
|
|
postEdit: null,
|
|
|
|
|
|
|
|
@computed
|
|
|
|
penaltyActions() {
|
|
|
|
return ACTIONS.map(id => {
|
|
|
|
return { id, name: I18n.t(`admin.user.penalty_post_${id}`) };
|
|
|
|
});
|
|
|
|
},
|
|
|
|
|
2018-06-15 23:03:24 +08:00
|
|
|
editing: Ember.computed.equal("postAction", "edit"),
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
actions: {
|
|
|
|
penaltyChanged() {
|
2019-05-27 16:15:39 +08:00
|
|
|
let postAction = this.postAction;
|
2018-01-31 05:31:29 +08:00
|
|
|
|
|
|
|
// If we switch to edit mode, jump to the edit textarea
|
2018-06-15 23:03:24 +08:00
|
|
|
if (postAction === "edit") {
|
|
|
|
Ember.run.scheduleOnce("afterRender", () => {
|
2019-07-16 18:45:15 +08:00
|
|
|
let elem = this.element;
|
|
|
|
let body = elem.closest(".modal-body");
|
2018-01-31 05:31:29 +08:00
|
|
|
body.scrollTop(body.height());
|
2019-07-16 18:45:15 +08:00
|
|
|
elem.querySelector(".post-editor").focus();
|
2018-01-31 05:31:29 +08:00
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|