From 8caf355857e2339db6f75c9bf44be26448478c44 Mon Sep 17 00:00:00 2001 From: Chris Meyers Date: Tue, 10 Jan 2017 09:47:54 -0500 Subject: [PATCH] handle reload when deleting org card under edit --- .../list/organizations-list.controller.js | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) 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 9bae54afc8..769a844354 100644 --- a/awx/ui/client/src/organizations/list/organizations-list.controller.js +++ b/awx/ui/client/src/organizations/list/organizations-list.controller.js @@ -127,6 +127,16 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', }); }; + function isDeletedOrganizationBeingEdited(deleted_organization_id, editing_organization_id) { + if (editing_organization_id === undefined) { + return false; + } + if (deleted_organization_id == editing_organization_id) { + return true; + } + return false; + } + $scope.deleteOrganization = function(id, name) { var action = function() { @@ -137,7 +147,11 @@ export default ['$stateParams', '$scope', '$rootScope', '$location', Rest.destroy() .success(function() { Wait('stop'); - $state.reload('organizations'); + if (isDeletedOrganizationBeingEdited(id, $stateParams.organization_id) === true) { + $state.go('^', null, { reload: true }); + } else { + $state.reload('organizations'); + } }) .error(function(data, status) { ProcessErrors($scope, data, status, null, {