REFACTOR: Add urls for admin groups, make it more idiomatic ember
This commit is contained in:
@@ -1,49 +1,23 @@
|
||||
Discourse.AdminGroupsController = Ember.Controller.extend({
|
||||
itemController: 'adminGroup',
|
||||
Discourse.AdminGroupsController = Ember.ArrayController.extend({
|
||||
sortProperties: ['name'],
|
||||
|
||||
refreshingAutoGroups: false,
|
||||
|
||||
actions: {
|
||||
edit: function(group){
|
||||
this.get('model').select(group);
|
||||
group.loadUsers();
|
||||
},
|
||||
|
||||
refreshAutoGroups: function(){
|
||||
var self = this;
|
||||
var self = this,
|
||||
groups = this.get('model');
|
||||
|
||||
self.set('refreshingAutoGroups', true);
|
||||
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
|
||||
return Discourse.Group.findAll().then(function(groups) {
|
||||
self.set('model', groups);
|
||||
self.set('refreshingAutoGroups', false);
|
||||
});
|
||||
});
|
||||
},
|
||||
|
||||
newGroup: function(){
|
||||
var group = Discourse.Group.create({ loadedUsers: true, visible: true }),
|
||||
model = this.get("model");
|
||||
model.addObject(group);
|
||||
model.select(group);
|
||||
},
|
||||
|
||||
save: function(group){
|
||||
if(!group.get("id")){
|
||||
group.create();
|
||||
} else {
|
||||
group.save();
|
||||
}
|
||||
},
|
||||
|
||||
destroy: function(group){
|
||||
var self = this;
|
||||
return bootbox.confirm(I18n.t("admin.groups.delete_confirm"), I18n.t("no_value"), I18n.t("yes_value"), function(result) {
|
||||
if (result) {
|
||||
group.destroy().then(function(deleted) {
|
||||
if (deleted) {
|
||||
self.get("model").removeObject(group);
|
||||
}
|
||||
this.transitionToRoute('adminGroups.index').then(function() {
|
||||
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
|
||||
return Discourse.Group.findAll().then(function(newGroups) {
|
||||
groups.clear();
|
||||
groups.addObjects(newGroups);
|
||||
}).finally(function() {
|
||||
self.set('refreshingAutoGroups', false);
|
||||
});
|
||||
}
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user