@abi-software/mapintegratedvuer 0.7.1-demo.0 → 0.7.2-vue3.0-alpha.0

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.
Files changed (65) hide show
  1. package/LICENSE +201 -201
  2. package/README.md +150 -142
  3. package/assets/gazelle-icons-no-background.css +32 -0
  4. package/assets/styleguide.css +19 -19
  5. package/cypress.config.js +23 -23
  6. package/dist/index.html +17 -17
  7. package/dist/mapintegratedvuer.js +60394 -59859
  8. package/dist/mapintegratedvuer.umd.cjs +515 -907
  9. package/dist/matterport.pdf +0 -0
  10. package/dist/style.css +1 -1
  11. package/dist/test.txt +0 -0
  12. package/package.json +135 -136
  13. package/public/index.html +17 -17
  14. package/public/matterport.pdf +0 -0
  15. package/public/test.txt +0 -0
  16. package/q.json +690 -0
  17. package/reporter-config.json +9 -9
  18. package/src/App.vue +245 -245
  19. package/src/assets/_variables.scss +43 -43
  20. package/src/assets/fonts/mapicon-species.eot +0 -0
  21. package/src/assets/fonts/mapicon-species.ttf +0 -0
  22. package/src/assets/fonts/mapicon-species.woff +0 -0
  23. package/src/assets/header-icon.scss +67 -67
  24. package/src/assets/mapicon-species-style.css +41 -41
  25. package/src/assets/styles.scss +9 -9
  26. package/src/components/ContentBar.vue +376 -376
  27. package/src/components/ContentVuer.vue +217 -217
  28. package/src/components/ContextCard.vue +385 -385
  29. package/src/components/ContextHelp.vue +73 -73
  30. package/src/components/CustomSplitter.vue +151 -151
  31. package/src/components/DatasetHeader.vue +97 -97
  32. package/src/components/DialogToolbarContent.vue +464 -464
  33. package/src/components/EventBus.js +3 -3
  34. package/src/components/FlatmapContextCard.vue +134 -134
  35. package/src/components/MapContent.vue +333 -285
  36. package/src/components/ResizeSensor.vue +47 -47
  37. package/src/components/SearchControls.vue +115 -115
  38. package/src/components/SimulatedData.js +721 -721
  39. package/src/components/SplitDialog.vue +287 -287
  40. package/src/components/SplitFlow.vue +414 -414
  41. package/src/components/index.js +7 -7
  42. package/src/components/markerZoomLevelsHardCoded.js +255 -255
  43. package/src/components/scripts/utilities.js +173 -173
  44. package/src/components/viewers/Flatmap.vue +145 -145
  45. package/src/components/viewers/Iframe.vue +31 -31
  46. package/src/components/viewers/MultiFlatmap.vue +384 -384
  47. package/src/components/viewers/Plot.vue +23 -23
  48. package/src/components/viewers/Scaffold.vue +198 -198
  49. package/src/components/viewers/Simulation.vue +21 -21
  50. package/src/icons/yellowstar.js +1 -1
  51. package/src/main.js +32 -22
  52. package/src/mixins/ContentMixin.js +438 -438
  53. package/src/mixins/DynamicMarkerMixin.js +88 -88
  54. package/src/mixins/RetrieveContextCardMixin.js +82 -0
  55. package/src/mixins/S3Bucket.vue +37 -37
  56. package/src/stores/entries.js +40 -40
  57. package/src/stores/index.js +24 -16
  58. package/src/stores/settings.js +144 -144
  59. package/src/stores/splitFlow.js +523 -523
  60. package/static.json +7 -7
  61. package/tsconfig.json +19 -0
  62. package/vite.config.js +70 -66
  63. package/vite.static-build.js +12 -12
  64. package/vitest.workspace.js +3 -3
  65. package/vuese-generator.js +65 -0
