eventmodeler 0.2.6 → 0.2.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -71,6 +71,18 @@ function findActorForScreen(model, screen) {
|
|
|
71
71
|
}
|
|
72
72
|
return undefined;
|
|
73
73
|
}
|
|
74
|
+
// Find which chapter contains a slice (based on horizontal center)
|
|
75
|
+
function findChapterForSlice(model, slice) {
|
|
76
|
+
const sliceCenterX = slice.position.x + slice.size.width / 2;
|
|
77
|
+
for (const chapter of model.chapters.values()) {
|
|
78
|
+
const chapterLeft = chapter.position.x;
|
|
79
|
+
const chapterRight = chapter.position.x + chapter.size.width;
|
|
80
|
+
if (sliceCenterX >= chapterLeft && sliceCenterX <= chapterRight) {
|
|
81
|
+
return chapter;
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
return null;
|
|
85
|
+
}
|
|
74
86
|
// Convert Field to JSON-friendly format
|
|
75
87
|
function fieldToJson(field) {
|
|
76
88
|
const result = {
|
|
@@ -330,13 +342,16 @@ export function codegenSlice(model, sliceName) {
|
|
|
330
342
|
const internalFlows = getInternalFlows(model, componentIds);
|
|
331
343
|
// 7. Get scenarios for this slice
|
|
332
344
|
const scenarios = [...model.scenarios.values()].filter(s => s.sliceId === slice.id);
|
|
333
|
-
// 8.
|
|
345
|
+
// 8. Find which chapter this slice belongs to
|
|
346
|
+
const chapter = findChapterForSlice(model, slice);
|
|
347
|
+
// 9. Build output
|
|
334
348
|
const output = {
|
|
335
349
|
sliceType,
|
|
336
350
|
slice: {
|
|
337
351
|
id: slice.id,
|
|
338
352
|
name: slice.name,
|
|
339
353
|
},
|
|
354
|
+
...(chapter && { chapter: { id: chapter.id, name: chapter.name } }),
|
|
340
355
|
elements: {
|
|
341
356
|
readModels: components.readModels.map(rm => ({
|
|
342
357
|
id: rm.id,
|
|
@@ -379,6 +394,6 @@ export function codegenSlice(model, sliceName) {
|
|
|
379
394
|
internalFlows,
|
|
380
395
|
scenarios: formatScenarios(model, scenarios),
|
|
381
396
|
};
|
|
382
|
-
//
|
|
397
|
+
// 10. Output JSON
|
|
383
398
|
outputJson(output);
|
|
384
399
|
}
|