@abi-software/flatmapvuer 1.6.1 → 1.6.2-beta.1

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/flatmapvuer",
3
- "version": "1.6.1",
3
+ "version": "1.6.2-beta.1",
4
4
  "license": "Apache-2.0",
5
5
  "files": [
6
6
  "dist/*",
@@ -43,8 +43,8 @@
43
43
  "./src/*": "./src/*"
44
44
  },
45
45
  "dependencies": {
46
- "@abi-software/flatmap-viewer": "^3.2.6",
47
- "@abi-software/map-utilities": "^1.2.1",
46
+ "@abi-software/flatmap-viewer": "^3.2.8",
47
+ "@abi-software/map-utilities": "^1.2.2-beta.1",
48
48
  "@abi-software/sparc-annotation": "0.3.2",
49
49
  "@abi-software/svg-sprite": "^1.0.1",
50
50
  "@element-plus/icons-vue": "^2.3.1",
@@ -152,7 +152,6 @@ Please use `const` to assign meaningful names to them...
152
152
  class: '.maplibregl-canvas',
153
153
  }"
154
154
  :toolbarOptions="toolbarOptions"
155
- :drawnType="drawnType"
156
155
  :activeDrawTool="activeDrawTool"
157
156
  :activeDrawMode="activeDrawMode"
158
157
  :newlyDrawnEntry="drawnCreatedEvent"
@@ -260,7 +259,7 @@ Please use `const` to assign meaningful names to them...
260
259
  <div
261
260
  class="pathway-location"
262
261
  :class="{ open: drawerOpen, close: !drawerOpen }"
263
- v-show="!disableUI"
262
+ v-show="!disableUI && requiresDrawer"
264
263
  >
265
264
  <div
266
265
  class="pathway-container"
@@ -270,27 +269,27 @@ Please use `const` to assign meaningful names to them...
270
269
  >
271
270
  <svg-legends v-if="!isFC" class="svg-legends-container" />
272
271
  <template v-if="showStarInLegend">
273
- <el-popover
274
- content="Location of the featured dataset"
275
- placement="right"
276
- :teleported="true"
277
- trigger="manual"
278
- width="max-content"
279
- :offset="-10"
280
- popper-class="flatmap-popper flatmap-teleport-popper"
281
- :visible="hoverVisibilities[9].value"
282
- ref="featuredMarkerPopover"
283
- >
284
- <template #reference>
285
- <div
286
- v-popover:featuredMarkerPopover
287
- class="yellow-star-legend"
288
- v-html="yellowstar"
289
- @mouseover="showTooltip(9)"
290
- @mouseout="hideTooltip(9)"
291
- ></div>
292
- </template>
293
- </el-popover>
272
+ <el-popover
273
+ content="Location of the featured dataset"
274
+ placement="right"
275
+ :teleported="true"
276
+ trigger="manual"
277
+ width="max-content"
278
+ :offset="-10"
279
+ popper-class="flatmap-popper flatmap-teleport-popper"
280
+ :visible="hoverVisibilities[9].value"
281
+ ref="featuredMarkerPopover"
282
+ >
283
+ <template #reference>
284
+ <div
285
+ v-popover:featuredMarkerPopover
286
+ class="yellow-star-legend"
287
+ v-html="yellowstar"
288
+ @mouseover="showTooltip(9)"
289
+ @mouseout="hideTooltip(9)"
290
+ ></div>
291
+ </template>
292
+ </el-popover>
294
293
  </template>
295
294
  <!-- The line below places the yellowstar svg on the left, and the text "Featured markers on the right" with css so they are both centered in the div -->
296
295
  <el-popover
@@ -454,44 +453,22 @@ Please use `const` to assign meaningful names to them...
454
453
  </template>
455
454
  </div>
456
455
  <el-row class="viewing-mode-description">
457
- {{ viewingModes[viewingMode] }}
456
+ {{ modeDescription }}
458
457
  </el-row>
459
458
  </el-row>
460
459
  <template v-if="viewingMode === 'Annotation' && userInformation">
