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

50 lines
1.2 KiB
Plaintext
Raw Normal View History

import DiscourseRoute from "discourse/routes/discourse";
import Group from "discourse/models/group";
export default DiscourseRoute.extend({
2017-08-02 06:33:50 -04:00
model(params) {
return Ember.RSVP.hash({
channels: this.store.findAll("channel", { provider: params.provider }),
provider: this.modelFor("admin-plugins-chat").findBy(
"id",
params.provider
),
2020-09-04 07:23:28 -04:00
groups: Group.findAll().then((groups) => {
return groups.filter((g) => !g.get("automatic"));
}),
}).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") };
},
actions: {
2017-10-03 05:42:07 -04:00
closeModal() {
if (this.get("controller.modalShowing")) {
this.refresh();
this.set("controller.modalShowing", false);
}
return true; // Continue bubbling up, so the modal actually closes
},
refreshProvider() {
this.refresh();
2020-09-04 07:23:28 -04:00
},
},
});