2017-07-03 12:18:30 +01:00
|
|
|
import Rule from 'discourse/plugins/discourse-chat-integration/admin/models/rule'
|
2017-06-28 15:12:37 +01:00
|
|
|
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
|
|
|
|
2017-06-28 15:12:37 +01:00
|
|
|
|
|
|
|
export default Ember.Controller.extend({
|
2017-06-29 12:56:48 +01:00
|
|
|
modalShowing: false,
|
2017-06-29 20:19:40 +01:00
|
|
|
|
2017-06-28 18:04:21 +01:00
|
|
|
actions:{
|
2017-07-04 00:14:01 +01:00
|
|
|
create(){
|
2017-06-29 20:19:40 +01:00
|
|
|
this.set('modalShowing', true);
|
2017-07-04 00:14:01 +01:00
|
|
|
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){
|
2017-06-29 12:56:48 +01:00
|
|
|
this.set('modalShowing', true);
|
2017-07-04 00:14:01 +01:00
|
|
|
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-06-29 12:56:48 +01:00
|
|
|
|
2017-06-28 18:04:21 +01:00
|
|
|
}
|
2017-06-28 15:12:37 +01:00
|
|
|
|
|
|
|
});
|