Bug Fixed: while deleting parts without parent
This commit is contained in:
1 parent
40cceecd25
commit
683657ec58
2 files changed
+124
-48
No files matched your search
@@ -301,9 +301,49 @@ function newStrategyPart () {
|
||||
}
|
||||
break
|
||||
case 'Phase': {
|
||||
thisObject.payload.parentNode = attachToNode
|
||||
thisObject.payload.chainParent = attachToNode
|
||||
thisObject.payload.parentNode.phases.push(thisObject.payload.node)
|
||||
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': {
|
||||
@@ -623,3 +663,4 @@ function newStrategyPart () {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+80
-45
@@ -378,19 +378,29 @@ function newWorkspace () {
|
||||
|
||||
function deleteStrategy (node) {
|
||||
let payload = node.payload
|
||||
for (let j = 0; j < payload.parentNode.strategies.length; j++) {
|
||||
let strategy = payload.parentNode.strategies[j]
|
||||
if (strategy.id === node.id) {
|
||||
deleteEvent(strategy.entryPoint)
|
||||
deleteEvent(strategy.exitPoint)
|
||||
deleteEvent(strategy.sellPoint)
|
||||
deleteManagedItem(strategy.stopLoss)
|
||||
deleteManagedItem(strategy.buyOrder)
|
||||
destroyPart(strategy)
|
||||
payload.parentNode.strategies.splice(j, 1)
|
||||
cleanNode(strategy)
|
||||
return
|
||||
if (payload.parentNode !== undefined) {
|
||||
for (let j = 0; j < payload.parentNode.strategies.length; j++) {
|
||||
let strategy = payload.parentNode.strategies[j]
|
||||
if (strategy.id === node.id) {
|
||||
deleteEvent(strategy.entryPoint)
|
||||
deleteEvent(strategy.exitPoint)
|
||||
deleteEvent(strategy.sellPoint)
|
||||
deleteManagedItem(strategy.stopLoss)
|
||||
deleteManagedItem(strategy.buyOrder)
|
||||
destroyPart(strategy)
|
||||
payload.parentNode.strategies.splice(j, 1)
|
||||
cleanNode(strategy)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
deleteEvent(node.entryPoint)
|
||||
deleteEvent(node.exitPoint)
|
||||
deleteEvent(node.sellPoint)
|
||||
deleteManagedItem(node.stopLoss)
|
||||
deleteManagedItem(node.buyOrder)
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -412,55 +422,80 @@ function newWorkspace () {
|
||||
|
||||
function deletePhase (node) {
|
||||
let payload = node.payload
|
||||
for (let k = 0; k < payload.parentNode.phases.length; k++) {
|
||||
let phase = payload.parentNode.phases[k]
|
||||
if (phase.id === node.id) {
|
||||
while (phase.situations.length > 0) {
|
||||
let situation = phase.situations[0]
|
||||
deleteSituation(situation)
|
||||
}
|
||||
phase.situations = []
|
||||
if (payload.parentNode !== undefined) {
|
||||
for (let k = 0; k < payload.parentNode.phases.length; k++) {
|
||||
let phase = payload.parentNode.phases[k]
|
||||
if (phase.id === node.id) {
|
||||
while (phase.situations.length > 0) {
|
||||
let situation = phase.situations[0]
|
||||
deleteSituation(situation)
|
||||
}
|
||||
phase.situations = []
|
||||
/* Before deleting this phase we need to give its chainParent to the next phase down the chain */
|
||||
if (k < payload.parentNode.phases.length - 1) {
|
||||
payload.parentNode.phases[k + 1].payload.chainParent = payload.chainParent
|
||||
}
|
||||
if (k < payload.parentNode.phases.length - 1) {
|
||||
payload.parentNode.phases[k + 1].payload.chainParent = payload.chainParent
|
||||
}
|
||||
/* Continue destroying this phase */
|
||||
destroyPart(phase)
|
||||
payload.parentNode.phases.splice(k, 1)
|
||||
cleanNode(phase)
|
||||
return
|
||||
destroyPart(phase)
|
||||
payload.parentNode.phases.splice(k, 1)
|
||||
cleanNode(phase)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
while (node.situations.length > 0) {
|
||||
let situation = node.situations[0]
|
||||
deleteSituation(situation)
|
||||
}
|
||||
node.situations = []
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
function deleteSituation (node) {
|
||||
let payload = node.payload
|
||||
for (let j = 0; j < payload.parentNode.situations.length; j++) {
|
||||
let situation = payload.parentNode.situations[j]
|
||||
if (situation.id === node.id) {
|
||||
while (situation.conditions.length > 0) {
|
||||
let condition = situation.conditions[0]
|
||||
deleteCondition(condition)
|
||||
if (payload.parentNode !== undefined) {
|
||||
for (let j = 0; j < payload.parentNode.situations.length; j++) {
|
||||
let situation = payload.parentNode.situations[j]
|
||||
if (situation.id === node.id) {
|
||||
while (situation.conditions.length > 0) {
|
||||
let condition = situation.conditions[0]
|
||||
deleteCondition(condition)
|
||||
}
|
||||
situation.conditions = []
|
||||
destroyPart(situation)
|
||||
payload.parentNode.situations.splice(j, 1)
|
||||
cleanNode(situation)
|
||||
return
|
||||
}
|
||||
situation.conditions = []
|
||||
destroyPart(situation)
|
||||
payload.parentNode.situations.splice(j, 1)
|
||||
cleanNode(situation)
|
||||
return
|
||||
}
|
||||
} else {
|
||||
while (node.conditions.length > 0) {
|
||||
let condition = node.conditions[0]
|
||||
deleteCondition(condition)
|
||||
}
|
||||
node.conditions = []
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
function deleteCondition (node) {
|
||||
let payload = node.payload
|
||||
for (let i = 0; i < payload.parentNode.conditions.length; i++) {
|
||||
let condition = payload.parentNode.conditions[i]
|
||||
if (condition.id === node.id) {
|
||||
destroyPart(node)
|
||||
payload.parentNode.conditions.splice(i, 1)
|
||||
cleanNode(condition)
|
||||
return
|
||||
if (payload.parentNode !== undefined) {
|
||||
for (let i = 0; i < payload.parentNode.conditions.length; i++) {
|
||||
let condition = payload.parentNode.conditions[i]
|
||||
if (condition.id === node.id) {
|
||||
destroyPart(node)
|
||||
payload.parentNode.conditions.splice(i, 1)
|
||||
cleanNode(condition)
|
||||
return
|
||||
}
|
||||
}
|
||||
} else {
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user