Refresh the list of rules when the modal dialog closes

This commit is contained in:
David Taylor 2017-06-29 12:56:48 +01:00
parent 8e0bec6e6f
commit 304d8f962f
3 changed files with 17 additions and 18 deletions

View File

@ -5,13 +5,14 @@ import showModal from 'discourse/lib/show-modal';
export default Ember.Controller.extend({
modalShowing: false,
actions:{
edit(rule){
console.log(rule.hasDirtyAttributes);
this.set('modalShowing', true);
showModal('admin-plugins-chat-edit-rule', { model: rule, admin: true });
},
}
});

View File

@ -4,11 +4,10 @@ import { ajax } from 'discourse/lib/ajax';
export default Ember.Controller.extend({
model: Rule.create({}),
actions: {
cancel: function(){
this.set('model', null);
this.set('workingCopy', null);
this.send('closeModal');
},
}

View File

@ -4,23 +4,22 @@ import { ajax } from 'discourse/lib/ajax';
export default Discourse.Route.extend({
model(params, transition) {
console.log("Loading rules for "+params.provider)
return this.store.find('rule', {provider: params.provider});
// var url = '/admin/plugins/chat'
// if(params.provider !== undefined){
// url += `/${params.provider}`
// }
// url += '.json'
// return ajax(url).then(result => {
// var rules = result.rules.map(v => FilterRule.create(v))
// var providers = result.providers
// return {provider: result.provider, rules: rules, providers: providers};
// });
},
serialize: function(model, params) {
return { provider: model['provider']};
},
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
},
}
});