2013-05-09 03:37:34 -04:00
|
|
|
Discourse.AdminGroupsController = Ember.Controller.extend({
|
2013-04-17 03:08:21 -04:00
|
|
|
itemController: 'adminGroup',
|
2013-05-08 01:20:38 -04:00
|
|
|
|
|
|
|
edit: function(group){
|
|
|
|
this.get('model').select(group);
|
2013-05-09 03:37:34 -04:00
|
|
|
group.load();
|
2013-05-08 01:20:38 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
refreshAutoGroups: function(){
|
|
|
|
var controller = this;
|
|
|
|
|
|
|
|
this.set('refreshingAutoGroups', true);
|
|
|
|
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function(){
|
|
|
|
controller.set('model', Discourse.Group.findAll());
|
|
|
|
controller.set('refreshingAutoGroups',false);
|
|
|
|
});
|
2013-05-09 03:37:34 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
newGroup: function(){
|
|
|
|
var group = Discourse.Group.create();
|
|
|
|
group.set("loaded", true);
|
|
|
|
var model = this.get("model");
|
|
|
|
model.addObject(group);
|
|
|
|
model.select(group);
|
|
|
|
},
|
2013-04-17 03:08:21 -04:00
|
|
|
|
2013-05-09 03:37:34 -04:00
|
|
|
save: function(group){
|
|
|
|
if(!group.get("id")){
|
|
|
|
group.create();
|
|
|
|
} else {
|
|
|
|
group.save();
|
|
|
|
}
|
|
|
|
},
|
2013-04-17 03:08:21 -04:00
|
|
|
|
2013-05-09 03:37:34 -04:00
|
|
|
destroy: function(group){
|
|
|
|
var list = this.get("model");
|
|
|
|
if(group.get("id")){
|
|
|
|
group.destroy().then(function(){
|
|
|
|
list.removeObject(group);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2013-04-17 03:08:21 -04:00
|
|
|
});
|
2013-05-09 03:37:34 -04:00
|
|
|
|