From aa7e96c0fa0a47070f78d88900c705a35560ba11 Mon Sep 17 00:00:00 2001 From: Michael Campagnaro Date: Fri, 26 Jul 2013 19:46:42 -0400 Subject: [PATCH] Fix auto-group refresh response so that ajax callback runs --- .../javascripts/admin/controllers/admin_groups_controller.js | 5 +++-- app/assets/javascripts/admin/models/group.js | 2 +- app/controllers/admin/groups_controller.rb | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/admin/controllers/admin_groups_controller.js b/app/assets/javascripts/admin/controllers/admin_groups_controller.js index 5578afc09f8..8fb3ae9a841 100644 --- a/app/assets/javascripts/admin/controllers/admin_groups_controller.js +++ b/app/assets/javascripts/admin/controllers/admin_groups_controller.js @@ -10,9 +10,10 @@ Discourse.AdminGroupsController = Ember.Controller.extend({ var controller = this; this.set('refreshingAutoGroups', true); - Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}).then(function(){ + Discourse.ajax('/admin/groups/refresh_automatic_groups', {type: 'POST'}) + .then(function() { controller.set('model', Discourse.Group.findAll()); - controller.set('refreshingAutoGroups',false); + controller.set('refreshingAutoGroups', false); }); }, diff --git a/app/assets/javascripts/admin/models/group.js b/app/assets/javascripts/admin/models/group.js index c4e3df70764..3001fd7f924 100644 --- a/app/assets/javascripts/admin/models/group.js +++ b/app/assets/javascripts/admin/models/group.js @@ -44,7 +44,7 @@ Discourse.Group = Discourse.Model.extend({ return Discourse.ajax("/admin/groups/" + group.get('id'), {type: "DELETE"}) .then(function(){ return true; - }, function(jqXHR, status, error) { + }, function(error) { group.set('disableSave', false); bootbox.alert(I18n.t("admin.groups.delete_failed")); return false; diff --git a/app/controllers/admin/groups_controller.rb b/app/controllers/admin/groups_controller.rb index b362276faec..dfc97b1d0a1 100644 --- a/app/controllers/admin/groups_controller.rb +++ b/app/controllers/admin/groups_controller.rb @@ -6,7 +6,7 @@ class Admin::GroupsController < Admin::AdminController def refresh_automatic_groups Group.refresh_automatic_groups! - render json: "ok" + render json: success_json end def users @@ -22,7 +22,7 @@ class Admin::GroupsController < Admin::AdminController group.usernames = params[:group][:usernames] group.name = params[:group][:name] if params[:group][:name] if group.save - render json: "ok" + render json: success_json else render_json_error group end