From 93dca5a3173bec8b4a3c688fff8dfce56af6164a Mon Sep 17 00:00:00 2001 From: mabashian Date: Mon, 7 Aug 2017 12:45:32 -0400 Subject: [PATCH] Fixed workflow bug deleting root parent while creating child --- awx/ui/client/src/templates/main.js | 5 +---- .../workflow-maker/workflow-maker.controller.js | 12 ++++++------ .../workflow-maker/workflow-maker.directive.js | 3 ++- .../src/templates/workflows/workflow.service.js | 3 ++- 4 files changed, 11 insertions(+), 12 deletions(-) diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index dbaf88d3e6..4bcfc1fa9b 100644 --- a/awx/ui/client/src/templates/main.js +++ b/awx/ui/client/src/templates/main.js @@ -326,7 +326,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates. }, views: { 'modal': { - template: `` + template: `` }, 'jobTemplateList@templates.editWorkflowJobTemplate.workflowMaker': { templateProvider: function(WorkflowMakerJobTemplateList, generateList) { @@ -620,9 +620,6 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates. }); }); - $scope.$on('setEdgeType', function(e, edgeType) { - $scope.edgeType = edgeType; - }); } ] } 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 9135e294a2..13027aedf4 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 @@ -365,12 +365,12 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', }); // Set the default to success - let edgeType = "success"; + $scope.edgeType = "success"; if (parent && ((betweenTwoNodes && parent.source.isStartNode) || (!betweenTwoNodes && parent.isStartNode))) { // We don't want to give the user the option to select // a type as this node will always be executed - edgeType = "always"; + $scope.edgeType = "always"; $scope.edgeFlags.showTypeOptions = false; } else { if ((_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && _.includes(siblingConnectionTypes, "always")) { @@ -378,10 +378,10 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', $scope.edgeFlags.typeRestriction = null; } else if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) { $scope.edgeFlags.typeRestriction = "successFailure"; - edgeType = "success"; + $scope.edgeType = "success"; } else if (_.includes(siblingConnectionTypes, "always")) { $scope.edgeFlags.typeRestriction = "always"; - edgeType = "always"; + $scope.edgeType = "always"; } else { $scope.edgeFlags.typeRestriction = null; } @@ -392,7 +392,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', // Reset the edgeConflict flag resetEdgeConflict(); - $scope.$broadcast("setEdgeType", edgeType); $scope.$broadcast("refreshWorkflowChart"); }; @@ -661,7 +660,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', $scope.edgeFlags.showTypeOptions = true; } - $scope.$broadcast('setEdgeType', $scope.nodeBeingEdited.edgeType); + $scope.edgeType = $scope.nodeBeingEdited.edgeType; $scope.$broadcast('templateSelected', { presetValues: formValues, @@ -764,6 +763,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', if($scope.workflowMakerFormConfig.nodeMode === "add") { if($scope.placeholderNode.isRoot) { + $scope.edgeType = "always"; $scope.edgeFlags.showTypeOptions = false; } } diff --git a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.directive.js b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.directive.js index 03ee776dfe..676e856d24 100644 --- a/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.directive.js +++ b/awx/ui/client/src/templates/workflows/workflow-maker/workflow-maker.directive.js @@ -11,7 +11,8 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state', '$window', return { scope: { workflowJobTemplateObj: '=', - canAddWorkflowJobTemplate: '=' + canAddWorkflowJobTemplate: '=', + edgeType: '=' }, restrict: 'E', templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'), diff --git a/awx/ui/client/src/templates/workflows/workflow.service.js b/awx/ui/client/src/templates/workflows/workflow.service.js index a83b7ef3da..293672045e 100644 --- a/awx/ui/client/src/templates/workflows/workflow.service.js +++ b/awx/ui/client/src/templates/workflows/workflow.service.js @@ -74,7 +74,8 @@ export default ['$q', function($q){ canAddTo: true, placeholder: true, isNew: true, - edited: false + edited: false, + isRoot: params.parent.isStartNode ? true : false }; let parentNode = (params.betweenTwoNodes) ? this.searchTree({element: params.tree, matchingId: params.parent.source.id}) : this.searchTree({element: params.tree, matchingId: params.parent.id});