Logic moved to workspace
This commit is contained in:
1 parent
b4512bbbe5
commit
c1b7da23d4
2 files changed
+71
-66
No files matched your search
@@ -293,72 +293,7 @@ function newStrategyPart () {
|
||||
}
|
||||
|
||||
if (isAttaching === true) {
|
||||
switch (thisObject.payload.node.type) {
|
||||
case 'Strategy': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
thisObject.payload.parentNode.strategies.push(thisObject.payload.node)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
switch (attachToNode.type) {
|
||||
case 'Stop': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
thisObject.payload.chainParent = phase
|
||||
} else {
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(thisObject.payload.node)
|
||||
}
|
||||
break
|
||||
case 'Take Profit': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
if (attachToNode.phases.length > 0) {
|
||||
let phase = attachToNode.phases[attachToNode.phases.length - 1]
|
||||
thisObject.payload.chainParent = phase
|
||||
} else {
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
}
|
||||
attachToNode.phases.push(thisObject.payload.node)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
thisObject.payload.parentNode = attachToNode.payload.parentNode
|
||||
for (let i = 0; i < thisObject.payload.parentNode.phases.length; i++) {
|
||||
let phase = thisObject.payload.parentNode.phases[i]
|
||||
if (attachToNode.id === phase.id) {
|
||||
if (i === thisObject.payload.parentNode.phases.length - 1) {
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
thisObject.payload.parentNode.phases.push(thisObject.payload.node)
|
||||
} else {
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
let nextPhase = thisObject.payload.parentNode.phases[i + 1]
|
||||
nextPhase.payload.chainParent = thisObject.payload.node
|
||||
thisObject.payload.parentNode.phases.splice(i + 1, 0, thisObject.payload.node)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'Situation': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
thisObject.payload.parentNode.situations.push(thisObject.payload.node)
|
||||
}
|
||||
break
|
||||
case 'Condition': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
thisObject.payload.parentNode.conditions.push(thisObject.payload.node)
|
||||
}
|
||||
break
|
||||
}
|
||||
canvas.strategySpace.workspace.attachNode(thisObject.payload.node, attachToNode)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@ function newWorkspace () {
|
||||
tradingSystem: undefined,
|
||||
container: undefined,
|
||||
detachNode: detachNode,
|
||||
attachNode: attachNode,
|
||||
getContainer: getContainer,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
@@ -123,6 +124,75 @@ function newWorkspace () {
|
||||
node.payload.parentNode = undefined
|
||||
}
|
||||
|
||||
function attachNode (node, attachToNode) {
|
||||
switch (node.type) {
|
||||
case 'Strategy': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.strategies.push(node)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
switch (attachToNode.type) {
|
||||
case 'Stop': {
|
||||
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)
|
||||
}
|
||||
break
|
||||
case 'Take Profit': {
|
||||
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)
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
node.payload.parentNode = attachToNode.payload.parentNode
|
||||
for (let i = 0; i < node.payload.parentNode.phases.length; i++) {
|
||||
let phase = node.payload.parentNode.phases[i]
|
||||
if (attachToNode.id === phase.id) {
|
||||
if (i === node.payload.parentNode.phases.length - 1) {
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.phases.push(node)
|
||||
} else {
|
||||
node.payload.chainParent = attachToNode
|
||||
let nextPhase = node.payload.parentNode.phases[i + 1]
|
||||
nextPhase.payload.chainParent = node
|
||||
node.payload.parentNode.phases.splice(i + 1, 0, node)
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'Situation': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.situations.push(node)
|
||||
}
|
||||
break
|
||||
case 'Condition': {
|
||||
node.payload.parentNode = attachToNode
|
||||
node.payload.chainParent = attachToNode
|
||||
node.payload.parentNode.conditions.push(node)
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
function createPart (partType, name, node, parentNode, chainParent, title) {
|
||||
let payload = {}
|
||||
if (chainParent === undefined) {
|
||||
|
||||
Reference in new issue
Block a user