@abi-software/mapintegratedvuer 1.9.0 → 1.9.2

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/mapintegratedvuer",
3
- "version": "1.9.0",
3
+ "version": "1.9.2",
4
4
  "license": "Apache-2.0",
5
5
  "scripts": {
6
6
  "serve": "vite --host --force",
@@ -50,8 +50,8 @@
50
50
  "*.js"
51
51
  ],
52
52
  "dependencies": {
53
- "@abi-software/flatmapvuer": "^1.9.0",
54
- "@abi-software/map-side-bar": "^2.8.0",
53
+ "@abi-software/flatmapvuer": "^1.9.2",
54
+ "@abi-software/map-side-bar": "^2.8.2",
55
55
  "@abi-software/map-utilities": "^1.5.0",
56
56
  "@abi-software/plotvuer": "1.0.4",
57
57
  "@abi-software/scaffoldvuer": "^1.9.0",
@@ -48,7 +48,10 @@ export default {
48
48
  },
49
49
  data: function() {
50
50
  return {
51
- styles: { }
51
+ styles: { },
52
+ query: "",
53
+ filter: [],
54
+ target: [],
52
55
  }
53
56
  },
54
57
  methods: {
@@ -213,35 +216,111 @@ export default {
213
216
 
214
217
  // mix connectivites of available maps
215
218
  if (uuids.length) {
216
- uuids.forEach((_uuid) => {
217
- if (_uuid in this.connectivitiesStore.globalConnectivities) {
218
- const connectivity = this.connectivitiesStore.globalConnectivities[_uuid];
219
- combinedConnectivities.push(...connectivity);
220
- }
221
- });
222
-
223
- const uniqueConnectivities = Array.from(
224
- new Map(combinedConnectivities.map((item) => [item.id, item])).values()
225
- );
219
+ this.connectivitiesStore.updateActiveConnectivityKeys(uuids);
220
+ const uniqueConnectivities = this.connectivitiesStore.getUniqueConnectivitiesByKeys;
226
221
 
227
222
  EventBus.emit("connectivity-knowledge", {
228
223
  data: uniqueConnectivities
229
224
  });
230
-
231
- if (uuids.length === 1) {
232
- this.connectivitiesStore.updateActiveConnectivityKey(uuid);
233
- }
234
225
  } else {
235
226
  if (sckanVersion) {
236
227
  EventBus.emit("connectivity-knowledge", {
237
228
  data: this.connectivitiesStore.globalConnectivities[sckanVersion]
238
229
  });
239
- this.connectivitiesStore.updateActiveConnectivityKey(sckanVersion);
230
+ this.connectivitiesStore.updateActiveConnectivityKeys([sckanVersion]);
240
231
  } else {
241
232
  console.warn(`There has no connectivity to show!`);
242
233
  }
243
234
  }
244
235
  },
236
+ getSearchedId: function (flatmap, term) {
237
+ let ids = [];
238
+ const searchResult = flatmap.mapImp.search(term);
239
+ const featureIds = searchResult.__featureIds || searchResult.featureIds;
240
+ featureIds.forEach((id) => {
241
+ const annotation = flatmap.mapImp.annotation(id);
242
+ if (
243
+ annotation.label?.toLowerCase().includes(term.toLowerCase()) &&
244
+ annotation.models && !ids.includes(annotation.models)
245
+ ) {
246
+ ids.push(annotation.models);
247
+ }
248
+ });
249
+ return ids;
250
+ },
251
+ connectivityQueryFilter: async function (data) {
252
+ const activeContents = this.getActiveContents();
253
+ let searchResults = [];
254
+ let searchState = '';
255
+
256
+ for (const activeContent of activeContents) {
257
+ const viewer = activeContent.$refs.viewer;
258
+
259
+ if (viewer) {
260
+ const multiflatmap = viewer.$refs.multiflatmap;
261
+ const flatmap = viewer.$refs.flatmap;
262
+ let currentFlatmap = null;
263
+
264
+ if (multiflatmap) {
265
+ const _currentFlatmap = multiflatmap.getCurrentFlatmap();
266
+ if (_currentFlatmap && _currentFlatmap.mapImp) {
267
+ currentFlatmap = _currentFlatmap;
268
+ }
269
+ }
270
+
271
+ if (flatmap && flatmap.mapImp) {
272
+ currentFlatmap = flatmap;
273
+ }
274
+
275
+ const uniqueConnectivities = this.connectivitiesStore.getUniqueConnectivitiesByKeys;
276
+
277
+ if (currentFlatmap && currentFlatmap.$el.checkVisibility()) {
278
+ let payload = {
279
+ state: "default",
280
+ data: [...uniqueConnectivities],
281
+ };
282
+
283
+ if (data) {
284
+ if (data.type === "query-update") {
285
+ if (this.query !== data.value) this.target = [];
286
+ this.query = data.value;
287
+ } else if (data.type === "filter-update") {
288
+ this.filter = data.value;
289
+ }
290
+ }
291
+
292
+ if (this.query) {
293
+ payload.state = "processed";
294
+ let prom1 = [], options = {};
295
+ const searchTerms = this.query.split(",").map((term) => term.trim());
296
+ for (let index = 0; index < searchTerms.length; index++) {
297
+ prom1.push(this.getSearchedId(currentFlatmap, searchTerms[index]));
298
+ }
299
+ const nestedIds = await Promise.all(prom1);
300
+ const ids = [...new Set(nestedIds.flat())];
301
+ let paths = await currentFlatmap.retrieveConnectedPaths(ids, options);
302
+ paths = [...ids, ...paths.filter((path) => !ids.includes(path))];
303
+ let results = uniqueConnectivities.filter((item) => paths.includes(item.id));
304
+ payload.data = results;
305
+ }
306
+
307
+ searchState = payload.state;
308
+ searchResults = [...searchResults, ...payload.data];
309
+ }
310
+ }
311
+ }
312
+
313
+ const uniqueResults = Array.from(
314
+ new Map(searchResults.map((item) => [item.id, item])).values()
315
+ );
316
+
317
+ const connectivitiesPayload = {
318
+ state: searchState,
319
+ data: uniqueResults,
320
+ };
321
+
322
+ EventBus.emit("connectivity-knowledge", connectivitiesPayload);
323
+ },
245
324
  },
246
325
  computed: {
247
326
  ...mapStores(useSplitFlowStore, useConnectivitiesStore),
@@ -299,6 +378,9 @@ export default {
299
378
  EventBus.on('species-layout-connectivity-update', () => {
300
379
  this.onSpeciesLayoutConnectivityUpdate();
301
380
  })
381
+ EventBus.on("connectivity-query-filter", (payload) => {
382
+ this.connectivityQueryFilter(payload);
383
+ });
302
384
  },
303
385
  };
304
386
  </script>
@@ -146,6 +146,7 @@ export default {
146
146
  },
147
147
  methods: {
148
148
  onConnectivityExplorerClicked: function (payload) {
149
+ this.search = payload.id
149
150
  this.onDisplaySearch({ term: payload.id }, false, true);
150
151
  },
151
152
  /**
@@ -374,6 +375,7 @@ export default {
374
375
  this.filterTriggered = false; // reset for next action
375
376
  }
376
377
  } else if (data.id === 2) {
378
+ this.search = '';
377
379
  this.connectivityEntry = [];
378
380
  EventBus.emit("connectivity-query-filter", data);
379
381
  }
@@ -635,7 +637,15 @@ export default {
635
637
  }
636
638
  });
637
639
  EventBus.on('connectivity-info-open', payload => {
638
- this.connectivityEntry = payload;
640
+ if (!this.search || payload.length > 1) {
641
+ this.connectivityEntry = payload;
642
+ } else if (this.search && payload.length === 1) {
643
+ // if search exist, payload should always be an array of one element
644
+ // skip those payload not contain the search
645
+ if (payload[0].featureId[0] === this.search) {
646
+ this.connectivityEntry = payload;
647
+ }
648
+ }
639
649
  // click on the flatmap paths/features directly
640
650
  // or onDisplaySearch is performed
641
651
  if (!this.connectivityExplorerClicked.length) {
@@ -647,12 +657,17 @@ export default {
647
657
  this.onShowConnectivity(this.connectivityHighlight);
648
658
  }
649
659
  if (this.$refs.sideBar) {
650
- this.$refs.sideBar.tabClicked({id: 2, type: 'connectivityExplorer'});
660
+ this.$refs.sideBar.tabClicked({ id: 2, type: 'connectivityExplorer' });
651
661
  this.$refs.sideBar.setDrawerOpen(true);
652
662
  }
653
663
  }
654
664
  this.connectivityExplorerClicked.pop();
655
665
  });
666
+ EventBus.on('connectivity-info-close', payload => {
667
+ if (this.$refs.sideBar) {
668
+ this.$refs.sideBar.resetConnectivitySearch();
669
+ }
670
+ });
656
671
  EventBus.on('connectivity-error', payload => {
657
672
  if (this.$refs.sideBar) {
658
673
  this.$refs.sideBar.updateConnectivityError(payload.data);
@@ -21,6 +21,7 @@
21
21
  :annotationSidebar="annotationSidebar"
22
22
  @connectivity-info-open="onConnectivityInfoOpen"
23
23
  @connectivity-error="onConnectivityError"
24
+ @connectivity-info-close="onConnectivityInfoClose"
24
25
  :connectivityInfoSidebar="connectivityInfoSidebar"
25
26
  :pathControls="true"
26
27
  ref="flatmap"
@@ -74,7 +75,7 @@ export default {
74
75
  * Perform a local search on this contentvuer
75
76
  */
76
77
  search: function (term) {
77
- return this.$refs.flatmap.searchAndShowResult(term);
78
+ return this.$refs.flatmap.searchAndShowResult(term, true);
78
79
  },
79
80
  getFlatmapImp() {
80
81
  return this.$refs.flatmap?.mapImp;
@@ -102,9 +103,11 @@ export default {
102
103
  },
103
104
  flatmapReadyCall: function (flatmap) {
104
105
  let provClone = {id: this.entry.id, prov: this.getFlatmapImp().provenance}; //create clone of provenance and add id
106
+ const flatmapImp = flatmap.mapImp;
105
107
  EventBus.emit("mapImpProv", provClone); // send clone to context card
106
108
  this.$emit("flatmap-provenance-ready", provClone);
107
109
  this.flatmapReadyForMarkerUpdates(flatmap);
110
+ this.loadConnectivityKnowledge(flatmapImp);
108
111
  EventBus.emit("mapLoaded", flatmap);
109
112
  },
110
113
  onPathwaySelectionChanged: function (data) {
@@ -20,6 +20,7 @@
20
20
  :annotationSidebar="annotationSidebar"
21
21
  @connectivity-info-open="onConnectivityInfoOpen"
22
22
  @connectivity-error="onConnectivityError"
23
+ @connectivity-info-close="onConnectivityInfoClose"
23
24
  :connectivityInfoSidebar="connectivityInfoSidebar"
24
25
  ref="multiflatmap"
25
26
  :displayMinimap="true"
@@ -504,14 +505,6 @@ export default {
504
505
  this.cardHoverHighlight();
505
506
  }
506
507
  });
507
- EventBus.on("connectivity-query-filter", (payload) => {
508
- if (this.flatmapReady && this.$refs.multiflatmap) {
509
- const currentFlatmap = this.$refs.multiflatmap.getCurrentFlatmap();
510
- if (currentFlatmap && currentFlatmap.mapImp) {
511
- this.connectivityQueryFilter(currentFlatmap, payload)
512
- }
513
- }
514
- });
515
508
  },
516
509
  };