461
- <el-row class="backgroundText">Drawn By*</el-row>
462
- <el-row class="backgroundControl">
463
- <el-select
464
- :teleported="false"
465
- v-model="drawnType"
466
- placeholder="Select"
467
- class="select-box"
468
- popper-class="flatmap_dropdown"
469
- @change="setDrawnType"
470
- >
471
- <el-option
472
- v-for="item in drawnTypes"
473
- :key="item"
474
- :label="item"
475
- :value="item"
476
- >
477
- <el-row>
478
- <el-col :span="12">{{ item }}</el-col>
479
- </el-row>
480
- </el-option>
481
- </el-select>
482
- </el-row>
483
- <el-row class="backgroundText">Annotated By*</el-row>
460
+ <el-row class="backgroundText">Annotations From</el-row>
484
461
  <el-row class="backgroundControl">
485
462
  <el-select
486
463
  :teleported="false"
487
- v-model="annotatedType"
464
+ v-model="annotationFrom"
488
465
  placeholder="Select"
489
466
  class="select-box"
490
467
  popper-class="flatmap_dropdown"
491
- @change="setAnnotatedType"
468
+ @change="setAnnotationFrom"
492
469
  >
493
470
  <el-option
494
- v-for="item in annotatedTypes"
471
+ v-for="item in annotatedSource"
495
472
  :key="item"
496
473
  :label="item"
497
474
  :value="item"
@@ -773,6 +750,7 @@ export default {
773
750
  if (this.annotationSidebar) this.$emit("annotation-close")
774
751
  this.closeTooltip()
775
752
  this.annotationEventCallback({}, { type: 'aborted' })
753
+ this.initialiseDrawing()
776
754
  },
777
755
  /**
778
756
  * @public
@@ -885,8 +863,7 @@ export default {
885
863
  }
886
864
  this.doubleClickedFeature = false
887
865
  }
888
- }
889
- if (this.activeDrawMode === 'Delete') {
866
+ } else if (this.activeDrawMode === 'Delete') {
890
867
  this.changeAnnotationDrawMode({
891
868
  mode: 'simple_select',
892
869
  options: { featureIds: [data.feature.feature.id] }
@@ -975,6 +952,7 @@ export default {
975
952
  if (this.annotationEntry.type === 'deleted') {
976
953
  if (this.annotationSidebar) this.$emit("annotation-close")
977
954
  this.closeTooltip()
955
+ // Only delete need, keep the annotation tooltip/sidebar open if created/updated
978
956
  this.annotationEntry = {}
979
957
  }
980
958
  this.addAnnotationFeature()
@@ -1015,12 +993,6 @@ export default {
1015
993
  let drawnFeatures = await this.annotator.drawnFeatures(this.userToken, this.serverURL, annotatedItemIds)
1016
994
  // The annotator has `resource` and `features` fields
1017
995
  if ('resource' in drawnFeatures) drawnFeatures = drawnFeatures.features
1018
- // Use to switch the displayed feature type
1019
- if (this.drawnType !== 'All tools') {
1020
- drawnFeatures = drawnFeatures.filter((feature) => {
1021
- return feature.geometry.type === this.drawnType
1022
- })
1023
- }
1024
996
  return drawnFeatures
1025
997
  },
1026
998
  /**
@@ -1030,21 +1002,19 @@ export default {
1030
1002
  addAnnotationFeature: async function () {
1031
1003
  if (this.mapImp) {
1032
1004
  if (!this.featureAnnotationSubmitted) this.clearAnnotationFeature()
1033
- if (this.drawnType !== 'None') {
1034
- if (!this.featureAnnotationSubmitted) this.loading = true
1035
- const userId = this.annotatedType === 'Anyone' ?
1036
- undefined : this.userInformation.orcid ?
1037
- this.userInformation.orcid : '0000-0000-0000-0000'
1038
- const participated = this.annotatedType === 'Anyone' ?
1039
- undefined : this.annotatedType === 'Me' ?
1040
- true : false
1041
- const drawnFeatures = await this.fetchDrawnFeatures(userId, participated)
1042
- this.existDrawnFeatures = drawnFeatures
1043
- this.loading = false
1044
- if (!this.featureAnnotationSubmitted) {
1045
- for (const feature of drawnFeatures) {
1046
- this.mapImp.addAnnotationFeature(feature)
1047
- }
1005
+ if (!this.featureAnnotationSubmitted) this.loading = true
1006
+ const userId = this.annotationFrom === 'Anyone' ?
1007
+ undefined : this.userInformation.orcid ?
1008
+ this.userInformation.orcid : '0000-0000-0000-0000'
1009
+ const participated = this.annotationFrom === 'Anyone' ?
1010
+ undefined : this.annotationFrom === 'Me' ?
1011
+ true : false
1012
+ const drawnFeatures = await this.fetchDrawnFeatures(userId, participated)
1013
+ this.existDrawnFeatures = drawnFeatures
1014
+ this.loading = false
1015
+ if (!this.featureAnnotationSubmitted) {
1016
+ for (const feature of drawnFeatures) {
1017
+ this.mapImp.addAnnotationFeature(feature)
1048
1018
  }
1049
1019
  }
1050
1020
  }
@@ -1062,26 +1032,13 @@ export default {
1062
1032
  this.$el.querySelector('.maplibregl-ctrl-group').style.display = 'none'
1063
1033
  }
1064
1034
  },
1065
- /**
1066
- * @public
1067
- * Function to switch the type of annotation.
1068
- * @arg {Boolean} `flag`
1069
- */
1070
- setDrawnType: function (flag) {
1071
- this.drawnType = flag
1072
- if (this.mapImp) {
1073
- this.manualAbortedOnClose()
1074
- this.addAnnotationFeature()
1075
- this.initialiseDrawing()
1076
- }
1077
- },
1078
1035
  /**
1079
1036
  * @public
1080
1037
  * Function to switch the type of person who annotated.
1081
1038
  * @arg {Boolean} `flag`
1082
1039
  */
