From 17f4903420f7d20e0981565b53365f9c810c361f Mon Sep 17 00:00:00 2001 From: Leigh Johnson Date: Mon, 27 Jun 2016 14:25:45 -0400 Subject: [PATCH] update user/admin counts on org cards when added/created in related form, resolves #2591 --- .../linkout/addUsers/addUsers.controller.js | 1 + .../controllers/organizations-admins.controller.js | 3 ++- .../controllers/organizations-users.controller.js | 1 + .../list/organizations-list.controller.js | 14 ++++++++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js index 388dbf55fe..7e417f8e02 100644 --- a/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js +++ b/awx/ui/client/src/organizations/linkout/addUsers/addUsers.controller.js @@ -67,6 +67,7 @@ export default ['$scope', '$rootScope', 'ProcessErrors', 'UserList', 'generateLi Wait('stop'); $scope.$parent.search('user'); $scope.closeModal(); + $scope.$parent.$emit('ReloadOrgListView'); }, function (error) { Wait('stop'); $rootScope.$broadcast("refreshList", listToClose); diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js index 45bdfd9dc5..2f2c844a49 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-admins.controller.js @@ -40,7 +40,7 @@ export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state', 'generat list.listTitle = listTitle; list.basePath = url; list.searchSize = "col-lg-12 col-md-12 col-sm-12 col-xs-12"; - + $scope.orgRelatedUrls = data.related; generator.inject(list, { mode: 'edit', scope: $scope, cancelButton: true }); @@ -78,6 +78,7 @@ export default ['$stateParams', '$scope', 'UserList', 'Rest', '$state', 'generat disassociate: true }).success(function () { $scope.search(list.iterator); + $scope.$emit('ReloadOrgListView'); }) .error(function (data, status) { ProcessErrors($scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js b/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js index 5ecf5ecc7b..3d7bdbfb28 100644 --- a/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js +++ b/awx/ui/client/src/organizations/linkout/controllers/organizations-users.controller.js @@ -77,6 +77,7 @@ disassociate: true }).success(function () { $scope.search(list.iterator); + $scope.$emit('ReloadOrgListView'); }) .error(function (data, status) { ProcessErrors($scope, data, status, null, { hdr: 'Error!', diff --git a/awx/ui/client/src/organizations/list/organizations-list.controller.js b/awx/ui/client/src/organizations/list/organizations-list.controller.js index 18b0226519..45350cd5e3 100644 --- a/awx/ui/client/src/organizations/list/organizations-list.controller.js +++ b/awx/ui/client/src/organizations/list/organizations-list.controller.js @@ -8,12 +8,12 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', '$log', '$compile', 'Rest', 'PaginateInit', 'SearchInit', 'OrganizationList', 'Alert', 'Prompt', 'ClearScope', 'ProcessErrors', 'GetBasePath', 'Wait', - '$state', 'generateList', + '$state', 'generateList', 'Refresh', function($stateParams, $scope, $rootScope, $location, $log, $compile, Rest, PaginateInit, SearchInit, OrganizationList, Alert, Prompt, ClearScope, ProcessErrors, GetBasePath, Wait, - $state, generateList) { + $state, generateList, Refresh) { ClearScope(); @@ -70,10 +70,20 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', }; $scope.$on("ReloadOrgListView", function() { + var url = GetBasePath('organizations') + '?'; if ($state.$current.self.name === "organizations" || $state.$current.self.name === "organizations.add") { $scope.activeCard = null; } + if ($scope[list.iterator + 'SearchFilters']){ + url = url + _.reduce($scope[list.iterator+'SearchFilters'], (result, filter) => result + '&' + filter.url, ''); + } + Refresh({ + scope: $scope, + set: list.name, + iterator: list.iterator, + url: url + }); });