2018-09-12 16:16:18 +01:00
|
|
|
import ModalFunctionality from "discourse/mixins/modal-functionality";
|
|
|
|
|
import { popupAjaxError } from "discourse/lib/ajax-error";
|
|
|
|
|
import {
|
|
|
|
|
default as computed,
|
|
|
|
|
on
|
|
|
|
|
} from "ember-addons/ember-computed-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", () => {
|
|
|
|
|
$("#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) {
|
2018-09-12 16:16:18 +01: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);
|
2017-07-31 17:09:21 +01:00
|
|
|
}
|
|
|
|
|
}
|
2017-10-03 17:42:07 +08:00
|
|
|
});
|