517
510
  </script>
@@ -556,6 +556,9 @@ export default {
556
556
  onConnectivityError: function (errorInfo) {
557
557
  EventBus.emit('connectivity-error', errorInfo);
558
558
  },
559
+ onConnectivityInfoClose: function () {
560
+ EventBus.emit('connectivity-info-close');
561
+ },
559
562
  loadConnectivityKnowledge: async function (flatmapImp) {
560
563
  const sckanVersion = getKnowledgeSource(flatmapImp);
561
564
  const flatmapQueries = markRaw(new FlatmapQueries());
@@ -594,56 +597,6 @@ export default {
594
597
  // EventBus.emit("connectivity-knowledge", { data: this.connectivityKnowledge[uuid] });
595
598
  EventBus.emit('species-layout-connectivity-update');
596
599
  },
597
- getSearchedId: function (flatmap, term) {
598
- let ids = [];
599
- const searchResult = flatmap.mapImp.search(term);
600
- const featureIds = searchResult.__featureIds || searchResult.featureIds;
601
- featureIds.forEach((id) => {
602
- const annotation = flatmap.mapImp.annotation(id);
603
- if (
604
- annotation.label?.toLowerCase().includes(term.toLowerCase()) &&
605
- annotation.models && !ids.includes(annotation.models)
606
- ) {
607
- ids.push(annotation.models);
608
- }
609
- });
610
- return ids;
611
- },
612
- connectivityQueryFilter: async function (flatmap, data) {
613
- const uuid = flatmap.mapImp.uuid;
614
- // to search from sckan or uuid based on the maps showing on split screens
615
- const activeConnectivityKey = this.connectivitiesStore.activeConnectivityKey || uuid;
616
- // only for those flatmaps that are shown on the split screen
617
- if (flatmap.$el.checkVisibility()) {
618
- let payload = {
619
- state: "default",
620
- data: [...this.connectivityKnowledge[activeConnectivityKey]],
621
- };
622
- if (data) {
623
- if (data.type === "query-update") {
624
- if (this.query !== data.value) this.target = [];
625
- this.query = data.value;
626
- } else if (data.type === "filter-update") {
627
- this.filter = data.value;
628
- }
629
- }
630
- if (this.query) {
631
- payload.state = "processed";
632
- let prom1 = [], options = {};
633
- const searchTerms = this.query.split(",").map((term) => term.trim());
634
- for (let index = 0; index < searchTerms.length; index++) {
635
- prom1.push(this.getSearchedId(flatmap, searchTerms[index]));
636
- }
637
- const nestedIds = await Promise.all(prom1);
638
- const ids = [...new Set(nestedIds.flat())];
639
- let paths = await flatmap.retrieveConnectedPaths(ids, options);
640
- paths = [...ids, ...paths.filter((path) => !ids.includes(path))];
641
- let results = this.connectivityKnowledge[activeConnectivityKey].filter((item) => paths.includes(item.id));
642
- payload.data = results;
643
- }
644
- EventBus.emit("connectivity-knowledge", payload);
645
- }
646
- }
647
600
  },
648
601
  data: function () {
649
602
  return {
@@ -665,8 +618,6 @@ export default {
665
618
  isInHelp: false,
666
619
  mapManager: undefined,
667
620
  connectivityKnowledge: {},
668
- query: "",
669
- filter: [],
670
621
  highlightDelay: undefined
671
622
  };
672
623
  },
@@ -4,18 +4,32 @@ export const useConnectivitiesStore = defineStore('connectivities', {
4
4
  state: () => {
5
5
  return {
6
6
  globalConnectivities: {},
7
- activeConnectivityKey: '',
7
+ activeConnectivityKeys: [],
8
8
  }
9
9
  },
10
10
  getters: {
11
+ getUniqueConnectivitiesByKeys: (state) => {
12
+ let combinedConnectivities = [];
13
+ state.activeConnectivityKeys.forEach((uuid) => {
14
+ if (uuid in state.globalConnectivities) {
15
+ const connectivity = state.globalConnectivities[uuid];
16
+ combinedConnectivities.push(...connectivity);
17
+ }
18
+ });
11
19
 
20
+ const uniqueConnectivities = Array.from(
21
+ new Map(combinedConnectivities.map((item) => [item.id, item])).values()
22
+ );
23
+
24
+ return uniqueConnectivities;
25
+ },
12
26
  },
13
27
  actions: {
14
28
  updateGlobalConnectivities(globalConnectivities) {
15
29
  this.globalConnectivities = globalConnectivities;
16
30
  },
17
- updateActiveConnectivityKey(activeConnectivityKey) {
18
- this.activeConnectivityKey = activeConnectivityKey;
31
+ updateActiveConnectivityKeys(activeConnectivityKeys) {
32
+ this.activeConnectivityKeys = activeConnectivityKeys;
19
33
  },
20
34
  }
21
35
  });