Files
discourse-chat-integration/assets/javascripts/admin/controllers/modals/admin-plugins-chat-integration-edit-rule.js
T

37 lines
824 B
JavaScript
Raw Normal View History

2018-09-12 16:16:18 +01:00
import ModalFunctionality from "discourse/mixins/modal-functionality";
import { popupAjaxError } from "discourse/lib/ajax-error";
import computed, { on } from "discourse-common/utils/decorators";
2017-07-31 17:09:21 +01:00
export default Ember.Controller.extend(ModalFunctionality, {
2017-10-03 17:42:07 +08:00
saveDisabled: false,
2018-09-12 16:16:18 +01:00
@on("init")
2017-10-03 17:42:07 +08:00
setupKeydown() {
2018-09-12 16:16:18 +01:00
Ember.run.schedule("afterRender", () => {
2020-09-04 13:23:28 +02:00
$("#chat-integration-edit-channel-modal").keydown((e) => {
2017-07-31 17:09:21 +01:00
if (e.keyCode === 13) {
2018-09-12 16:16:18 +01:00
this.send("save");
2017-07-31 17:09:21 +01:00
}
});
});
2017-10-03 18:11:58 +08:00
},
2017-07-31 17:09:21 +01:00
2018-09-12 16:16:18 +01:00
@computed("model.rule.type")
2017-10-03 17:42:07 +08:00
showCategory(type) {
return type === "normal";
},
2017-07-31 17:09:21 +01:00
actions: {
save(rule) {
2020-09-22 17:11:12 +02:00
if (this.get("saveDisabled")) {
return;
}
2017-07-31 17:09:21 +01:00
rule
2018-09-12 16:16:18 +01:00
.save()
.then(() => this.send("closeModal"))
2018-09-12 16:16:18 +01:00
.catch(popupAjaxError);
2020-09-04 13:23:28 +02:00
},
},
2017-10-03 17:42:07 +08:00
});