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

49 lines
1.1 KiB
Plaintext
Raw Normal View History

import Group from "discourse/models/group";
export default Discourse.Route.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
),
groups: Group.findAll().then(groups => {
return groups.filter(g => !g.get("automatic"));
})
}).then(value => {
value.channels.forEach(channel => {
channel.set(
"rules",
channel.rules.map(rule => {
rule = this.store.createRecord("rule", rule);
rule.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();
}
}
});