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
|
|
|
|
2013-09-16 14:08:55 -04:00
|
|
|
actions: {
|
|
|
|
edit: function(group){
|
|
|
|
this.get('model').select(group);
|
2014-02-06 15:11:46 -05:00
|
|
|
group.loadUsers();
|
2013-09-16 14:08:55 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
refreshAutoGroups: function(){
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
self.set('refreshingAutoGroups', true);
|
|
|
|
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
|
2014-02-06 14:37:08 -05:00
|
|
|
return Discourse.Group.findAll().then(function(groups) {
|
|
|
|
self.set('model', groups);
|
|
|
|
self.set('refreshingAutoGroups', false);
|
|
|
|
});
|
2013-09-16 14:08:55 -04:00
|
|
|
});
|
|
|
|
},
|
|
|
|
|
|
|
|
newGroup: function(){
|
2014-02-06 15:11:46 -05:00
|
|
|
var group = Discourse.Group.create({ loadedUsers: true }),
|
|
|
|
model = this.get("model");
|
2013-09-16 14:08:55 -04:00
|
|
|
model.addObject(group);
|
|
|
|
model.select(group);
|
|
|
|
},
|
|
|
|
|
|
|
|
save: function(group){
|
|
|
|
if(!group.get("id")){
|
|
|
|
group.create();
|
|
|
|
} else {
|
|
|
|
group.save();
|
2013-07-21 22:37:01 -04:00
|
|
|
}
|
2013-09-16 14:08:55 -04:00
|
|
|
},
|
|
|
|
|
|
|
|
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);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
2013-05-09 03:37:34 -04:00
|
|
|
}
|
2013-09-16 14:08:55 -04:00
|
|
|
|
2013-04-17 03:08:21 -04:00
|
|
|
});
|
2013-05-09 03:37:34 -04:00
|
|
|
|