Fixed workflow bug deleting root parent while creating child

This commit is contained in:
mabashian
2017-08-07 12:45:32 -04:00
parent 2eaa00b633
commit 93dca5a317
4 changed files with 11 additions and 12 deletions

View File

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

View File

@@ -365,12 +365,12 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
}); });
// Set the default to success // Set the default to success
let edgeType = "success"; $scope.edgeType = "success";
if (parent && ((betweenTwoNodes && parent.source.isStartNode) || (!betweenTwoNodes && parent.isStartNode))) { if (parent && ((betweenTwoNodes && parent.source.isStartNode) || (!betweenTwoNodes && parent.isStartNode))) {
// We don't want to give the user the option to select // We don't want to give the user the option to select
// a type as this node will always be executed // a type as this node will always be executed
edgeType = "always"; $scope.edgeType = "always";
$scope.edgeFlags.showTypeOptions = false; $scope.edgeFlags.showTypeOptions = false;
} else { } else {
if ((_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && _.includes(siblingConnectionTypes, "always")) { if ((_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) && _.includes(siblingConnectionTypes, "always")) {
@@ -378,10 +378,10 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.edgeFlags.typeRestriction = null; $scope.edgeFlags.typeRestriction = null;
} else if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) { } else if (_.includes(siblingConnectionTypes, "success") || _.includes(siblingConnectionTypes, "failure")) {
$scope.edgeFlags.typeRestriction = "successFailure"; $scope.edgeFlags.typeRestriction = "successFailure";
edgeType = "success"; $scope.edgeType = "success";
} else if (_.includes(siblingConnectionTypes, "always")) { } else if (_.includes(siblingConnectionTypes, "always")) {
$scope.edgeFlags.typeRestriction = "always"; $scope.edgeFlags.typeRestriction = "always";
edgeType = "always"; $scope.edgeType = "always";
} else { } else {
$scope.edgeFlags.typeRestriction = null; $scope.edgeFlags.typeRestriction = null;
} }
@@ -392,7 +392,6 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
// Reset the edgeConflict flag // Reset the edgeConflict flag
resetEdgeConflict(); resetEdgeConflict();
$scope.$broadcast("setEdgeType", edgeType);
$scope.$broadcast("refreshWorkflowChart"); $scope.$broadcast("refreshWorkflowChart");
}; };
@@ -661,7 +660,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
$scope.edgeFlags.showTypeOptions = true; $scope.edgeFlags.showTypeOptions = true;
} }
$scope.$broadcast('setEdgeType', $scope.nodeBeingEdited.edgeType); $scope.edgeType = $scope.nodeBeingEdited.edgeType;
$scope.$broadcast('templateSelected', { $scope.$broadcast('templateSelected', {
presetValues: formValues, presetValues: formValues,
@@ -764,6 +763,7 @@ export default ['$scope', 'WorkflowService', 'GetBasePath', 'TemplatesService',
if($scope.workflowMakerFormConfig.nodeMode === "add") { if($scope.workflowMakerFormConfig.nodeMode === "add") {
if($scope.placeholderNode.isRoot) { if($scope.placeholderNode.isRoot) {
$scope.edgeType = "always";
$scope.edgeFlags.showTypeOptions = false; $scope.edgeFlags.showTypeOptions = false;
} }
} }

View File

@@ -11,7 +11,8 @@ export default ['templateUrl', 'CreateDialog', 'Wait', '$state', '$window',
return { return {
scope: { scope: {
workflowJobTemplateObj: '=', workflowJobTemplateObj: '=',
canAddWorkflowJobTemplate: '=' canAddWorkflowJobTemplate: '=',
edgeType: '='
}, },
restrict: 'E', restrict: 'E',
templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'), templateUrl: templateUrl('templates/workflows/workflow-maker/workflow-maker'),

View File

@@ -74,7 +74,8 @@ export default ['$q', function($q){
canAddTo: true, canAddTo: true,
placeholder: true, placeholder: true,
isNew: 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}); let parentNode = (params.betweenTwoNodes) ? this.searchTree({element: params.tree, matchingId: params.parent.source.id}) : this.searchTree({element: params.tree, matchingId: params.parent.id});