2019-10-24 00:30:52 +08:00
|
|
|
import Component from "@ember/component";
|
2020-11-11 03:31:28 +08:00
|
|
|
import { action } from "@ember/object";
|
2023-10-11 02:38:59 +08:00
|
|
|
import { equal } from "@ember/object/computed";
|
|
|
|
import { tagName } from "@ember-decorators/component";
|
2022-12-20 01:36:03 +08:00
|
|
|
import discourseComputed from "discourse-common/utils/decorators";
|
|
|
|
import I18n from "I18n";
|
2020-11-11 03:31:28 +08:00
|
|
|
|
|
|
|
const CUSTOM_REASON_KEY = "custom";
|
|
|
|
|
2023-02-23 23:32:53 +08:00
|
|
|
@tagName("")
|
|
|
|
export default class AdminPenaltyReason extends Component {
|
|
|
|
selectedReason = CUSTOM_REASON_KEY;
|
|
|
|
customReason = "";
|
|
|
|
|
|
|
|
reasonKeys = [
|
2020-11-11 03:31:28 +08:00
|
|
|
"not_listening_to_staff",
|
|
|
|
"consuming_staff_time",
|
2021-05-19 09:09:50 +08:00
|
|
|
"combative",
|
2020-11-11 03:31:28 +08:00
|
|
|
"in_wrong_place",
|
|
|
|
"no_constructive_purpose",
|
|
|
|
CUSTOM_REASON_KEY,
|
2023-02-23 23:32:53 +08:00
|
|
|
];
|
|
|
|
|
|
|
|
@equal("selectedReason", CUSTOM_REASON_KEY) isCustomReason;
|
2020-11-11 03:31:28 +08:00
|
|
|
|
|
|
|
@discourseComputed("reasonKeys")
|
|
|
|
reasons(keys) {
|
|
|
|
return keys.map((key) => {
|
|
|
|
return { id: key, name: I18n.t(`admin.user.suspend_reasons.${key}`) };
|
|
|
|
});
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
2020-11-11 03:31:28 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
setSelectedReason(value) {
|
|
|
|
this.set("selectedReason", value);
|
|
|
|
this.setReason();
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
2020-11-11 03:31:28 +08:00
|
|
|
|
|
|
|
@action
|
|
|
|
setCustomReason(value) {
|
|
|
|
this.set("customReason", value);
|
|
|
|
this.setReason();
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
2020-11-11 03:31:28 +08:00
|
|
|
|
|
|
|
setReason() {
|
|
|
|
if (this.isCustomReason) {
|
|
|
|
this.set("reason", this.customReason);
|
|
|
|
} else {
|
|
|
|
this.set(
|
|
|
|
"reason",
|
|
|
|
I18n.t(`admin.user.suspend_reasons.${this.selectedReason}`)
|
|
|
|
);
|
|
|
|
}
|
2023-02-23 23:32:53 +08:00
|
|
|
}
|
|
|
|
}
|