From cbdea119bd7243518c32720866a6232f81662ba4 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Tue, 20 Dec 2016 16:36:21 -0500 Subject: [PATCH 1/2] Fixed various issues with the lookup modals and lookup lists --- awx/ui/client/src/shared/form-generator.js | 2 +- awx/ui/client/src/shared/generator-helpers.js | 3 +- .../list-generator/list-generator.factory.js | 2 +- .../shared/lookup/lookup-modal.directive.js | 60 ++++++++++- .../shared/lookup/lookup-modal.partial.html | 2 +- .../src/shared/stateDefinitions.factory.js | 5 +- awx/ui/client/src/templates/main.js | 102 ++++++++++++++++-- .../workflow-maker.controller.js | 36 +++++-- 8 files changed, 186 insertions(+), 26 deletions(-) diff --git a/awx/ui/client/src/shared/form-generator.js b/awx/ui/client/src/shared/form-generator.js index e2aa526257..63146ce890 100644 --- a/awx/ui/client/src/shared/form-generator.js +++ b/awx/ui/client/src/shared/form-generator.js @@ -1328,7 +1328,7 @@ angular.module('FormGenerator', [GeneratorHelpers.name, 'Utilities', listGenerat //lookup type fields if (field.type === 'lookup') { - let defaultLookupNgClick = `$state.go($state.current.name + '.${field.sourceModel}')`; + let defaultLookupNgClick = `$state.go($state.current.name + '.${field.sourceModel}', {selected: ${field.sourceModel}})`; html += label(); html += "
`; + innerTable += ` `; } else { // its assumed that options.input_type = checkbox innerTable += "
diff --git a/awx/ui/client/src/shared/stateDefinitions.factory.js b/awx/ui/client/src/shared/stateDefinitions.factory.js index 2c3bb8c4cb..0033502454 100644 --- a/awx/ui/client/src/shared/stateDefinitions.factory.js +++ b/awx/ui/client/src/shared/stateDefinitions.factory.js @@ -455,7 +455,7 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat searchPrefix: field.sourceModel, //squashSearchUrl: true, @issue enable name: `${formStateDefinition.name}.${field.sourceModel}`, - url: `/${field.sourceModel}`, + url: `/${field.sourceModel}?selected`, // a lookup field's basePath takes precedence over generic list definition's basePath, if supplied data: { basePath: field.basePath || null, @@ -466,6 +466,9 @@ export default ['$injector', '$stateExtender', '$log', function($injector, $stat value: { page_size: '5' } } }, + ncyBreadcrumb: { + skip: true + }, views: { 'modal': { templateProvider: function(ListDefinition, generateList) { diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index 03b380bd58..e925b2e9f6 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -133,9 +133,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA $scope.list = list; $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + + $scope.$watch('job_templates', function(){ + if($scope.selectedTemplate){ + $scope.job_templates.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.job_templates[i].checked = 1; + } + else { + $scope.job_templates[i].checked = 0; + } + }); + } + }); } - $scope.toggle_job_template = function(id) { + $scope.toggle_row = function(id) { $scope.job_templates.forEach(function(row, i) { if (row.id === id) { @@ -153,7 +166,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA $scope.$on('templateSelected', function(e, options) { if(options.activeTab !== 'jobs') { - // Clear out any selected job + $scope.job_templates.forEach(function(row, i) { + $scope.job_templates[i].checked = 0; + }); + } + else { + if($scope.selectedTemplate){ + $scope.job_templates.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.job_templates[i].checked = 1; + } + else { + $scope.job_templates[i].checked = 0; + } + }); + } } }); } @@ -181,9 +208,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + $scope.$watch('workflow_inventory_sources', function(){ + if($scope.selectedTemplate){ + $scope.workflow_inventory_sources.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.workflow_inventory_sources[i].checked = 1; + } + else { + $scope.workflow_inventory_sources[i].checked = 0; + } + }); + } + }); } - $scope.toggle_inventory_source = function(id) { + $scope.toggle_row = function(id) { $scope.workflow_inventory_sources.forEach(function(row, i) { if (row.id === id) { @@ -200,8 +239,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA }; $scope.$on('templateSelected', function(e, options) { - if(options.activeTab !== 'project_sync') { - + if(options.activeTab !== 'inventory_sync') { + $scope.workflow_inventory_sources.forEach(function(row, i) { + $scope.workflow_inventory_sources[i].checked = 0; + }); + } + else { + if($scope.selectedTemplate){ + $scope.workflow_inventory_sources.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.workflow_inventory_sources[i].checked = 1; + } + else { + $scope.workflow_inventory_sources[i].checked = 0; + } + }); + } } }); } @@ -227,9 +280,21 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA $scope[`${list.iterator}_dataset`] = Dataset.data; $scope[list.name] = $scope[`${list.iterator}_dataset`].results; + $scope.$watch('projects', function(){ + if($scope.selectedTemplate){ + $scope.projects.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.projects[i].checked = 1; + } + else { + $scope.projects[i].checked = 0; + } + }); + } + }); } - $scope.toggle_project = function(id) { + $scope.toggle_row = function(id) { $scope.projects.forEach(function(row, i) { if (row.id === id) { @@ -246,8 +311,22 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA }; $scope.$on('templateSelected', function(e, options) { - if(options.activeTab !== 'inventory_sync') { - + if(options.activeTab !== 'project_sync') { + $scope.projects.forEach(function(row, i) { + $scope.projects[i].checked = 0; + }); + } + else { + if($scope.selectedTemplate){ + $scope.projects.forEach(function(row, i) { + if(row.id === $scope.selectedTemplate.id) { + $scope.projects[i].checked = 1; + } + else { + $scope.projects[i].checked = 0; + } + }); + } } }); } @@ -294,6 +373,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA }; $scope.$on('templateSelected', function(e, options) { + resetPromptFields(); // Loop across the preset values and attach them to scope _.forOwn(options.presetValues, function(value, key) { @@ -387,6 +467,9 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA dynamic: true } }, + ncyBreadcrumb: { + skip: true + }, views: { 'related': { templateProvider: function(ListDefinition, generateList) { @@ -439,6 +522,9 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplatesA dynamic: true } }, + ncyBreadcrumb: { + skip: true + }, views: { 'related': { templateProvider: function(ListDefinition, generateList) { diff --git a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js index 1e4f923a37..77f22a87af 100644 --- a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js +++ b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.controller.js @@ -560,17 +560,33 @@ export default ['$scope', 'WorkflowService', 'generateList', 'TemplateList', 'Pr $scope.selectedTemplate = $scope.nodeBeingEdited.unifiedJobTemplate; - switch ($scope.nodeBeingEdited.unifiedJobTemplate.type) { - case "job_template": - $scope.workflowMakerFormConfig.activeTab = "jobs"; - break; - case "project": - $scope.workflowMakerFormConfig.activeTab = "project_sync"; - break; - case "inventory_source": - $scope.workflowMakerFormConfig.activeTab = "inventory_sync"; - break; + if($scope.selectedTemplate.unified_job_type) { + switch ($scope.selectedTemplate.unified_job_type) { + case "job": + $scope.workflowMakerFormConfig.activeTab = "jobs"; + break; + case "project_update": + $scope.workflowMakerFormConfig.activeTab = "project_sync"; + break; + case "inventory_update": + $scope.workflowMakerFormConfig.activeTab = "inventory_sync"; + break; + } } + else if($scope.selectedTemplate.type) { + switch ($scope.selectedTemplate.type) { + case "job_template": + $scope.workflowMakerFormConfig.activeTab = "jobs"; + break; + case "project": + $scope.workflowMakerFormConfig.activeTab = "project_sync"; + break; + case "inventory_source": + $scope.workflowMakerFormConfig.activeTab = "inventory_sync"; + break; + } + } + } let siblingConnectionTypes = WorkflowService.getSiblingConnectionTypes({ From e1526083320ba9d035cae48bea66a2ebfa54b6d6 Mon Sep 17 00:00:00 2001 From: Michael Abashian Date: Wed, 21 Dec 2016 09:18:31 -0500 Subject: [PATCH 2/2] Removed escaped quotes from template literal string - not needed --- .../client/src/shared/list-generator/list-generator.factory.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/awx/ui/client/src/shared/list-generator/list-generator.factory.js b/awx/ui/client/src/shared/list-generator/list-generator.factory.js index 945fc18704..be67f0ce4b 100644 --- a/awx/ui/client/src/shared/list-generator/list-generator.factory.js +++ b/awx/ui/client/src/shared/list-generator/list-generator.factory.js @@ -317,7 +317,7 @@ export default ['$location', '$compile', '$rootScope', 'Attr', 'Icon', // Change layout if a lookup list, place radio buttons before labels if (options.mode === 'lookup') { if (options.input_type === "radio") { //added by JT so that lookup forms can be either radio inputs or check box inputs - innerTable += ` `; + innerTable += ` `; } else { // its assumed that options.input_type = checkbox innerTable += "