discourse-chat-integration/assets/javascripts/admin/routes/admin-plugins-chat-integrat...

50 lines
1.2 KiB
JavaScript
Raw Normal View History

import DiscourseRoute from "discourse/routes/discourse";
import Group from "discourse/models/group";
import { action } from "@ember/object";
2022-03-06 15:18:46 -05:00
import RSVP from "rsvp";
export default DiscourseRoute.extend({
2017-08-02 06:33:50 -04:00
model(params) {
2022-03-06 15:18:46 -05:00
return RSVP.hash({
channels: this.store.findAll("channel", { provider: params.provider }),
2021-08-26 09:52:53 -04:00
provider: this.modelFor("admin-plugins-chat-integration").findBy(
"id",
params.provider
),
groups: Group.findAll(),
2020-09-04 07:23:28 -04:00
}).then((value) => {
value.channels.forEach((channel) => {
channel.set(
"rules",
2020-09-04 07:23:28 -04:00
channel.rules.map((rule) => {
rule = this.store.createRecord("rule", rule);
rule.set("channel", channel);
return rule;
})
);
});
2017-10-03 05:42:07 -04:00
return value;
});
},
2017-10-03 05:42:07 -04:00
serialize(model) {
return { provider: model["provider"].get("id") };
},
@action
closeModal() {
if (this.get("controller.modalShowing")) {
this.refresh();
this.set("controller.modalShowing", false);
}
return true; // Continue bubbling up, so the modal actually closes
},
@action
refreshProvider() {
this.refresh();
2020-09-04 07:23:28 -04:00
},
});