2018-09-12 16:16:18 +01:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
2021-11-14 14:14:49 +01:00
|
|
|
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-08-01 15:20:00 +01:00
|
|
|
},
|
|
|
|
|
|
2017-07-31 17:09:21 +01:00
|
|
|
actions: {
|
2019-03-20 11:57:07 +01:00
|
|
|
save(rule) {
|
2020-09-22 17:11:12 +02:00
|
|
|
if (this.get("saveDisabled")) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2017-07-31 17:09:21 +01:00
|
|
|
|
2019-03-20 11:57:07 +01:00
|
|
|
rule
|
2018-09-12 16:16:18 +01:00
|
|
|
.save()
|
2019-03-20 11:57:07 +01:00
|
|
|
.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
|
|
|
});
|