From c52818ecee9d25a8d53d9aff084399186eed7b40 Mon Sep 17 00:00:00 2001 From: Chris Houseknecht Date: Thu, 6 Feb 2014 15:19:58 -0500 Subject: [PATCH] AC-1023 AC-1025 fixed drag-n-drop issues. Linting exposed a datatype mismatch issue. --- awx/ui/static/js/helpers/Hosts.js | 4 ++-- awx/ui/static/lib/ansible/InventoryTree.js | 11 +++++------ awx/ui/static/lib/ansible/directives.js | 6 ++++-- awx/ui/static/lib/ansible/form-generator.js | 2 +- 4 files changed, 12 insertions(+), 11 deletions(-) diff --git a/awx/ui/static/js/helpers/Hosts.js b/awx/ui/static/js/helpers/Hosts.js index cb5e0628b4..4e60ca4698 100644 --- a/awx/ui/static/js/helpers/Hosts.js +++ b/awx/ui/static/js/helpers/Hosts.js @@ -634,9 +634,9 @@ function($rootScope, $location, $log, $routeParams, Rest, Alert, Prompt, Process url = (scope.selected_group_id === null) ? GetBasePath('inventory') + scope.inventory_id + '/hosts/' : GetBasePath('groups') + scope.selected_group_id + '/hosts/', - + group = (scope.selected_tree_id) ? Find({ list: scope.groups, key: 'id', val: scope.selected_tree_id }) : null; - + if (scope.removeHostsReload) { scope.removeHostsReload(); } diff --git a/awx/ui/static/lib/ansible/InventoryTree.js b/awx/ui/static/lib/ansible/InventoryTree.js index 7a56db007e..9f8731f8d3 100644 --- a/awx/ui/static/lib/ansible/InventoryTree.js +++ b/awx/ui/static/lib/ansible/InventoryTree.js @@ -402,14 +402,13 @@ angular.module('InventoryTree', ['Utilities', 'RestServices', 'GroupsHelper', 'P function($compile, Alert, ProcessErrors, Find, Wait, Rest, Empty, GetBasePath) { return function(params) { - var scope = params.scope; - var target = Find({ list: scope.groups, key: 'id', val: params.target_tree_id }); - var host = Find({ list: scope.hosts, key: 'id', val: params.host_id }); - - var found = false; + var scope = params.scope, + target = Find({ list: scope.groups, key: 'id', val: params.target_tree_id }), + host = Find({ list: scope.hosts, key: 'id', val: params.host_id }), + found = false, i; if (host.summary_fields.all_groups) { - for (var i=0; i< host.summary_fields.all_groups.length; i++) { + for (i=0; i< host.summary_fields.all_groups.length; i++) { if (host.summary_fields.all_groups[i].id == target.group_id) { found = true; break; diff --git a/awx/ui/static/lib/ansible/directives.js b/awx/ui/static/lib/ansible/directives.js index 6e1a001012..f7a3d25cb8 100644 --- a/awx/ui/static/lib/ansible/directives.js +++ b/awx/ui/static/lib/ansible/directives.js @@ -590,10 +590,12 @@ angular.module('AWDirectives', ['RestServices', 'Utilities', 'AuthService', 'Job // Drag-n-drop succeeded. Trigger a response from the inventory.edit controller $(this).removeClass('droppable-hover'); if (ui.draggable.attr('data-type') === 'group') { - scope.$emit('CopyMoveGroup', ui.draggable.attr('data-tree-id'), $(this).attr('data-tree-id')); + scope.$emit('CopyMoveGroup', parseInt(ui.draggable.attr('data-tree-id'),10), + parseInt($(this).attr('data-tree-id'),10)); } else if (ui.draggable.attr('data-type') === 'host') { - scope.$emit('CopyMoveHost', $(this).attr('data-tree-id'), ui.draggable.attr('data-host-id')); + scope.$emit('CopyMoveHost', parseInt($(this).attr('data-tree-id'),10), + parseInt(ui.draggable.attr('data-host-id'),10)); } }, tolerance: 'pointer' diff --git a/awx/ui/static/lib/ansible/form-generator.js b/awx/ui/static/lib/ansible/form-generator.js index 5d67311545..d7ce0277c2 100644 --- a/awx/ui/static/lib/ansible/form-generator.js +++ b/awx/ui/static/lib/ansible/form-generator.js @@ -201,7 +201,7 @@ function($rootScope, $location, $cookieStore, $compile, SearchWidget, PaginateWi applyDefaults: function() { for (var fld in this.form.fields) { - if (this.form.fields[fld].default || this.form.fields[fld].default === 0) { + if (this.form.fields[fld]['default'] || this.form.fields[fld]['default'] === 0) { if (this.form.fields[fld].type === 'select' && this.scope[fld + '_options']) { this.scope[fld] = this.scope[fld + '_options'][this.form.fields[fld]['default']]; }