discourse-chat-integration/admin/assets/javascripts/admin/controllers/modals/admin-plugins-chat-integrat...

52 lines
1.1 KiB
JavaScript

import { tracked } from "@glimmer/tracking";
import Controller from "@ember/controller";
import { action } from "@ember/object";
import { inject as service } from "@ember/service";
import { popupAjaxError } from "discourse/lib/ajax-error";
import ModalFunctionality from "discourse/mixins/modal-functionality";
export default class AdminPluginsChatIntegrationEditRule extends Controller.extend(
ModalFunctionality
) {
@service siteSettings;
@tracked saveDisabled = false;
get showCategory() {
return this.model.rule.type === "normal";
}
get currentRuleType() {
return this.model.rule.type;
}
@action
save(rule) {
if (this.saveDisabled) {
return;
}
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;
}
}
}