2017-06-28 15:12:37 +01:00
|
|
|
import { ajax } from 'discourse/lib/ajax';
|
|
|
|
|
|
|
|
export default Discourse.Route.extend({
|
|
|
|
|
|
|
|
model(params, transition) {
|
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-07-04 00:14:01 +01:00
|
|
|
provider: this.modelFor("admin-plugins-chat").findBy('id',params.provider)
|
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
|
|
|
},
|
|
|
|
|
|
|
|
serialize: function(model, params) {
|
2017-07-04 00:14:01 +01:00
|
|
|
return { provider: model['provider'].get('id')};
|
2017-06-29 12:56:48 +01:00
|
|
|
},
|
|
|
|
|
|
|
|
actions: {
|
|
|
|
closeModal: function(data){
|
|
|
|
if(this.get('controller.modalShowing')){
|
|
|
|
this.refresh();
|
|
|
|
this.set('controller.modalShowing', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return true; // Continue bubbling up, so the modal actually closes
|
|
|
|
},
|
|
|
|
|
2017-06-29 20:19:40 +01:00
|
|
|
refresh: function(data){
|
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
|
2017-06-28 15:12:37 +01:00
|
|
|
}
|
|
|
|
});
|