Files
discourse-chat-integration/assets/javascripts/admin/controllers/admin-plugins-chat-provider.js.es6
T

74 lines
1.8 KiB
JavaScript
Raw Normal View History

2017-06-28 18:04:21 +01:00
import showModal from 'discourse/lib/show-modal';
2017-10-03 17:42:07 +08:00
import computed from "ember-addons/ember-computed-decorators";
export default Ember.Controller.extend({
2017-08-21 16:46:43 +01:00
modalShowing: false,
2017-10-03 17:42:07 +08:00
@computed('model.channels')
anyErrors(channels) {
let anyErrors = false;
channels.forEach((channel) => {
if (channel.error_key) {
2017-07-04 19:37:56 +01:00
anyErrors = true;
}
});
2017-10-03 17:42:07 +08:00
2017-07-04 19:37:56 +01:00
return anyErrors;
2017-10-03 17:42:07 +08:00
},
2017-07-04 19:37:56 +01:00
2017-06-28 18:04:21 +01:00
actions:{
2017-10-03 17:42:07 +08:00
createChannel() {
2017-08-21 16:46:43 +01:00
this.set('modalShowing', true);
2017-10-03 17:42:07 +08:00
const model = {
channel: this.store.createRecord('channel', { provider: this.get('model.provider.id'), data:{} }),
provider: this.get('model.provider')
};
2017-08-21 16:46:43 +01:00
showModal('admin-plugins-chat-edit-channel', { model: model, admin: true });
},
2017-10-03 17:42:07 +08:00
editChannel(channel) {
2017-08-21 16:46:43 +01:00
this.set('modalShowing', true);
2017-10-03 17:42:07 +08:00
const model = {
channel: channel,
provider: this.get('model.provider')
};
2017-08-21 16:46:43 +01:00
showModal('admin-plugins-chat-edit-channel', { model: model, admin: true });
},
2017-10-03 17:42:07 +08:00
testChannel(channel) {
this.set('modalShowing', true);
2017-10-03 17:42:07 +08:00
showModal('admin-plugins-chat-test', { model: { channel: channel }, admin: true });
},
2017-07-31 17:09:21 +01:00
createRule(channel){
this.set('modalShowing', true);
2017-10-03 17:42:07 +08:00
const model = {
rule: this.store.createRecord('rule', { channel_id: channel.id }),
channel: channel,
provider: this.get('model.provider'),
groups: this.get('model.groups')
};
2017-07-31 17:09:21 +01:00
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
},
editRule(rule, channel){
this.set('modalShowing', true);
2017-10-03 17:42:07 +08:00
const model = {
rule: rule,
channel: channel,
provider: this.get('model.provider'),
groups: this.get('model.groups')
};
2017-07-31 17:09:21 +01:00
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
},
2017-06-28 18:04:21 +01:00
}
2017-10-03 17:42:07 +08:00
});