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

49 lines
1.5 KiB
JavaScript
Raw Normal View History

2017-07-03 12:18:30 +01:00
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
import { ajax } from 'discourse/lib/ajax';
import computed from "ember-addons/ember-computed-decorators";
2017-06-28 18:04:21 +01:00
import showModal from 'discourse/lib/show-modal';
2017-06-29 20:19:40 +01:00
import { popupAjaxError } from 'discourse/lib/ajax-error';
2017-06-28 18:04:21 +01:00
export default Ember.Controller.extend({
modalShowing: false,
2017-06-29 20:19:40 +01:00
2017-07-04 19:37:56 +01:00
anyErrors: function(){
var anyErrors = false;
this.get('model.rules').forEach(function(rule){
if(rule.error_key){
anyErrors = true;
}
});
return anyErrors;
}.property('model.rules'),
2017-06-28 18:04:21 +01:00
actions:{
create(){
2017-06-29 20:19:40 +01:00
this.set('modalShowing', true);
var model = {rule: this.store.createRecord('rule',{provider: this.get('model.provider').id}), provider:this.get('model.provider')};
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
2017-06-29 20:19:40 +01:00
},
2017-06-28 18:04:21 +01:00
edit(rule){
this.set('modalShowing', true);
var model = {rule: rule, provider:this.get('model.provider')};
showModal('admin-plugins-chat-edit-rule', { model: model, admin: true });
2017-06-28 18:04:21 +01:00
},
2017-06-29 20:19:40 +01:00
delete(rule){
const self = this;
rule.destroyRecord().then(function() {
self.send('refresh');
}).catch(popupAjaxError)
},
2017-07-04 19:37:56 +01:00
showError(error_key){
bootbox.alert(I18n.t(error_key));
},
test(){
this.set('modalShowing', true);
var model = {provider:this.get('model.provider'), channel:''}
showModal('admin-plugins-chat-test', { model: model, admin: true });
2017-07-04 19:37:56 +01:00
}
2017-06-28 18:04:21 +01:00
}
});