Skip to content

Commit

Permalink
feat: minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
seankwarren committed Jun 15, 2023
1 parent adde08d commit f7b7f35
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/subworkflows/subworkflow.js
Original file line number Diff line number Diff line change
Expand Up @@ -222,8 +222,15 @@ export class Subworkflow extends BaseSubworkflow {
addUnit(unit, targetUnit) {
console.log("adding unit");
const { units } = this;
if (units.length === 0) {
console.log("adding unit to empty subworkflow");
unit.head = true;
this.setUnits([unit]);
return;
}
if (!targetUnit) {
// handle prepending to the first node
console.log(`adding unit to head`);
const oldHead = units.find((u) => u.head === true);
console.log(`new unit: ${unit.flowchartId}`);
oldHead.head = false;
Expand All @@ -237,12 +244,6 @@ export class Subworkflow extends BaseSubworkflow {
console.log("new units list:");
console.log(units);
this.setUnits(units);
return;
}
if (units.length === 0) {
console.log("adding unit to empty subworkflow");
unit.head = true;
this.setUnits([unit]);
} else {
console.log(`adding unit following the unit ${targetUnit}`);
const target = units.find((u) => u.flowchartId === targetUnit); // get the target Unit
Expand Down

0 comments on commit f7b7f35

Please sign in to comment.