Bug Fixed attaching and detaching phases

This commit is contained in:
Luis Fernando Molina committed 2019-12-26 13:59:03 +01:00
1 parent 6b42383e87
commit a596068600
2 files changed
+56 -25

No files matched your search

@@ -96,11 +96,6 @@ function newChainAttachDetach () {
case 'Phase': {
switch (attachToNode.type) {
case 'Stop': {
if (attachToNode.maxPhases !== undefined) {
if (attachToNode.phases.length >= attachToNode.maxPhases) {
return
}
}
node.payload.parentNode = attachToNode
if (attachToNode.phases.length > 0) {
let phase = attachToNode.phases[attachToNode.phases.length - 1]
@@ -113,10 +108,36 @@ function newChainAttachDetach () {
}
break
case 'Take Profit': {
if (attachToNode.maxPhases !== undefined) {
if (attachToNode.phases.length >= attachToNode.maxPhases) {
return
}
node.payload.parentNode = attachToNode
if (attachToNode.phases.length > 0) {
let phase = attachToNode.phases[attachToNode.phases.length - 1]
node.payload.chainParent = phase
} else {
node.payload.chainParent = attachToNode
}
attachToNode.phases.push(node)
completeAttachment(node, rootNodes)
}
break
case 'Initial Stop': {
if (attachToNode.phases.length >= 1) {
return
}
node.payload.parentNode = attachToNode
if (attachToNode.phases.length > 0) {
let phase = attachToNode.phases[attachToNode.phases.length - 1]
node.payload.chainParent = phase
} else {
node.payload.chainParent = attachToNode
}
attachToNode.phases.push(node)
completeAttachment(node, rootNodes)
}
break
case 'Initial Take Profit': {
if (attachToNode.phases.length >= 1) {
return
}
node.payload.parentNode = attachToNode
if (attachToNode.phases.length > 0) {
@@ -62,21 +62,23 @@ function newUiObjectsFromNodes () {
/* For the cases where an node is not chained to its parent but to the one at the parent before it at its collection */
if (nodeDefinition.chainedToSameType === true) {
let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type)
if (parentNodeDefinition !== undefined) {
if (parentNodeDefinition.properties !== undefined) {
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
let property = parentNodeDefinition.properties[i]
if (property.childType === node.type) {
if (property.type === 'array') {
if (parentNode[property.name] !== undefined) {
if (parentNode[property.name].length > 1) {
let nodeChildren = parentNode[property.name]
for (let j = 0; j < nodeChildren.length; j++) {
if (node.id === nodeChildren[j].id) {
if (j > 0) {
if (parentNode !== undefined) {
let parentNodeDefinition = APP_SCHEMA_MAP.get(parentNode.type)
if (parentNodeDefinition !== undefined) {
if (parentNodeDefinition.properties !== undefined) {
for (let i = 0; i < parentNodeDefinition.properties.length; i++) {
let property = parentNodeDefinition.properties[i]
if (property.childType === node.type) {
if (property.type === 'array') {
if (parentNode[property.name] !== undefined) {
if (parentNode[property.name].length > 1) {
let nodeChildren = parentNode[property.name]
for (let j = 0; j < nodeChildren.length; j++) {
if (node.id === nodeChildren[j].id) {
if (j > 0) {
chainParent = nodeChildren[j - 1]
}
}
}
}
}
@@ -156,8 +158,6 @@ function newUiObjectsFromNodes () {
}
}
createUiObject(true, object.type, object.name, object, parentNode, chainParent)
if (nodeDefinition !== undefined) {
if (nodeDefinition.initialValues !== undefined) {
if (nodeDefinition.initialValues.code !== undefined) {
@@ -184,7 +184,15 @@ function newUiObjectsFromNodes () {
if (parentNode[property.name] === undefined) {
parentNode[property.name] = []
}
parentNode[property.name].push(object)
if (property.maxItems !== undefined) {
if (parentNode[property.name].length < property.maxItems) {
parentNode[property.name].push(object)
} else {
return // Object can not be created.
}
} else {
parentNode[property.name].push(object)
}
}
break
}
@@ -192,6 +200,8 @@ function newUiObjectsFromNodes () {
}
}
createUiObject(true, object.type, object.name, object, parentNode, chainParent)
/* Auto Add more Children */
if (nodeDefinition.properties !== undefined) {
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.