Return a promise from Discourse.Group.findAll()

This commit is contained in:
Robin Ward 2014-02-06 14:37:08 -05:00
parent 003eb06807
commit bd0c2a74fc
2 changed files with 7 additions and 8 deletions

View File

@ -1,6 +1,5 @@
Discourse.AdminGroupsController = Ember.Controller.extend({
itemController: 'adminGroup',
aliasLevels: null,
actions: {
edit: function(group){
@ -13,8 +12,10 @@ Discourse.AdminGroupsController = Ember.Controller.extend({
self.set('refreshingAutoGroups', true);
Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function() {
self.set('model', Discourse.Group.findAll());
self.set('refreshingAutoGroups', false);
return Discourse.Group.findAll().then(function(groups) {
self.set('model', groups);
self.set('refreshingAutoGroups', false);
});
});
},

View File

@ -122,15 +122,13 @@ Discourse.Group = Discourse.Model.extend({
Discourse.Group.reopenClass({
findAll: function(){
var list = Discourse.SelectableArray.create();
Discourse.ajax("/admin/groups.json").then(function(groups){
return Discourse.ajax("/admin/groups.json").then(function(groups){
var list = Discourse.SelectableArray.create();
_.each(groups,function(group){
list.addObject(Discourse.Group.create(group));
});
return list;
});
return list;
},
aliasLevelOptions: function() {