1083
- setAnnotatedType: function (flag) {
1084
- this.annotatedType = flag
1040
+ setAnnotationFrom: function (flag) {
1041
+ this.annotationFrom = flag
1085
1042
  if (this.mapImp) {
1086
1043
  this.manualAbortedOnClose()
1087
1044
  this.addAnnotationFeature()
@@ -1589,7 +1546,7 @@ export default {
1589
1546
  this.annotationEntry = {}
1590
1547
  } else if (data.type === 'modeChanged') {
1591
1548
  if (data.feature.mode === 'direct_select') this.doubleClickedFeature = true
1592
- if (this.annotationSidebar && data.feature.mode === 'simple_select') {
1549
+ if (this.annotationSidebar && data.feature.mode === 'simple_select' && this.activeDrawMode === 'Deleted') {
1593
1550
  this.annotationEventCallback({}, { type: 'aborted' })
1594
1551
  }
1595
1552
  } else if (data.type === 'selectionChanged') {
@@ -1624,6 +1581,7 @@ export default {
1624
1581
  if (data.type === 'created') this.drawnCreatedEvent = payload
1625
1582
  else this.checkAndCreatePopups(payload)
1626
1583
  }
1584
+ if (data.type === 'updated') this.previousEditEvent = data
1627
1585
  if (data.type === 'deleted') this.previousDeletedEvent = data
1628
1586
  else this.previousDeletedEvent = {}
1629
1587
  },
@@ -1711,6 +1669,14 @@ export default {
1711
1669
  !this.activeDrawTool
1712
1670
  ) {
1713
1671
  this.checkAndCreatePopups(payload)
1672
+ if (this.annotationSidebar && this.previousEditEvent.type === 'updated') {
1673
+ this.annotationEntry = {
1674
+ ...this.previousEditEvent,
1675
+ resourceId: this.serverURL
1676
+ }
1677
+ this.annotationEventCallback({}, { type: 'aborted' })
1678
+ }
1679
+ this.previousEditEvent = {}
1714
1680
  }
1715
1681
  this.$emit('resource-selected', payload)
1716
1682
  } else {
@@ -1870,12 +1836,8 @@ export default {
1870
1836
  if (data.feature.featureId && data.feature.models) {
1871
1837
  this.displayTooltip(data.feature.models)
1872
1838
  } else if (data.feature.feature) {
1873
- // in drawing or edit/delete mode is on or has connectivity
1874
- if (
1875
- this.activeDrawTool ||
1876
- this.activeDrawMode ||
1877
- Object.keys(this.connectionEntry).length > 0
1878
- ) {
1839
+ // in drawing or edit/delete mode is on or valid drawn
1840
+ if (this.activeDrawTool || this.activeDrawMode || this.isValidDrawnCreated) {
1879
1841
  this.featureAnnotationSubmitted = false
1880
1842
  this.annotationEntry.featureId = data.feature.feature.id
1881
1843
  if (this.activeDrawTool) {
@@ -2042,7 +2004,11 @@ export default {
2042
2004
  isPathwayContainer(parentElement) ||
2043
2005
  isPathwayContainer(nextElementSibling)
2044
2006
  ) {
2045
- this.drawerOpen = true;
2007
+ if (this.requiresDrawer) {
2008
+ this.drawerOpen = true;
2009
+ } else {
2010
+ this.helpModeActiveIndex += 1;
2011
+ }
2046
2012
  }
2047
2013
  } else {
2048
2014
  // skip the unavailable tooltips
@@ -2174,8 +2140,7 @@ export default {
2174
2140
  !this.disableUI && (
2175
2141
  (
2176
2142
  this.viewingMode === 'Annotation' &&
2177
- !this.annotationSidebar &&
2178
- this.userInformation
2143
+ !this.annotationSidebar
2179
2144
  ) ||
2180
2145
  (
2181
2146
  this.viewingMode === 'Exploration' &&
@@ -2189,7 +2154,6 @@ export default {
2189
2154
  this.mapImp.showPopup(featureId, this.$refs.tooltip.$el, options);
2190
2155
  this.popUpCssHacks();
2191
2156
  });
2192
-
2193
2157
  }
2194
2158
  },
2195
2159
  hasTooltipEntry: function () {
@@ -2483,7 +2447,7 @@ export default {
2483
2447
  }
2484
2448
  }
2485
2449
 
2486
- let promise1 = this.mapManager.loadMap(
2450
+ let promise1 = this.mapManagerRef.loadMap(
2487
2451
  identifier,
2488
2452
  this.$refs.display,
2489
2453
  this.eventCallback(),
@@ -2568,7 +2532,6 @@ export default {
2568
2532
  this.addResizeButtonToMinimap()
2569
2533
  this.loading = false
2570
2534
  this.computePathControlsMaximumHeight()
2571
- this.drawerOpen = true;
2572
2535
  this.mapResize()
2573
2536
  this.handleMapClick();
2574
2537
  this.setInitMapState();
@@ -2831,6 +2794,14 @@ export default {
2831
2794
  type: Object,
2832
2795
  default: undefined,
2833
2796
  },
2797
+ /**
2798
+ * Flatmap's Map Manager to use as single Map Manager
2799
+ * if the FlatmapVuer is loaded from MultiFlatmapVuer.
2800
+ */
2801
+ mapManager: {
2802
+ type: Object,
2803
+ default: undefined,
2804
+ },
2834
2805
  /**
2835
2806
  * Specify the endpoint of the flatmap server.
2836
2807
  */
@@ -2878,7 +2849,7 @@ export default {
2878
2849
  data: function () {
2879
2850
  return {
2880
2851
  sensor: null,
2881
- mapManager: undefined,
2852
+ mapManagerRef: undefined,
2882
2853
  flatmapQueries: undefined,
2883
2854
  annotationEntry: {},
2884
2855
  //tooltip display has to be set to false until it is rendered
@@ -2942,12 +2913,10 @@ export default {
2942
2913
  viewingModes: {
2943
2914
  'Exploration': 'Find relevant research and view detail of neural pathways by selecting a pathway to view its connections and data sources',
2944
2915
  'Neuron Connection': 'Discover Neuron connections by selecting a neuron and viewing its associated network connections',
2945
- 'Annotation': 'View internal identifiers of features'
2916
+ 'Annotation': ['View feature annotations', 'Add, comment on and view feature annotations']
2946
2917
  },
2947
- drawnType: 'All tools',
2948
- drawnTypes: ['All tools', 'Point', 'LineString', 'Polygon', 'None'],
2949
- annotatedType: 'Anyone',
2950
- annotatedTypes: ['Anyone', 'Me', 'Others'],
2918
+ annotationFrom: 'Anyone',
2919
+ annotatedSource: ['Anyone', 'Me', 'Others'],
2951
2920
  openMapRef: undefined,
2952
2921
  backgroundIconRef: undefined,
2953
2922
  toolbarOptions: [
@@ -2964,6 +2933,7 @@ export default {
2964
2933
  activeDrawTool: undefined,
2965
2934
  featureAnnotationSubmitted: false,
2966
2935
  drawnCreatedEvent: {},
2936
+ previousEditEvent: {},
2967
2937
  previousDeletedEvent: {},
2968
2938
  connectionEntry: {},
2969
2939
  existDrawnFeatures: [], // Store all exist drawn features
@@ -2998,6 +2968,37 @@ export default {
2998
2968
  isValidDrawnCreated: function () {
2999
2969
  return Object.keys(this.drawnCreatedEvent).length > 0
3000
2970
  },
2971
+ requiresDrawer: function() {
2972
+ if (this.loading) {
2973
+ this.drawerOpen = false
2974
+ return false
2975
+ }
2976
+ if (!this.isFC) {
2977
+ this.drawerOpen = true
2978
+ return true
2979
+ } else {
2980
+ if ((this.systems?.length > 0) ||
2981
+ (this.containsAlert && this.alertOptions) ||
2982
+ (this.pathways?.length > 0) ||
2983
+ (this.taxonConnectivity?.length > 0)
2984
+ ) {
2985
+ this.drawerOpen = true
2986
+ return true
2987
+ }
2988
+ }
2989
+ this.drawerOpen = false
2990
+ return true
2991
+ },
2992
+ modeDescription: function () {
2993
+ let description = this.viewingModes[this.viewingMode]
2994
+ if (this.viewingMode === 'Annotation') {
2995
+ if (this.userInformation) {
2996
+ return description[1]
2997
+ }
2998
+ return description[0]
2999
+ }
3000
+ return description
3001
+ },
3001
3002
  },
3002
3003
  watch: {
3003
3004
  entry: function () {
@@ -3019,7 +3020,7 @@ export default {
3019
3020
  state: {
3020
3021
  handler: function (state, oldVal) {
3021
3022
  if (state !== oldVal) {
3022
- if (this.mapManager) {
3023
+ if (this.mapManagerRef) {
3023
3024
  this.setState(state)
3024
3025
  } else {
3025
3026
  //this component has not been mounted yet
@@ -3088,11 +3089,22 @@ export default {
3088
3089
  }
3089
3090
  }
3090
3091
  },
3092
+ created: function () {
3093
+ if (this.mapManager) {
3094
+ this.mapManagerRef = this.mapManager;
3095
+ } else {
3096
+ this.mapManagerRef = markRaw(new flatmap.MapManager(this.flatmapAPI));
3097
+ /**
3098
+ * The event emitted after a new mapManager is loaded.
3099
+ * This mapManager can be used to create new flatmaps.
3100
+ */
3101
+ this.$emit('mapmanager-loaded', this.mapManagerRef);
3102
+ }
3103
+ },
3091
3104
  mounted: function () {
3092
3105
  this.openMapRef = shallowRef(this.$refs.openMapRef)
3093
3106
  this.backgroundIconRef = shallowRef(this.$refs.backgroundIconRef)
3094
3107
  this.tooltipWait.length = this.hoverVisibilities.length
3095
- this.mapManager = markRaw(new flatmap.MapManager(this.flatmapAPI))
3096
3108
  this.flatmapQueries = markRaw(new FlatmapQueries())
3097
3109
  this.flatmapQueries.initialise(this.flatmapAPI)
3098
3110
  if (this.state) {
@@ -3189,6 +3201,7 @@ export default {
3189
3201
 
3190
3202
  .svg-legends-container {
3191
3203
  width: 70%;
3204
+ min-width:183px;
3192
3205
  height: auto;
3193
3206
  position: relative;
3194
3207
  max-height: 140px;
@@ -83,6 +83,7 @@
83
83
  :displayMinimap="displayMinimap"
84
84
  :showStarInLegend="showStarInLegend"
85
85
  style="height: 100%"
86
+ :mapManager="mapManagerRef"
86
87
  :flatmapAPI="flatmapAPI"
87
88
  :sparcAPI="sparcAPI"
88
89
  />
@@ -124,6 +125,9 @@ export default {
124
125
  Popover,
125
126
  FlatmapVuer,
126
127
  },
128
+ created: function () {
129
+ this.loadMapManager();
130
+ },
127
131
  mounted: function () {
128
132
  this.initialise()
129
133
  EventBus.on('onActionClick', (action) => {
@@ -219,6 +223,23 @@ export default {
219
223
  }
220
224
  })
221
225
  },
226
+ /**
227
+ * Function to load `mapManager` to create flatmap.
228
+ */
229
+ loadMapManager: function () {
230
+ if (!this.mapManagerRef) {
231
+ if (this.mapManager) {
232
+ this.mapManagerRef = this.mapManager;
233
+ } else {
234
+ this.mapManagerRef = markRaw(new flatmap.MapManager(this.flatmapAPI));
235
+ /**
236
+ * The event emitted after a new mapManager is loaded.
237
+ * This mapManager can be used to create new flatmaps.
238
+ */
239
+ this.$emit('mapmanager-loaded', this.mapManagerRef);
240
+ }
241
+ }
242
+ },
222
243
  /**
223
244
  * @public
224
245
  * Function to emit ``resource-selected`` event with provided ``resource``.
@@ -410,12 +431,11 @@ export default {
410
431
  //uuid is in the state but should be checked if it is the latest map
411
432
  //for that taxon
412
433
  return new Promise(() => {
413
- const mapManager = new flatmap.MapManager(this.flatmapAPI)
414
434
  //mapManager.findMap_ is an async function so we need to wrap this with a promise
415
435
  const identifier = { taxon: mapState.entry }
416
436
  if (mapState.biologicalSex)
417
437
  identifier['biologicalSex'] = mapState.biologicalSex
418
- mapManager
438
+ this.mapManagerRef
419
439
  .findMap_(identifier)
420
440
  .then((map) => {
421
441
  if (map.uuid !== mapState.uuid) {
@@ -461,6 +481,9 @@ export default {
461
481
  */
462
482
  setState: function (state) {
463
483
  if (state) {
484
+ // Update undefined mapManagerRef for setState happens before created event
485
+ this.loadMapManager();
486
+
464
487
  //Update state if required
465
488
  this.updateState(state).then((currentState) => {
466
489
  this.initialise().then(() => {
@@ -696,6 +719,14 @@ export default {
696
719
  type: Object,
697
720
  default: undefined,
698
721
  },
722
+ /**
723
+ * Flatmap's Map Manager to use as single Map Manager
724
+ * when the value is provided.
725
+ */
726
+ mapManager: {
727
+ type: Object,
728
+ default: undefined,
729
+ },
699
730
  /**
700
731
  * Specify the endpoint of the flatmap server.
701
732
  */
@@ -739,6 +770,7 @@ export default {
739
770
  requireInitialisation: true,
740
771
  resolveList: markRaw([]),
741
772
  initialised: false,
773
+ mapManagerRef: undefined,
742
774
  }
743
775
  },
744
776
  watch: {