Remove reference to isStartNode and just check the id of the node to determine if it's our start node or not

This commit is contained in:
mabashian
2018-11-19 14:43:34 -05:00
parent 623cf54766
commit 56885a5da1
3 changed files with 12 additions and 15 deletions

View File

@@ -454,7 +454,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
if( if(
d.edgeType !== 'placeholder' && d.edgeType !== 'placeholder' &&
!scope.graphState.isLinkMode && !scope.graphState.isLinkMode &&
!d.source.isStartNode && d.source.id !== 1 &&
d.source.id !== scope.graphState.nodeBeingAdded && d.source.id !== scope.graphState.nodeBeingAdded &&
d.target.id !== scope.graphState.nodeBeingAdded && d.target.id !== scope.graphState.nodeBeingAdded &&
scope.mode !== 'details' scope.mode !== 'details'
@@ -467,7 +467,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
} }
}) })
.on("mouseout", function(d){ .on("mouseout", function(d){
if(!d.source.isStartNode && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details') { if(d.source.id !== 1 && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details') {
$(`#aw-workflow-chart-g`).prepend($(`#link-${d.source.id}-${d.target.id}`)); $(`#aw-workflow-chart-g`).prepend($(`#link-${d.source.id}-${d.target.id}`));
d3.select("#link-" + d.source.id + "-" + d.target.id) d3.select("#link-" + d.source.id + "-" + d.target.id)
.classed("WorkflowChart-linkHovering", false); .classed("WorkflowChart-linkHovering", false);
@@ -486,7 +486,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
if( if(
d.edgeType !== 'placeholder' && d.edgeType !== 'placeholder' &&
!scope.graphState.isLinkMode && !scope.graphState.isLinkMode &&
!d.source.isStartNode && d.source.id !== 1 &&
d.source.id !== scope.graphState.nodeBeingAdded && d.source.id !== scope.graphState.nodeBeingAdded &&
d.target.id !== scope.graphState.nodeBeingAdded && d.target.id !== scope.graphState.nodeBeingAdded &&
scope.mode !== 'details' scope.mode !== 'details'
@@ -499,7 +499,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
} }
}) })
.on("mouseleave", function(d){ .on("mouseleave", function(d){
if(!d.source.isStartNode && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details') { if(d.source.id !== 1 && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details') {
$(`#aw-workflow-chart-g`).prepend($(`#link-${d.source.id}-${d.target.id}`)); $(`#aw-workflow-chart-g`).prepend($(`#link-${d.source.id}-${d.target.id}`));
d3.select("#link-" + d.source.id + "-" + d.target.id) d3.select("#link-" + d.source.id + "-" + d.target.id)
.classed("WorkflowChart-linkHovering", false); .classed("WorkflowChart-linkHovering", false);
@@ -796,7 +796,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
nodeEnter.each(function(d) { nodeEnter.each(function(d) {
let thisNode = d3.select(this); let thisNode = d3.select(this);
if(d.isStartNode && scope.mode === 'details') { if(d.id === 1 && scope.mode === 'details') {
// Overwrite the default root height and width and replace it with a small blue square // Overwrite the default root height and width and replace it with a small blue square
rootW = 25; rootW = 25;
rootH = 25; rootH = 25;
@@ -809,7 +809,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
.attr("fill", "#337ab7") .attr("fill", "#337ab7")
.attr("class", "WorkflowChart-rootNode"); .attr("class", "WorkflowChart-rootNode");
} }
else if(d.isStartNode && scope.mode !== 'details') { else if(d.id === 1 && scope.mode !== 'details') {
thisNode.append("rect") thisNode.append("rect")
.attr("width", rootW) .attr("width", rootW)
.attr("height", rootH) .attr("height", rootH)
@@ -951,7 +951,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
.attr("class", function(d) { return d.isInvalidLinkTarget ? "WorkflowChart-nodeOverlay WorkflowChart-nodeOverlay--disabled" : "WorkflowChart-nodeOverlay WorkflowChart-nodeOverlay--transparent"; }) .attr("class", function(d) { return d.isInvalidLinkTarget ? "WorkflowChart-nodeOverlay WorkflowChart-nodeOverlay--disabled" : "WorkflowChart-nodeOverlay WorkflowChart-nodeOverlay--transparent"; })
.call(node_click) .call(node_click)
.on("mouseover", function(d) { .on("mouseover", function(d) {
if(!d.isStartNode) { if(d.id !== 1) {
$(`#node-${d.id}`).appendTo(`#aw-workflow-chart-g`); $(`#node-${d.id}`).appendTo(`#aw-workflow-chart-g`);
let resourceName = (d.unifiedJobTemplate && d.unifiedJobTemplate.name) ? d.unifiedJobTemplate.name : ""; let resourceName = (d.unifiedJobTemplate && d.unifiedJobTemplate.name) ? d.unifiedJobTemplate.name : "";
if(resourceName && resourceName.length > maxNodeTextLength) { if(resourceName && resourceName.length > maxNodeTextLength) {
@@ -1016,7 +1016,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
.on("mouseout", function(d){ .on("mouseout", function(d){
$('.WorkflowChart-tooltip').remove(); $('.WorkflowChart-tooltip').remove();
$('.WorkflowChart-potentialLink').remove(); $('.WorkflowChart-potentialLink').remove();
if(!d.isStartNode) { if(d.id !== 1) {
d3.select("#node-" + d.id) d3.select("#node-" + d.id)
.classed("WorkflowChart-nodeHovering", false); .classed("WorkflowChart-nodeHovering", false);
} }
@@ -1122,7 +1122,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
.attr("cy", nodeH) .attr("cy", nodeH)
.attr("r", 10) .attr("r", 10)
.attr("class", "WorkflowChart-nodeRemoveCircle") .attr("class", "WorkflowChart-nodeRemoveCircle")
.style("display", function(d) { return (d.isStartNode || d.id === scope.graphState.nodeBeingAdded || scope.readOnly) ? "none" : null; }) .style("display", function(d) { return (d.id === 1 || d.id === scope.graphState.nodeBeingAdded || scope.readOnly) ? "none" : null; })
.call(remove_node) .call(remove_node)
.on("mouseover", function(d) { .on("mouseover", function(d) {
d3.select("#node-" + d.id) d3.select("#node-" + d.id)
@@ -1144,7 +1144,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
.size(60) .size(60)
.type("cross") .type("cross")
) )
.style("display", function(d) { return (d.isStartNode || d.id === scope.graphState.nodeBeingAdded || scope.readOnly) ? "none" : null; }) .style("display", function(d) { return (d.id === 1 || d.id === scope.graphState.nodeBeingAdded || scope.readOnly) ? "none" : null; })
.call(remove_node) .call(remove_node)
.on("mouseover", function(d) { .on("mouseover", function(d) {
d3.select("#node-" + d.id) d3.select("#node-" + d.id)
@@ -1260,7 +1260,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
function remove_node() { function remove_node() {
this.on("click", function(d) { this.on("click", function(d) {
if(!d.isStartNode && !scope.readOnly && !scope.graphState.isLinkMode) { if(d.id !== 1 && !scope.readOnly && !scope.graphState.isLinkMode) {
scope.deleteNode({ scope.deleteNode({
nodeToDelete: d nodeToDelete: d
}); });
@@ -1288,7 +1288,7 @@ export default ['$state','moment', '$timeout', '$window', '$filter', 'Rest', 'Ge
function edit_link() { function edit_link() {
this.on("click", function(d) { this.on("click", function(d) {
if(!scope.graphState.isLinkMode && !d.source.isStartNode && d.source.id !== scope.graphState.nodeBeingAdded && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details'){ if(!scope.graphState.isLinkMode && d.source.id !== 1 && d.source.id !== scope.graphState.nodeBeingAdded && d.target.id !== scope.graphState.nodeBeingAdded && scope.mode !== 'details'){
scope.editLink({ scope.editLink({
linkToEdit: d linkToEdit: d
}); });

View File

@@ -10,9 +10,7 @@ export default [function(){
let nodeIdCounter = 1; let nodeIdCounter = 1;
let arrayOfNodesForChart = [ let arrayOfNodesForChart = [
{ {
index: 0,
id: nodeIdCounter, id: nodeIdCounter,
isStartNode: true,
unifiedJobTemplate: { unifiedJobTemplate: {
name: "START" name: "START"
} }

View File

@@ -537,7 +537,6 @@ export default ['$scope', 'TemplatesService',
}; };
if (parentId === 1) { if (parentId === 1) {
child.edgeType = "always"; child.edgeType = "always";
source.isStartNode = true;
} }
$scope.graphState.arrayOfLinksForChart.push({ $scope.graphState.arrayOfLinksForChart.push({
source, source,