1
0
mirror of https://github.com/ansible/awx.git synced 2024-10-31 15:21:13 +03:00

Merge pull request #270 from mabashian/5177-workflows

Various workflow maker bug fixes
This commit is contained in:
Michael Abashian 2017-08-15 10:31:26 -04:00 committed by GitHub
commit 6b3dd7bfde
4 changed files with 34 additions and 35 deletions

View File

@ -326,7 +326,7 @@ angular.module('templates', [surveyMaker.name, templatesList.name, jobTemplates.
},
views: {
'modal': {
template: `<workflow-maker ng-if="includeWorkflowMaker" workflow-job-template-obj="workflow_job_template_obj" can-add-workflow-job-template="canAddWorkflowJobTemplate" edge-type="edgeType"></workflow-maker>`
template: `<workflow-maker ng-if="includeWorkflowMaker" workflow-job-template-obj="workflow_job_template_obj" can-add-workflow-job-template="canAddWorkflowJobTemplate"></workflow-maker>`
},
'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;
});
}
]
}

View File

@ -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")

View File

@ -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;
}
}

View File

@ -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'),