@@ -1,523 +1,523 @@
1
- import { defineStore } from 'pinia';
2
-
3
- /* eslint-disable no-alert, no-console */
4
- const presetLayouts = (view) => {
5
- switch (view) {
6
- case "2horpanel":
7
- return {
8
- "split-1": {content: false, horizontal: true, children: ["pane-1", "pane-2"]},
9
- "pane-1": {content: true, id: 1},
10
- "pane-2": {content: true, id: 2},
11
- };
12
- case "2vertpanel":
13
- return {
14
- "split-1": {content: false, horizontal: false, children: ["pane-1", "pane-2"]},
15
- "pane-1": {content: true, id: 1},
16
- "pane-2": {content: true, id: 2},
17
- }
18
- case "3panel":
19
- return {
20
- "split-1": {content: false, horizontal: false, children: ["pane-1", "split-2"]},
21
- "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3"]},
22
- "pane-1": {content: true, id: 1},
23
- "pane-2": {content: true, id: 2},
24
- "pane-3": {content: true, id: 3},
25
- }
26
- case "4panel":
27
- return {
28
- "split-1": {content: false, horizontal: false, children: ["split-3", "split-2"]},
29
- "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3"]},
30
- "split-3": {content: false, horizontal: true, children: ["pane-1", "pane-4"]},
31
- "pane-1": {content: true, id: 1},
32
- "pane-2": {content: true, id: 2},
33
- "pane-3": {content: true, id: 3},
34
- "pane-4": {content: true, id: 4},
35
- }
36
- case "5panel":
37
- return {
38
- "split-1": {content: false, horizontal: true, children: ["split-3", "split-2"]},
39
- "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3"]},
40
- "split-3": {content: false, horizontal: false, children: ["pane-1","pane-4", "pane-5"]},
41
- "pane-1": {content: true, id: 1},
42
- "pane-2": {content: true, id: 2},
43
- "pane-3": {content: true, id: 3},
44
- "pane-4": {content: true, id: 4},
45
- "pane-5": {content: true, id: 5},
46
- }
47
- case "6panel":
48
- return {
49
- "split-1": {content: false, horizontal: true, children: ["split-3", "split-2"]},
50
- "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3", "pane-5"]},
51
- "split-3": {content: false, horizontal: false, children: ["pane-1","pane-4", "pane-6"]},
52
- "pane-1": {content: true, id: 1},
53
- "pane-2": {content: true, id: 2},
54
- "pane-3": {content: true, id: 3},
55
- "pane-4": {content: true, id: 4},
56
- "pane-5": {content: true, id: 5},
57
- "pane-6": {content: true, id: 6},
58
- }
59
- case "6panelVertical":
60
- return {
61
- "split-1": {content: false, horizontal: false, children: ["split-3", "split-2"]},
62
- "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3", "pane-5"]},
63
- "split-3": {content: false, horizontal: true, children: ["pane-1","pane-4", "pane-6"]},
64
- "pane-1": {content: true, id: 1},
65
- "pane-2": {content: true, id: 2},
66
- "pane-3": {content: true, id: 3},
67
- "pane-4": {content: true, id: 4},
68
- "pane-5": {content: true, id: 5},
69
- "pane-6": {content: true, id: 6},
70
- }
71
- case "singlepanel":
72
- default:
73
- return {
74
- "split-1": {content: false, horizontal: false, children: ["pane-1"]},
75
- "pane-1": {content: true, id: 1},
76
- }
77
- }
78
- }
79
-
80
- //A method to assign unused entry to pane with duplicated id
81
- const autoAssignEntryIdsToPane = (entries, layout) => {
82
- const assignedIds = [];
83
- const invalidIdKeys = [];
84
- for (const [key, value] of Object.entries(layout)) {
85
- if (value.content) {
86
- if (assignedIds.includes(value.id)) {
87
- //id has got an assigned pane, cache it and find one
88
- //later
89
- invalidIdKeys.push(key);
90
- } else {
91
- assignedIds.push(value.id);
92
- }
93
- }
94
- }
95
- invalidIdKeys.forEach((key) => {
96
- let done = false;
97
- for (let i = 0; i < entries.length && !done; i++) {
98
- if (!(assignedIds.includes(entries[i].id))) {
99
- layout[key].id = entries[i].id;
100
- assignedIds.push(entries.id);
101
- done = true;
102
- }
103
- }
104
- });
105
- }
106
-
107
- const extractPaneInfo = (layout) => {
108
- const panes = {};
109
- for (const [key, value] of Object.entries(layout)) {
110
- if (value.content) {
111
- panes[key] = value;
112
- }
113
- }
114
- return panes;
115
- }
116
-
117
- const newLayoutWithOrigInfo = (original, activeView) => {
118
- const panes = extractPaneInfo(original);
119
- const customLayout = presetLayouts(activeView);
120
- for (const [key, value] of Object.entries(panes)) {
121
- customLayout[key] = value;
122
- }
123
- return customLayout;
124
- }
125
-
126
- const findKeyWithId = (layout, id) => {
127
- return Object.keys(layout).find(key => layout[key]["id"] === id);
128
- }
129
-
130
- export const useSplitFlowStore = defineStore('splitFlow', {
131
- state: () => {
132
- return {
133
- activeView: "singlepanel",
134
- viewIcons: [
135
- { icon: "singlepanel", name: "Single view", min: 1 },
136
- { icon: "2horpanel", name: "Horizontal split", min: 2 },
137
- { icon: "2vertpanel", name: "Vertical split", min: 2 },
138
- { icon: "3panel", name: "Three panes", min: 3 },
139
- { icon: "4panel", name: "Four panes", min: 4 },
140
- { icon: "5panel", name: "Five panes", min: 5 },
141
- { icon: "6panel", name: "Six (horizontal)", min: 6 },
142
- { icon: "6panelVertical", name: "Six (vertical)", min: 6 },
143
- //{ icon: "customise", name: "Customise", min: 2 }
144
- ],
145
- customLayout: {
146
- "split-1": {content: false, horizontal: false, children: ["pane-1"]},
147
- "pane-1": {content: true, id: 1},
148
- /*
149
- Example layout
150
-
151
- "split-1": {content: false, horizontal: true, children: ["split-2", "pane-1"]},
152
- "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3"]},
153
- "pane-1": {content: true, id: 1},
154
- "pane-2": {content: true, id: 2},
155
- "pane-3": {content: true, id: 3},
156
- */
157
- },
158
- splitters: { "first": 50, "second": 50, "third": 50 },
159
- globalCallback: false,
160
- syncMode: false,
161
- }
162
- },
163
- getters: {
164
- getPaneNameById: (state) => (id) => {
165
- return findKeyWithId(state.customLayout, id);
166
- },
167
- getState: (state) => () => {
168
- return {
169
- activeView: state.activeView,
170
- splitters: state.splitters,
171
- globalCallback: state.globalCallback,
172
- customLayout: state.customLayout,
173
- syncMode: state.syncMode,
174
- };
175
- },
176
- },
177
- actions: {
178
- assignOrSwapPaneWithIds(payload) {
179
- let sourceKey = findKeyWithId(this.customLayout, payload.source);
180
- let targetKey = findKeyWithId(this.customLayout, payload.target);
181
- // Check if it is on syncMode
182
- if (this.syncMode && (!(targetKey || sourceKey))) {
183
- //exit syncMod if the two panel in sync mode are not swapping
184
- this.syncMode = false;
185
- this.globalCallback = false;
186
- }
187
- if (targetKey) {
188
- this.customLayout[targetKey].id = payload.source;
189
- }
190
- if (sourceKey) {
191
- this.customLayout[sourceKey].id = payload.target;
192
- }
193
- },
194
- toggleGlobalCallback(flag) {
195
- this.globalCallback = flag;
196
- },
197
- updateActiveView(payload) {
198
- //Deactivate sync mode if current or future view
199
- //is not in 2 split panels/
200
- if (this.syncMode) {
201
- const view1 = this.viewIcons.find(
202
- view => this.activeView === view.icon);
203
- const view2 = this.viewIcons.find(
204
- view => payload.view === view.icon);
205
- if (!(view1.min == 2 && view2.min == 2)) {
206
- this.syncMode = false;
207
- this.globalCallback = false;
208
- }
209
- }
210
- this.activeView = payload.view;
211
- const customLayout = newLayoutWithOrigInfo(
212
- this.customLayout, this.activeView);
213
- autoAssignEntryIdsToPane(payload.entries, customLayout);
214
- for (const [key, value] of Object.entries(customLayout)) {
215
- this.customLayout[key] = value;
216
- }
217
- },
218
- setSplitter(payload) {
219
- if (this.splitters[payload.name])
220
- this.splitters[payload.name] = payload.value;
221
- },
222
- setState(newState) {
223
- if (newState) {
224
- let customLayout = undefined;
225
- if (newState.activeView) {
226
- this.activeView = newState.activeView;
227
- }
228
- if (newState.customLayout) {
229
- customLayout = newState.customLayout;
230
- } else {
231
- customLayout = presetLayouts(this.activeView);
232
- console.log(newState, customLayout)
233
- if (newState.slotInfo) {
234
- for (let i = 0; i < newState.slotInfo.length; i++) {
235
- switch (newState.slotInfo[i].name) {
236
- case "first": {
237
- customLayout["pane-1"].id = newState.slotInfo[i].id;
238
- } break;
239
- case "second": {
240
- if("pane-2" in customLayout)
241
- customLayout["pane-2"].id = newState.slotInfo[i].id;
242
- } break;
243
- case "thrid": {
244
- if("pane-3" in customLayout)
245
- customLayout["pane-3"].id = newState.slotInfo[i].id;
246
- } break;
247
- case "fourth": {
248
- if("pane-4" in customLayout)
249
- customLayout["pane-4"].id = newState.slotInfo[i].id;
250
- } break;
251
- case "fifth": {
252
- if("pane-5" in customLayout)
253
- customLayout["pane-5"].id = newState.slotInfo[i].id;
254
- } break;
255
- case "sixth": {
256
- if("pane-6" in customLayout)
257
- customLayout["pane-6"].id = newState.slotInfo[i].id;
258
- } break;
259
- default:
260
- break;
261
- }
262
- }
263
- }
264
- }
265
- for (const [key, value] of Object.entries(customLayout)) {
266
- this.customLayout[key] = value;
267
- }
268
- if (newState.globalCallback) {
269
- this.globalCallback = newState.globalCallback;
270
- }
271
- for (const [key, value] of Object.entries(newState.splitters)) {
272
- this.splitters[key] = value;
273
- }
274
- if (newState.syncMode) {
275
- this.syncMode = newState.syncMode;
276
- }
277
- }
278
- },
279
- setIdToPrimaryPane(id) {
280
- const currentKey = findKeyWithId(this.customLayout, id);
281
- const firstPaneId = this.customLayout["pane-1"].id;
282
- this.customLayout["pane-1"].id = id;
283
- if (currentKey) {
284
- this.customLayout[currentKey].id = firstPaneId;
285
- }
286
- },
287
- setSyncMode(payload) {
288
- if (payload) {
289
- //Force the second slot to be the new viewer in payload and change the
290
- //view to the payload's layout
291
- //this.customLayout["pane-2"].id = id;
292
- if (payload.flag === true) {
293
- this.activeView = payload.layout;
294
- //Extract pane info form original state and copy to the new layout
295
- const customLayout = newLayoutWithOrigInfo(
296
- this.customLayout, this.activeView);
297
- const originalKey = findKeyWithId(customLayout, 1);
298
- const firstPaneId = customLayout["pane-1"].id;
299
- if (originalKey !== "pane-1") {
300
- customLayout["pane-1"].id = firstPaneId;
301
- }
302
- customLayout["pane-1"].id = 1;
303
- customLayout["pane-2"].id = payload.newId;
304
- for (const [key, value] of Object.entries(customLayout)) {
305
- this.customLayout[key] = value;
306
- }
307
- this.syncMode = true;
308
- this.globalCallback = true;
309
- } else {
310
- this.activeView = "singlepanel";
311
- const customLayout = newLayoutWithOrigInfo(
312
- this.customLayout, this.activeView);
313
- for (const [key, value] of Object.entries(customLayout)) {
314
- this.customLayout[key] = value;
315
- }
316
- this.syncMode = false;
317
- this.globalCallback = false;
318
- }
319
- }
320
- },
321
- closeSlot(payload) {
322
- if (payload) {
323
- this.syncMode = false;
324
- this.globalCallback = false;
325
- let availableId = 0;
326
- //Primary id cannot be changed
327
- if (payload.id === 1) {
328
- availableId = 1;
329
- } else if (payload.entries) {
330
- for (let i = 0; i < payload.entries.length &&
331
- availableId == 0; i++) {
332
- //Find the first entry not currently in use
333
- if (findKeyWithId(payload.entries[i].id) === undefined) {
334
- availableId = payload.entries[i].id;
335
- }
336
- }
337
- }
338
- //Switch the view
339
- if (this.activeView !== "customise") {
340
- //closePaneWithStandardLayout
341
- const pView = this.activeView;
342
- switch (this.activeView) {
343
- case "2horpanel":
344
- case "2vertpanel":
345
- this.activeView = "singlepanel";
346
- break;
347
- case "3panel":
348
- this.activeView = "2vertpanel";
349
- break;
350
- case "4panel":
351
- this.activeView = "3panel";
352
- break;
353
- case "5panel":
354
- this.activeView = "4panel";
355
- break;
356
- case "6panelVertical":
357
- case "6panel":
358
- this.activeView = "5panel";
359
- break;
360
- default:
361
- break;
362
- }
363
- const customLayout = newLayoutWithOrigInfo(
364
- this.customLayout, this.activeView);
365
- const key = findKeyWithId(customLayout, payload.id);
366
-
367
- // The following move the entry id to the appropriate slot
368
- // and remove the target id
369
- switch (key) {
370
- case "pane-1": {
371
- switch (pView) {
372
- case "2horpanel":
373
- case "2vertpanel": {
374
- customLayout["pane-1"].id = customLayout["pane-2"].id;
375
- customLayout["pane-2"].id = availableId;
376
- } break;
377
- case "3panel": {
378
- customLayout["pane-1"].id = customLayout["pane-2"].id;
379
- customLayout["pane-2"].id = customLayout["pane-3"].id;
380
- customLayout["pane-3"].id = availableId;
381
- } break;
382
- case "4panel": {
383
- customLayout["pane-1"].id = customLayout["pane-2"].id;
384
- customLayout["pane-2"].id = customLayout["pane-3"].id;
385
- customLayout["pane-3"].id = customLayout["pane-4"].id;
386
- customLayout["pane-4"].id = availableId;
387
- } break;
388
- case "5panel": {
389
- customLayout["pane-1"].id = customLayout["pane-2"].id;
390
- customLayout["pane-2"].id = customLayout["pane-3"].id;
391
- customLayout["pane-3"].id = customLayout["pane-4"].id;
392
- customLayout["pane-4"].id = customLayout["pane-5"].id;
393
- customLayout["pane-5"].id = availableId;
394
- } break;
395
- case "6panelVertical":
396
- case "6panel":
397
- {
398
- customLayout["pane-1"].id = customLayout["pane-2"].id;
399
- customLayout["pane-2"].id = customLayout["pane-3"].id;
400
- customLayout["pane-3"].id = customLayout["pane-4"].id;
401
- customLayout["pane-4"].id = customLayout["pane-5"].id;
402
- customLayout["pane-5"].id = customLayout["pane-6"].id;
403
- customLayout["pane-6"].id = availableId;
404
- } break;
405
- default:
406
- break;
407
- }
408
- } break;
409
- case "pane-2": {
410
- switch (pView) {
411
- case "2horpanel":
412
- case "2vertpanel": {
413
- customLayout["pane-2"].id = availableId;
414
- } break;
415
- case "3panel": {
416
- customLayout["pane-2"].id = customLayout["pane-3"].id;
417
- customLayout["pane-3"].id = availableId;
418
- } break;
419
- case "4panel": {
420
- customLayout["pane-2"].id = customLayout["pane-3"].id;
421
- customLayout["pane-3"].id = customLayout["pane-4"].id;
422
- customLayout["pane-4"].id = availableId;
423
- } break;
424
- case "5panel": {
425
- customLayout["pane-2"].id = customLayout["pane-3"].id;
426
- customLayout["pane-3"].id = customLayout["pane-4"].id;
427
- customLayout["pane-4"].id = customLayout["pane-5"].id;
428
- customLayout["pane-5"].id = availableId;
429
- } break;
430
- case "6panelVertical":
431
- case "6panel":
432
- {
433
- customLayout["pane-2"].id = customLayout["pane-3"].id;
434
- customLayout["pane-3"].id = customLayout["pane-4"].id;
435
- customLayout["pane-4"].id = customLayout["pane-5"].id;
436
- customLayout["pane-5"].id = customLayout["pane-6"].id;
437
- customLayout["pane-6"].id = availableId;
438
- } break;
439
- default:
440
- break;
441
- }
442
- } break;
443
- case "pane-3": {
444
- switch (pView) {
445
- case "3panel": {
446
- customLayout["pane-3"].id = availableId;
447
- } break;
448
- case "4panel": {
449
- customLayout["pane-3"].id = customLayout["pane-4"].id;
450
- customLayout["pane-4"].id = availableId;
451
- } break;
452
- case "5panel": {
453
- customLayout["pane-3"].id = customLayout["pane-4"].id;
454
- customLayout["pane-4"].id = customLayout["pane-5"].id;
455
- customLayout["pane-5"].id = availableId;
456
- } break;
457
- case "6panelVertical":
458
- case "6panel":
459
- {
460
- customLayout["pane-3"].id = customLayout["pane-4"].id;
461
- customLayout["pane-4"].id = customLayout["pane-5"].id;
462
- customLayout["pane-5"].id = customLayout["pane-6"].id;
463
- customLayout["pane-6"].id = availableId;
464
- } break;
465
- default:
466
- break;
467
- }
468
- } break;
469
- case "pane-4": {
470
- switch (pView) {
471
- case "4panel": {
472
- customLayout["pane-4"].id = availableId;
473
- } break;
474
- case "5panel": {
475
- customLayout["pane-4"].id = customLayout["pane-5"].id;
476
- customLayout["pane-5"].id = availableId;
477
- } break;
478
- case "6panelVertical":
479
- case "6panel": {
480
- customLayout["pane-4"].id = customLayout["pane-5"].id;
481
- customLayout["pane-5"].id = customLayout["pane-6"].id;
482
- customLayout["pane-6"].id = availableId;
483
- } break;
484
- default:
485
- break;
486
- }
487
- } break;
488
- case "pane-5": {
489
- switch (pView) {
490
- case "5panel": {
491
- customLayout["pane-5"].id = availableId;
492
- } break;
493
- case "6panelVertical":
494
- case "6panel": {
495
- customLayout["pane-5"].id = customLayout["pane-6"].id;
496
- customLayout["pane-6"].id = availableId;
497
- } break;
498
- default:
499
- break;
500
- }
501
- } break;
502
- case "pane-6" : {
503
- switch (pView) {
504
- case "6panelVertical":
505
- case "6panel":
506
- {
507
- customLayout["pane-6"].id = availableId;
508
- } break;
509
- default:
510
- break;
511
- }
512
- } break;
513
- default:
514
- break;
515
- }
516
- for (const [key, value] of Object.entries(customLayout)) {
517
- this.customLayout[key] = value;
518
- }
519
- }
520
- }
521
- }
522
- }
523
- });
1
+ import { defineStore } from 'pinia';
2
+
3
+ /* eslint-disable no-alert, no-console */
4
+ const presetLayouts = (view) => {
5
+ switch (view) {
6
+ case "2horpanel":
7
+ return {
8
+ "split-1": {content: false, horizontal: true, children: ["pane-1", "pane-2"]},
9
+ "pane-1": {content: true, id: 1},
10
+ "pane-2": {content: true, id: 2},
11
+ };
12
+ case "2vertpanel":
13
+ return {
14
+ "split-1": {content: false, horizontal: false, children: ["pane-1", "pane-2"]},
15
+ "pane-1": {content: true, id: 1},
16
+ "pane-2": {content: true, id: 2},
17
+ }
18
+ case "3panel":
19
+ return {
20
+ "split-1": {content: false, horizontal: false, children: ["pane-1", "split-2"]},
21
+ "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3"]},
22
+ "pane-1": {content: true, id: 1},
23
+ "pane-2": {content: true, id: 2},
24
+ "pane-3": {content: true, id: 3},
25
+ }
26
+ case "4panel":
27
+ return {
28
+ "split-1": {content: false, horizontal: false, children: ["split-3", "split-2"]},
29
+ "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3"]},
30
+ "split-3": {content: false, horizontal: true, children: ["pane-1", "pane-4"]},
31
+ "pane-1": {content: true, id: 1},
32
+ "pane-2": {content: true, id: 2},
33
+ "pane-3": {content: true, id: 3},
34
+ "pane-4": {content: true, id: 4},
35
+ }
36
+ case "5panel":
37
+ return {
38
+ "split-1": {content: false, horizontal: true, children: ["split-3", "split-2"]},
39
+ "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3"]},
40
+ "split-3": {content: false, horizontal: false, children: ["pane-1","pane-4", "pane-5"]},
41
+ "pane-1": {content: true, id: 1},
42
+ "pane-2": {content: true, id: 2},
43
+ "pane-3": {content: true, id: 3},
44
+ "pane-4": {content: true, id: 4},
45
+ "pane-5": {content: true, id: 5},
46
+ }
47
+ case "6panel":
48
+ return {
49
+ "split-1": {content: false, horizontal: true, children: ["split-3", "split-2"]},
50
+ "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3", "pane-5"]},
51
+ "split-3": {content: false, horizontal: false, children: ["pane-1","pane-4", "pane-6"]},
52
+ "pane-1": {content: true, id: 1},
53
+ "pane-2": {content: true, id: 2},
54
+ "pane-3": {content: true, id: 3},
55
+ "pane-4": {content: true, id: 4},
56
+ "pane-5": {content: true, id: 5},
57
+ "pane-6": {content: true, id: 6},
58
+ }
59
+ case "6panelVertical":
60
+ return {
61
+ "split-1": {content: false, horizontal: false, children: ["split-3", "split-2"]},
62
+ "split-2": {content: false, horizontal: true, children: ["pane-2", "pane-3", "pane-5"]},
63
+ "split-3": {content: false, horizontal: true, children: ["pane-1","pane-4", "pane-6"]},
64
+ "pane-1": {content: true, id: 1},
65
+ "pane-2": {content: true, id: 2},
66
+ "pane-3": {content: true, id: 3},
67
+ "pane-4": {content: true, id: 4},
68
+ "pane-5": {content: true, id: 5},
69
+ "pane-6": {content: true, id: 6},
70
+ }
71
+ case "singlepanel":
72
+ default:
73
+ return {
74
+ "split-1": {content: false, horizontal: false, children: ["pane-1"]},
75
+ "pane-1": {content: true, id: 1},
76
+ }
77
+ }
78
+ }
79
+
80
+ //A method to assign unused entry to pane with duplicated id
81
+ const autoAssignEntryIdsToPane = (entries, layout) => {
82
+ const assignedIds = [];
83
+ const invalidIdKeys = [];
84
+ for (const [key, value] of Object.entries(layout)) {
85
+ if (value.content) {
86
+ if (assignedIds.includes(value.id)) {
87
+ //id has got an assigned pane, cache it and find one
88
+ //later
89
+ invalidIdKeys.push(key);
90
+ } else {
91
+ assignedIds.push(value.id);
92
+ }
93
+ }
94
+ }
95
+ invalidIdKeys.forEach((key) => {
96
+ let done = false;
97
+ for (let i = 0; i < entries.length && !done; i++) {
98
+ if (!(assignedIds.includes(entries[i].id))) {
99
+ layout[key].id = entries[i].id;
100
+ assignedIds.push(entries.id);
101
+ done = true;
102
+ }
103
+ }
104
+ });
105
+ }
106
+
107
+ const extractPaneInfo = (layout) => {
108
+ const panes = {};
109
+ for (const [key, value] of Object.entries(layout)) {
110
+ if (value.content) {
111
+ panes[key] = value;
112
+ }
113
+ }
114
+ return panes;
115
+ }
116
+
117
+ const newLayoutWithOrigInfo = (original, activeView) => {
118
+ const panes = extractPaneInfo(original);
119
+ const customLayout = presetLayouts(activeView);
120
+ for (const [key, value] of Object.entries(panes)) {
121
+ customLayout[key] = value;
122
+ }
123
+ return customLayout;
124
+ }
125
+
126
+ const findKeyWithId = (layout, id) => {
127
+ return Object.keys(layout).find(key => layout[key]["id"] === id);
128
+ }
129
+
130
+ export const useSplitFlowStore = defineStore('splitFlow', {
131
+ state: () => {
132
+ return {
133
+ activeView: "singlepanel",
134
+ viewIcons: [
135
+ { icon: "singlepanel", name: "Single view", min: 1 },
136
+ { icon: "2horpanel", name: "Horizontal split", min: 2 },
137
+ { icon: "2vertpanel", name: "Vertical split", min: 2 },
138
+ { icon: "3panel", name: "Three panes", min: 3 },
139
+ { icon: "4panel", name: "Four panes", min: 4 },
140
+ { icon: "5panel", name: "Five panes", min: 5 },
141
+ { icon: "6panel", name: "Six (horizontal)", min: 6 },
142
+ { icon: "6panelVertical", name: "Six (vertical)", min: 6 },
143
+ //{ icon: "customise", name: "Customise", min: 2 }
144
+ ],
145
+ customLayout: {
146
+ "split-1": {content: false, horizontal: false, children: ["pane-1"]},
147
+ "pane-1": {content: true, id: 1},
148
+ /*
149
+ Example layout
150
+
151
+ "split-1": {content: false, horizontal: true, children: ["split-2", "pane-1"]},
152
+ "split-2": {content: false, horizontal: false, children: ["pane-2", "pane-3"]},
153
+ "pane-1": {content: true, id: 1},
154
+ "pane-2": {content: true, id: 2},
155
+ "pane-3": {content: true, id: 3},
156
+ */
157
+ },
158
+ splitters: { "first": 50, "second": 50, "third": 50 },
159
+ globalCallback: false,
160
+ syncMode: false,
161
+ }
162
+ },
163
+ getters: {
164
+ getPaneNameById: (state) => (id) => {
165
+ return findKeyWithId(state.customLayout, id);
166
+ },
167
+ getState: (state) => () => {
168
+ return {
169
+ activeView: state.activeView,
170
+ splitters: state.splitters,
171
+ globalCallback: state.globalCallback,
172
+ customLayout: state.customLayout,
173
+ syncMode: state.syncMode,
174
+ };
175
+ },
176
+ },
177
+ actions: {
178
+ assignOrSwapPaneWithIds(payload) {
179
+ let sourceKey = findKeyWithId(this.customLayout, payload.source);
180
+ let targetKey = findKeyWithId(this.customLayout, payload.target);
181
+ // Check if it is on syncMode
182
+ if (this.syncMode && (!(targetKey || sourceKey))) {
183
+ //exit syncMod if the two panel in sync mode are not swapping
184
+ this.syncMode = false;
185
+ this.globalCallback = false;
186
+ }
187
+ if (targetKey) {
188
+ this.customLayout[targetKey].id = payload.source;
189
+ }
190
+ if (sourceKey) {
191
+ this.customLayout[sourceKey].id = payload.target;
192
+ }
193
+ },
194
+ toggleGlobalCallback(flag) {
195
+ this.globalCallback = flag;
196
+ },
197
+ updateActiveView(payload) {
198
+ //Deactivate sync mode if current or future view
199
+ //is not in 2 split panels/
200
+ if (this.syncMode) {
201
+ const view1 = this.viewIcons.find(
202
+ view => this.activeView === view.icon);
203
+ const view2 = this.viewIcons.find(
204
+ view => payload.view === view.icon);
205
+ if (!(view1.min == 2 && view2.min == 2)) {
206
+ this.syncMode = false;
207
+ this.globalCallback = false;
208
+ }
209
+ }
210
+ this.activeView = payload.view;
211
+ const customLayout = newLayoutWithOrigInfo(
212
+ this.customLayout, this.activeView);
213
+ autoAssignEntryIdsToPane(payload.entries, customLayout);
214
+ for (const [key, value] of Object.entries(customLayout)) {
215
+ this.customLayout[key] = value;
216
+ }
217
+ },
218
+ setSplitter(payload) {
219
+ if (this.splitters[payload.name])
220
+ this.splitters[payload.name] = payload.value;
221
+ },
222
+ setState(newState) {
223
+ if (newState) {
224
+ let customLayout = undefined;
225
+ if (newState.activeView) {
226
+ this.activeView = newState.activeView;
227
+ }
228
+ if (newState.customLayout) {
229
+ customLayout = newState.customLayout;
230
+ } else {
231
+ customLayout = presetLayouts(this.activeView);
232
+ console.log(newState, customLayout)
233
+ if (newState.slotInfo) {
234
+ for (let i = 0; i < newState.slotInfo.length; i++) {
235
+ switch (newState.slotInfo[i].name) {
236
+ case "first": {
237
+ customLayout["pane-1"].id = newState.slotInfo[i].id;
238
+ } break;
239
+ case "second": {
240
+ if("pane-2" in customLayout)
241
+ customLayout["pane-2"].id = newState.slotInfo[i].id;
242
+ } break;
243
+ case "thrid": {
244
+ if("pane-3" in customLayout)
245
+ customLayout["pane-3"].id = newState.slotInfo[i].id;
246
+ } break;
247
+ case "fourth": {
248
+ if("pane-4" in customLayout)
249
+ customLayout["pane-4"].id = newState.slotInfo[i].id;
250
+ } break;
251
+ case "fifth": {
252
+ if("pane-5" in customLayout)
253
+ customLayout["pane-5"].id = newState.slotInfo[i].id;
254
+ } break;
255
+ case "sixth": {
256
+ if("pane-6" in customLayout)
257
+ customLayout["pane-6"].id = newState.slotInfo[i].id;
258
+ } break;
259
+ default:
260
+ break;
261
+ }
262
+ }
263
+ }
264
+ }
265
+ for (const [key, value] of Object.entries(customLayout)) {
266
+ this.customLayout[key] = value;
267
+ }
268
+ if (newState.globalCallback) {
269
+ this.globalCallback = newState.globalCallback;
270
+ }
271
+ for (const [key, value] of Object.entries(newState.splitters)) {
272
+ this.splitters[key] = value;
273
+ }
274
+ if (newState.syncMode) {
275
+ this.syncMode = newState.syncMode;
276
+ }
277
+ }
278
+ },
279
+ setIdToPrimaryPane(id) {
280
+ const currentKey = findKeyWithId(this.customLayout, id);
281
+ const firstPaneId = this.customLayout["pane-1"].id;
282
+ this.customLayout["pane-1"].id = id;
283
+ if (currentKey) {
284
+ this.customLayout[currentKey].id = firstPaneId;
285
+ }
286
+ },
287
+ setSyncMode(payload) {
288
+ if (payload) {
289
+ //Force the second slot to be the new viewer in payload and change the
290
+ //view to the payload's layout
291
+ //this.customLayout["pane-2"].id = id;
292
+ if (payload.flag === true) {
293
+ this.activeView = payload.layout;
294
+ //Extract pane info form original state and copy to the new layout
295
+ const customLayout = newLayoutWithOrigInfo(
296
+ this.customLayout, this.activeView);
297
+ const originalKey = findKeyWithId(customLayout, 1);
298
+ const firstPaneId = customLayout["pane-1"].id;
299
+ if (originalKey !== "pane-1") {
300
+ customLayout["pane-1"].id = firstPaneId;
301
+ }
302
+ customLayout["pane-1"].id = 1;
303
+ customLayout["pane-2"].id = payload.newId;
304
+ for (const [key, value] of Object.entries(customLayout)) {
305
+ this.customLayout[key] = value;
306
+ }
307
+ this.syncMode = true;
308
+ this.globalCallback = true;
309
+ } else {
310
+ this.activeView = "singlepanel";
311
+ const customLayout = newLayoutWithOrigInfo(
312
+ this.customLayout, this.activeView);
313
+ for (const [key, value] of Object.entries(customLayout)) {
314
+ this.customLayout[key] = value;
315
+ }
316
+ this.syncMode = false;
317
+ this.globalCallback = false;
318
+ }
319
+ }
320
+ },
321
+ closeSlot(payload) {
322
+ if (payload) {
323
+ this.syncMode = false;
324
+ this.globalCallback = false;
325
+ let availableId = 0;
326
+ //Primary id cannot be changed
327
+ if (payload.id === 1) {
328
+ availableId = 1;
329
+ } else if (payload.entries) {
330
+ for (let i = 0; i < payload.entries.length &&
331
+ availableId == 0; i++) {
332
+ //Find the first entry not currently in use
333
+ if (findKeyWithId(payload.entries[i].id) === undefined) {
334
+ availableId = payload.entries[i].id;
335
+ }
336
+ }
337
+ }
338
+ //Switch the view
339
+ if (this.activeView !== "customise") {
340
+ //closePaneWithStandardLayout
341
+ const pView = this.activeView;
342
+ switch (this.activeView) {
343
+ case "2horpanel":
344
+ case "2vertpanel":
345
+ this.activeView = "singlepanel";
346
+ break;
347
+ case "3panel":
348
+ this.activeView = "2vertpanel";
349
+ break;
350
+ case "4panel":
351
+ this.activeView = "3panel";
352
+ break;
353
+ case "5panel":
354
+ this.activeView = "4panel";
355
+ break;
356
+ case "6panelVertical":
357
+ case "6panel":
358
+ this.activeView = "5panel";
359
+ break;
360
+ default:
361
+ break;
362
+ }
363
+ const customLayout = newLayoutWithOrigInfo(
364
+ this.customLayout, this.activeView);
365
+ const key = findKeyWithId(customLayout, payload.id);
366
+
367
+ // The following move the entry id to the appropriate slot
368
+ // and remove the target id
369
+ switch (key) {
370
+ case "pane-1": {
371
+ switch (pView) {
372
+ case "2horpanel":
373
+ case "2vertpanel": {
374
+ customLayout["pane-1"].id = customLayout["pane-2"].id;
375
+ customLayout["pane-2"].id = availableId;
376
+ } break;
377
+ case "3panel": {
378
+ customLayout["pane-1"].id = customLayout["pane-2"].id;
379
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
380
+ customLayout["pane-3"].id = availableId;
381
+ } break;
382
+ case "4panel": {
383
+ customLayout["pane-1"].id = customLayout["pane-2"].id;
384
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
385
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
386
+ customLayout["pane-4"].id = availableId;
387
+ } break;
388
+ case "5panel": {
389
+ customLayout["pane-1"].id = customLayout["pane-2"].id;
390
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
391
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
392
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
393
+ customLayout["pane-5"].id = availableId;
394
+ } break;
395
+ case "6panelVertical":
396
+ case "6panel":
397
+ {
398
+ customLayout["pane-1"].id = customLayout["pane-2"].id;
399
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
400
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
401
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
402
+ customLayout["pane-5"].id = customLayout["pane-6"].id;
403
+ customLayout["pane-6"].id = availableId;
404
+ } break;
405
+ default:
406
+ break;
407
+ }
408
+ } break;
409
+ case "pane-2": {
410
+ switch (pView) {
411
+ case "2horpanel":
412
+ case "2vertpanel": {
413
+ customLayout["pane-2"].id = availableId;
414
+ } break;
415
+ case "3panel": {
416
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
417
+ customLayout["pane-3"].id = availableId;
418
+ } break;
419
+ case "4panel": {
420
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
421
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
422
+ customLayout["pane-4"].id = availableId;
423
+ } break;
424
+ case "5panel": {
425
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
426
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
427
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
428
+ customLayout["pane-5"].id = availableId;
429
+ } break;
430
+ case "6panelVertical":
431
+ case "6panel":
432
+ {
433
+ customLayout["pane-2"].id = customLayout["pane-3"].id;
434
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
435
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
436
+ customLayout["pane-5"].id = customLayout["pane-6"].id;
437
+ customLayout["pane-6"].id = availableId;
438
+ } break;
439
+ default:
440
+ break;
441
+ }
442
+ } break;
443
+ case "pane-3": {
444
+ switch (pView) {
445
+ case "3panel": {
446
+ customLayout["pane-3"].id = availableId;
447
+ } break;
448
+ case "4panel": {
449
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
450
+ customLayout["pane-4"].id = availableId;
451
+ } break;
452
+ case "5panel": {
453
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
454
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
455
+ customLayout["pane-5"].id = availableId;
456
+ } break;
457
+ case "6panelVertical":
458
+ case "6panel":
459
+ {
460
+ customLayout["pane-3"].id = customLayout["pane-4"].id;
461
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
462
+ customLayout["pane-5"].id = customLayout["pane-6"].id;
463
+ customLayout["pane-6"].id = availableId;
464
+ } break;
465
+ default:
466
+ break;
467
+ }
468
+ } break;
469
+ case "pane-4": {
470
+ switch (pView) {
471
+ case "4panel": {
472
+ customLayout["pane-4"].id = availableId;
473
+ } break;
474
+ case "5panel": {
475
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
476
+ customLayout["pane-5"].id = availableId;
477
+ } break;
478
+ case "6panelVertical":
479
+ case "6panel": {
480
+ customLayout["pane-4"].id = customLayout["pane-5"].id;
481
+ customLayout["pane-5"].id = customLayout["pane-6"].id;
482
+ customLayout["pane-6"].id = availableId;
483
+ } break;
484
+ default:
485
+ break;
486
+ }
487
+ } break;
488
+ case "pane-5": {
489
+ switch (pView) {
490
+ case "5panel": {
491
+ customLayout["pane-5"].id = availableId;
492
+ } break;
493
+ case "6panelVertical":
494
+ case "6panel": {
495
+ customLayout["pane-5"].id = customLayout["pane-6"].id;
496
+ customLayout["pane-6"].id = availableId;
497
+ } break;
498
+ default:
499
+ break;
500
+ }
501
+ } break;
502
+ case "pane-6" : {
503
+ switch (pView) {
504
+ case "6panelVertical":
505
+ case "6panel":
506
+ {
507
+ customLayout["pane-6"].id = availableId;
508
+ } break;
509
+ default:
510
+ break;
511
+ }
512
+ } break;
513
+ default:
514
+ break;
515
+ }
516
+ for (const [key, value] of Object.entries(customLayout)) {
517
+ this.customLayout[key] = value;
518
+ }
519
+ }
520
+ }
521
+ }
522
+ }
523
+ });