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