mirror of
https://github.com/ansible/awx.git
synced 2026-05-17 14:27:42 -02:30
Inventory refactor: fixed drag-n-drop so that a group cannot be dropped onto itself or dropped into a group where it already exists.
This commit is contained in:
@@ -417,7 +417,7 @@ angular.module('HostsHelper', [ 'RestServices', 'Utilities', 'ListGenerator', 'H
|
|||||||
})
|
})
|
||||||
.error( function(data, status, headers, config) {
|
.error( function(data, status, headers, config) {
|
||||||
ProcessErrors(scope, data, status, form,
|
ProcessErrors(scope, data, status, form,
|
||||||
{ hdr: 'Error!', msg: 'Failed to retrieve host: ' + id + '. GET returned status: ' + status });
|
{ hdr: 'Error!', msg: 'Failed to retrieve host: ' + host_id + '. GET returned status: ' + status });
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -376,12 +376,12 @@ dd {
|
|||||||
.help-link,
|
.help-link,
|
||||||
.help-link:active,
|
.help-link:active,
|
||||||
.help-link:visited {
|
.help-link:visited {
|
||||||
color: #49afcd;
|
color: @grey;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
.help-link:hover {
|
.help-link:hover {
|
||||||
color: @blue;
|
color: @black;
|
||||||
text-decoration: none;
|
text-decoration: none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P
|
|||||||
|
|
||||||
var children = [];
|
var children = [];
|
||||||
for (var j=0; j < sorted[i].children.length; j++) {
|
for (var j=0; j < sorted[i].children.length; j++) {
|
||||||
children.push(sorted[i].children[j]);
|
children.push(sorted[i].children[j].id);
|
||||||
}
|
}
|
||||||
|
|
||||||
var group = {
|
var group = {
|
||||||
|
|||||||
@@ -554,14 +554,30 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService'])
|
|||||||
// the following is inventory specific accept checking and
|
// the following is inventory specific accept checking and
|
||||||
// drop processing.
|
// drop processing.
|
||||||
accept: function(draggable) {
|
accept: function(draggable) {
|
||||||
var node = Find({ list: scope.groups, key: 'id', val: parseInt($(this).attr('data-tree-id')) });
|
if ($(this).attr('data-group-id') == draggable.attr('data-group-id')) {
|
||||||
if (node) {
|
// No dropping a node onto itself (or a copy)
|
||||||
var group = draggable.attr('data-group-id');
|
return false;
|
||||||
return (node.children.indexOf(group) > -1) ? false : true;
|
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
// this shouldn't be possible
|
// No dropping a node into a group that already has the node
|
||||||
return false;
|
var node = Find({ list: scope.groups, key: 'id', val: parseInt($(this).attr('data-tree-id')) });
|
||||||
|
if (node) {
|
||||||
|
var group = parseInt(draggable.attr('data-group-id'));
|
||||||
|
var found = false;
|
||||||
|
// For whatever reason indexOf() would not work...
|
||||||
|
for (var i=0; i < node.children.length; i++) {
|
||||||
|
if (node.children[i] == group) {
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
return (found) ? false : true;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
// this shouldn't be possible
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
over: function(e, ui) {
|
over: function(e, ui) {
|
||||||
|
|||||||
Reference in New Issue
Block a user