diff --git a/awx/ui/client/src/templates/main.js b/awx/ui/client/src/templates/main.js index 4bcfc1fa9b..dbaf88d3e6 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,6 +620,9 @@ 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-chart/workflow-chart.directive.js b/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js index 6cc3c21522..0a945398a2 100644 --- a/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js +++ b/awx/ui/client/src/templates/workflows/workflow-chart/workflow-chart.directive.js @@ -304,7 +304,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge }).each(wrap); thisNode.append("foreignObject") - .attr("x", 43) + .attr("x", 54) .attr("y", 45) .style("font-size","0.7em") .attr("class", "WorkflowChart-conflictText") 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 13027aedf4..428ada820a 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 @@ -109,26 +109,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', // params.parentId // params.node - let generatePostUrl = function(){ - - let base = (params.parentId) ? GetBasePath('workflow_job_template_nodes') + params.parentId : $scope.treeData.workflow_job_template_obj.related.workflow_nodes; - - if(params.parentId) { - if(params.node.edgeType === 'success') { - base += "/success_nodes"; - } - else if(params.node.edgeType === 'failure') { - base += "/failure_nodes"; - } - else if(params.node.edgeType === 'always') { - base += "/always_nodes"; - } - } - - return base; - - }; - let buildSendableNodeData = function() { // Create the node let sendableNodeData = { @@ -198,10 +178,17 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', if(params.node.isNew) { TemplatesService.addWorkflowNode({ - url: generatePostUrl(), + url: $scope.treeData.workflow_job_template_obj.related.workflow_nodes, data: buildSendableNodeData() }) .then(function(data) { + + $scope.associateRequests.push({ + parentId: params.parentId, + nodeId: data.data.id, + edge: params.node.edgeType + }); + params.node.isNew = false; continueRecursing(data.data.id); }, function(error) { @@ -227,12 +214,22 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', if((params.node.originalParentId && params.parentId !== params.node.originalParentId) || params.node.originalEdge !== params.node.edgeType) {//beep - $scope.disassociateRequests.push({ - parentId: params.node.originalParentId, - nodeId: params.node.nodeId, - edge: params.node.originalEdge + let parentIsDeleted = false; + + _.forEach($scope.treeData.data.deletedNodes, function(deletedNode) { + if(deletedNode === params.node.originalParentId) { + parentIsDeleted = true; + } }); + if(!parentIsDeleted) { + $scope.disassociateRequests.push({ + parentId: params.node.originalParentId, + nodeId: params.node.nodeId, + edge: params.node.originalEdge + }); + } + // Can only associate if we have a parent. // If we don't have a parent then this is a root node // and the act of disassociating will make it a root node @@ -365,12 +362,12 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', }); // Set the default to success - $scope.edgeType = "success"; + let 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 - $scope.edgeType = "always"; + edgeType = "always"; $scope.edgeFlags.showTypeOptions = false; } else { if ((_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && _.includes(siblingConnectionTypes, "always")) { @@ -378,10 +375,10 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', $scope.edgeFlags.typeRestriction = null; } else if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) { $scope.edgeFlags.typeRestriction = "successFailure"; - $scope.edgeType = "success"; + edgeType = "success"; } else if (_.includes(siblingConnectionTypes, "always")) { $scope.edgeFlags.typeRestriction = "always"; - $scope.edgeType = "always"; + edgeType = "always"; } else { $scope.edgeFlags.typeRestriction = null; } @@ -392,6 +389,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', // Reset the edgeConflict flag resetEdgeConflict(); + $scope.$broadcast("setEdgeType", edgeType); $scope.$broadcast("refreshWorkflowChart"); }; @@ -660,7 +658,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService', $scope.edgeFlags.showTypeOptions = true; } - $scope.edgeType = $scope.nodeBeingEdited.edgeType; + $scope.$broadcast('setEdgeType', $scope.nodeBeingEdited.edgeType); $scope.$broadcast('templateSelected', { presetValues: formValues, @@ -763,7 +761,6 @@ 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 676e856d24..03ee776dfe 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,8 +11,7 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state', '$window', return { scope: { workflowJobTemplateObj: '=', - canAddWorkflowJobTemplate: '=', - edgeType: '=' + canAddWorkflowJobTemplate: '=' }, restrict: 'E', templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'),