From fb54484ed368db29eb94263413ea41331e7b1889 Mon Sep 17 00:00:00 2001 From: chouseknecht Date: Wed, 24 Jul 2013 11:45:34 -0400 Subject: [PATCH] AC-256 Fixed the out-of-sync tree issue, which leads to 'spurious error message'. --- awx/ui/static/js/controllers/Inventories.js | 32 ++++++++++++++++++--- awx/ui/static/js/helpers/Groups.js | 10 +++---- 2 files changed, 32 insertions(+), 10 deletions(-) diff --git a/awx/ui/static/js/controllers/Inventories.js b/awx/ui/static/js/controllers/Inventories.js index cfb208ac23..f227c26925 100644 --- a/awx/ui/static/js/controllers/Inventories.js +++ b/awx/ui/static/js/controllers/Inventories.js @@ -373,7 +373,13 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP return { addGroup: { label: 'Add Group', - action: function(obj) { GroupsAdd({ "inventory_id": id, group_id: null }); } + action: function(obj) { + scope.group_id = null; + if (!scope.$$phase) { + scope.$digest(); + } + GroupsAdd({ "inventory_id": id, group_id: null }); + } } } } @@ -381,16 +387,34 @@ function InventoriesEdit ($scope, $rootScope, $compile, $location, $log, $routeP return { addGroup: { label: 'Add Group', - action: function(obj) { GroupsList({ "inventory_id": id, group_id: $(obj).attr('group_id') }); } + action: function(obj) { + scope.group_id = $(obj).attr('group_id'); + if (!scope.$$phase) { + scope.$digest(); + } + GroupsList({ "inventory_id": id, group_id: $(obj).attr('group_id') }); + } }, edit: { label: 'Edit Group', - action: function(obj) { GroupsEdit({ "inventory_id": id, group_id: $(obj).attr('group_id') }); }, + action: function(obj) { + scope.group_id = $(obj).attr('group_id'); + if (!scope.$$phase) { + scope.$digest(); + } + GroupsEdit({ "inventory_id": id, group_id: $(obj).attr('group_id') }); + }, separator_before: true }, "delete": { label: 'Delete Group', - action: function(obj) { GroupsDelete({ scope: scope, "inventory_id": id, group_id: $(obj).attr('group_id') }) } + action: function(obj) { + scope.group_id = $(obj).attr('group_id'); + if (!scope.$$phase) { + scope.$digest(); + } + GroupsDelete({ scope: scope, "inventory_id": id, group_id: $(obj).attr('group_id') }); + } } } } diff --git a/awx/ui/static/js/helpers/Groups.js b/awx/ui/static/js/helpers/Groups.js index bc9320a1b6..80da927d2b 100644 --- a/awx/ui/static/js/helpers/Groups.js +++ b/awx/ui/static/js/helpers/Groups.js @@ -328,9 +328,9 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' .factory('GroupsDelete', ['$rootScope', '$location', '$log', '$routeParams', 'Rest', 'Alert', 'GroupForm', 'GenerateForm', - 'Prompt', 'ProcessErrors', 'GetBasePath', + 'Prompt', 'ProcessErrors', 'GetBasePath', 'RefreshTree', function($rootScope, $location, $log, $routeParams, Rest, Alert, GroupForm, GenerateForm, Prompt, ProcessErrors, - GetBasePath) { + GetBasePath, RefreshTree) { return function(params) { // Delete the selected group node. Disassociates it from its parent. var scope = params.scope; @@ -338,9 +338,6 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' var inventory_id = params.inventory_id; var obj = $('#tree-view li[group_id="' + group_id + '"]'); var parent = (obj.parent().last().prop('tagName') == 'LI') ? obj.parent().last() : obj.parent().parent().last(); - //if (parent.length > 0) { - // parent = parent.last(); - //} var url; if (parent.attr('type') == 'group') { @@ -354,7 +351,8 @@ angular.module('GroupsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', ' Rest.post({ id: group_id, disassociate: 1 }) .success( function(data, status, headers, config) { $('#prompt-modal').modal('hide'); - $('#tree-view').jstree("delete_node",obj); + RefreshTree({ scope: scope }); + //$('#tree-view').jstree("delete_node",obj); }) .error( function(data, status, headers, config) { $('#prompt-modal').modal('hide');