Delete Strategy Implemented
This commit is contained in:
1 parent
632b49ad16
commit
c74d375d20
2 files changed
+51
-13
No files matched your search
@@ -152,18 +152,6 @@ function newStrategyPartConstructor () {
|
||||
currentRadius: 0,
|
||||
angle: -135
|
||||
},
|
||||
{
|
||||
action: 'Delete Strategy',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Delete This Strategy',
|
||||
visible: false,
|
||||
iconPathOn: 'trash',
|
||||
iconPathOff: 'trash',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -40
|
||||
},
|
||||
{
|
||||
action: 'Open Settings',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
@@ -174,7 +162,19 @@ function newStrategyPartConstructor () {
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: 0
|
||||
angle: -40
|
||||
},
|
||||
{
|
||||
action: 'Delete Strategy',
|
||||
actionFunction: payload.onMenuItemClick,
|
||||
label: 'Delete This Strategy',
|
||||
visible: false,
|
||||
iconPathOn: 'trash',
|
||||
iconPathOff: 'trash',
|
||||
rawRadius: 8,
|
||||
targetRadius: 0,
|
||||
currentRadius: 0,
|
||||
angle: -0
|
||||
},
|
||||
{
|
||||
action: 'Download',
|
||||
|
||||
@@ -326,6 +326,10 @@ function newWorkspace () {
|
||||
createPart('Condition', condition.name, condition, situation, situation, 'Condition')
|
||||
}
|
||||
break
|
||||
case 'Delete Strategy': {
|
||||
deleteStrategy(payload.node)
|
||||
break
|
||||
}
|
||||
case 'Delete Phase': {
|
||||
deletePhase(payload.node)
|
||||
break
|
||||
@@ -343,6 +347,40 @@ 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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function deleteEvent (node) {
|
||||
while (node.situations.length > 0) {
|
||||
deleteSituation(node.situations[0])
|
||||
}
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
|
||||
function deleteManagedItem (node) {
|
||||
while (node.phases.length > 0) {
|
||||
deletePhase(node.phases[0])
|
||||
}
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
|
||||
function deletePhase (node) {
|
||||
let payload = node.payload
|
||||
for (let k = 0; k < payload.parentNode.phases.length; k++) {
|
||||
|
||||
Reference in new issue
Block a user