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

44 lines
1.1 KiB
Plaintext
Raw Normal View History

import Group from 'discourse/models/group';
export default Discourse.Route.extend({
2017-08-02 11:33:50 +01: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;
}));
});
return value;
});
},
2017-08-02 11:33:50 +01:00
serialize: function(model) {
return { provider: model['provider'].get('id')};
},
actions: {
2017-08-02 11:33:50 +01:00
closeModal: function(){
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(){
this.refresh();
}
}
});