2018-09-12 11:16:18 -04:00
|
|
|
import Group from "discourse/models/group";
|
2017-06-28 10:12:37 -04:00
|
|
|
|
|
|
|
export default Discourse.Route.extend({
|
2017-08-02 06:33:50 -04:00
|
|
|
model(params) {
|
2017-06-29 15:19:40 -04:00
|
|
|
return Ember.RSVP.hash({
|
2018-09-12 11:16:18 -04:00
|
|
|
channels: this.store.findAll("channel", { provider: params.provider }),
|
|
|
|
provider: this.modelFor("admin-plugins-chat").findBy(
|
|
|
|
"id",
|
|
|
|
params.provider
|
|
|
|
),
|
2017-08-01 10:20:00 -04:00
|
|
|
groups: Group.findAll().then(groups => {
|
2018-09-12 11:16:18 -04:00
|
|
|
return groups.filter(g => !g.get("automatic"));
|
2017-08-01 10:20:00 -04:00
|
|
|
})
|
2017-07-18 11:17:03 -04:00
|
|
|
}).then(value => {
|
|
|
|
value.channels.forEach(channel => {
|
2018-09-12 11:16:18 -04:00
|
|
|
channel.set(
|
|
|
|
"rules",
|
|
|
|
channel.rules.map(rule => {
|
|
|
|
rule = this.store.createRecord("rule", rule);
|
|
|
|
rule.channel = channel;
|
|
|
|
return rule;
|
|
|
|
})
|
|
|
|
);
|
2017-07-18 11:17:03 -04:00
|
|
|
});
|
2017-10-03 05:42:07 -04:00
|
|
|
|
2017-07-18 11:17:03 -04:00
|
|
|
return value;
|
2017-06-29 15:19:40 -04:00
|
|
|
});
|
2017-06-28 10:12:37 -04:00
|
|
|
},
|
|
|
|
|
2017-10-03 05:42:07 -04:00
|
|
|
serialize(model) {
|
2018-09-12 11:16:18 -04:00
|
|
|
return { provider: model["provider"].get("id") };
|
2017-06-29 07:56:48 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
2017-10-03 05:42:07 -04:00
|
|
|
closeModal() {
|
2018-09-12 11:16:18 -04:00
|
|
|
if (this.get("controller.modalShowing")) {
|
2017-06-29 07:56:48 -04:00
|
|
|
this.refresh();
|
2018-09-12 11:16:18 -04:00
|
|
|
this.set("controller.modalShowing", false);
|
2017-06-29 07:56:48 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
return true; // Continue bubbling up, so the modal actually closes
|
|
|
|
},
|
|
|
|
|
2019-03-20 06:57:07 -04:00
|
|
|
refreshProvider() {
|
2017-06-29 15:19:40 -04:00
|
|
|
this.refresh();
|
|
|
|
}
|
2017-06-28 10:12:37 -04:00
|
|
|
}
|
|
|
|
});
|