2022-03-06 21:18:46 +01:00
|
|
|
import Controller from "@ember/controller";
|
2018-09-12 16:16:18 +01:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2023-01-23 10:30:48 -08:00
|
|
|
import { tracked } from "@glimmer/tracking";
|
|
|
|
|
import { action } from "@ember/object";
|
|
|
|
|
import { inject as service } from "@ember/service";
|
2017-07-31 17:09:21 +01:00
|
|
|
|
2023-01-23 10:30:48 -08:00
|
|
|
export default class AdminPluginsChatIntegrationEditRule extends Controller.extend(
|
|
|
|
|
ModalFunctionality
|
|
|
|
|
) {
|
|
|
|
|
@service siteSettings;
|
|
|
|
|
@tracked saveDisabled = false;
|
2017-10-03 17:42:07 +08:00
|
|
|
|
2023-01-23 10:30:48 -08:00
|
|
|
get showCategory() {
|
|
|
|
|
return this.model.rule.type === "normal";
|
|
|
|
|
}
|
2017-07-31 17:09:21 +01:00
|
|
|
|
2023-01-23 10:30:48 -08:00
|
|
|
get currentRuleType() {
|
|
|
|
|
return this.model.rule.type;
|
|
|
|
|
}
|
2017-08-01 15:20:00 +01:00
|
|
|
|
2023-01-23 10:30:48 -08:00
|
|
|
@action
|
|
|
|
|
save(rule) {
|
|
|
|
|
if (this.saveDisabled) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-07-31 17:09:21 +01:00
|
|
|
|
2023-01-23 10:30:48 -08:00
|
|
|
rule
|
|
|
|
|
.save()
|
|
|
|
|
.then(() => this.send("closeModal"))
|
|
|
|
|
.catch(popupAjaxError);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
handleKeyUp(e) {
|
|
|
|
|
if (e.code === "Enter") {
|
|
|
|
|
this.save();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@action
|
|
|
|
|
onChangeRuleType(type) {
|
|
|
|
|
this.model.rule.type = type;
|
|
|
|
|
this.currentRuleType = type;
|
|
|
|
|
if (type !== "normal") {
|
|
|
|
|
this.showCategory = false;
|
|
|
|
|
} else {
|
|
|
|
|
this.showCategory = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|