From be74d9d9322eddf67493d36ff1eb7c9750796d0e Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Tue, 5 Nov 2013 20:37:51 +0000 Subject: [PATCH] AC-536 No longer dissaociating hosts from /inventories/N/groups, so no more cases where dragging-n-dropping groups results in lost hosts. Fixed tree styling to better align nodes. --- awx/ui/static/less/ansible-ui.less | 5 +-- awx/ui/static/lib/ansible/TreeSelector.js | 40 +++++++++++++---------- 2 files changed, 25 insertions(+), 20 deletions(-) diff --git a/awx/ui/static/less/ansible-ui.less b/awx/ui/static/less/ansible-ui.less index ea3f3acaaa..994ca5a22c 100644 --- a/awx/ui/static/less/ansible-ui.less +++ b/awx/ui/static/less/ansible-ui.less @@ -1060,7 +1060,7 @@ input[type="checkbox"].checkbox-no-label { ul { list-style-type: none; - padding-left: 16px; + padding-left: 15px; } .tree-root { @@ -1105,13 +1105,14 @@ input[type="checkbox"].checkbox-no-label { .expand-container { width: 14px; - text-align: center; + text-align: left; } .badge-container { vertical-align: none; padding-top: 2px; padding-bottom: 2px; + margin-left: 3px; } #root-badge-container { diff --git a/awx/ui/static/lib/ansible/TreeSelector.js b/awx/ui/static/lib/ansible/TreeSelector.js index 8fe33e0999..d8cd08c851 100644 --- a/awx/ui/static/lib/ansible/TreeSelector.js +++ b/awx/ui/static/lib/ansible/TreeSelector.js @@ -252,12 +252,11 @@ angular.module('TreeSelector', ['Utilities', 'RestServices', 'TreeSelector', 'Gr var sublist, subicon; if (childlists && childlists.length > 0) { // has childen - for (var i=0; i < childlists.length; i++) { - sublist = angular.element(childlists[i]); - sublist.addClass('hidden'); - subicon = list.find('li')[0].children()[0]; + childlists.each(function(idx) { + $(this).addClass('hidden'); + subicon = $(this).find('li').first().find('.expand-container i'); subicon.removeClass('icon-caret-down').addClass('icon-caret-right'); - } + }); } /* When the active node's parent is closed, activate the parent */ if ($(parent).find('.active').length > 0) { @@ -329,19 +328,24 @@ angular.module('TreeSelector', ['Utilities', 'RestServices', 'TreeSelector', 'Gr scope.removeGroupRemove(); } scope.removeGroupRemove = scope.$on('removeGroup', function() { - var url = (parent.attr('data-group-id')) ? GetBasePath('base') + 'groups/' + parent.attr('data-group-id') + '/children/' : - GetBasePath('inventory') + inv_id + '/groups/'; - Rest.setUrl(url); - Rest.post({ id: node.attr('data-group-id'), disassociate: 1 }) - .success( function(data, status, headers, config) { - cleanUp('success'); - }) - .error( function(data, status, headers, config) { - cleanUp('fail'); - ProcessErrors(scope, data, status, null, - { hdr: 'Error!', msg: 'Failed to remove ' + node.attr('name') + ' from ' + - parent.attr('name') + '. POST returned status: ' + status }); - }); + if (parent.attr('data-group-id')) { + // Only remove a group from a parent when the parent is a group and not the inventory root + var url = GetBasePath('base') + 'groups/' + parent.attr('data-group-id') + '/children/'; + Rest.setUrl(url); + Rest.post({ id: node.attr('data-group-id'), disassociate: 1 }) + .success( function(data, status, headers, config) { + cleanUp('success'); + }) + .error( function(data, status, headers, config) { + cleanUp('fail'); + ProcessErrors(scope, data, status, null, + { hdr: 'Error!', msg: 'Failed to remove ' + node.attr('name') + ' from ' + + parent.attr('name') + '. POST returned status: ' + status }); + }); + } + else { + cleanUp('success'); + } }); if (scope['addToTargetRemove']) {