discourse/app/assets/javascripts/admin/controllers/admin_groups_controller.js

53 lines
1.3 KiB
JavaScript
Raw Normal View History

Discourse.AdminGroupsController = Ember.Controller.extend({
itemController: 'adminGroup',
2013-05-08 13:20:38 +08:00
2013-09-17 02:08:55 +08:00
actions: {
edit: function(group){
this.get('model').select(group);
group.loadUsers();
2013-09-17 02:08:55 +08:00
},
refreshAutoGroups: function(){
var self = this;
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);
});
2013-09-17 02:08:55 +08:00
});
},
newGroup: function(){
var group = Discourse.Group.create({ loadedUsers: true }),
model = this.get("model");
2013-09-17 02:08:55 +08:00
model.addObject(group);
model.select(group);
},
save: function(group){
if(!group.get("id")){
group.create();
} else {
group.save();
}
2013-09-17 02:08:55 +08: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-09-17 02:08:55 +08:00
});