Skip to content

Commit 65f1f96

Browse files
committed
feature: clone unit with new flowchartId
1 parent 7b2782c commit 65f1f96

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/units/base.js

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
import lodash from "lodash";
2-
31
import { NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity } from "@exabyte-io/code.js/dist/entity";
42
import { getUUID } from "@exabyte-io/code.js/dist/utils";
3+
import lodash from "lodash";
4+
55
import { UNIT_STATUSES } from "../enums";
66

77
export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSettingsContextAndRenderHashedInMemoryEntity {
@@ -47,8 +47,10 @@ export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSet
4747
}
4848

4949
get lastStatusUpdate() {
50-
const statusTrack = this.prop("statusTrack", []).filter(s => (s.repetition || 0) === this.repetition);
51-
const sortedStatusTrack = lodash.sortBy(statusTrack || [], x => x.trackedAt);
50+
const statusTrack = this.prop("statusTrack", []).filter(
51+
(s) => (s.repetition || 0) === this.repetition,
52+
);
53+
const sortedStatusTrack = lodash.sortBy(statusTrack || [], (x) => x.trackedAt);
5254
return sortedStatusTrack[sortedStatusTrack.length - 1];
5355
}
5456

@@ -61,7 +63,7 @@ export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSet
6163
}
6264

6365
getHashObject() {
64-
return { ...this.hashObjectFromRuntimeItems, type: this.type }
66+
return { ...this.hashObjectFromRuntimeItems, type: this.type };
6567
}
6668

6769
/**
@@ -71,7 +73,14 @@ export class BaseUnit extends NamedDefaultableRepetitionRuntimeItemsImportantSet
7173
* @returns Boolean
7274
*/
7375
isInStatus(status) {
74-
return (this.status === status);
76+
return this.status === status;
7577
}
7678

79+
clone(extraContext) {
80+
const flowchartIDOverrideConfigAsExtraContext = {
81+
flowchartId: BaseUnit.defaultFlowchartId(),
82+
...extraContext,
83+
};
84+
return super.clone(flowchartIDOverrideConfigAsExtraContext);
85+
}
7786
}

0 commit comments

Comments
 (0)