@abi-software/map-side-bar 2.8.3-beta.6 → 2.8.3-beta.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "2.8.3-beta.6",
3
+ "version": "2.8.3-beta.7",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -1,11 +1,7 @@
1
1
  <template>
2
- <el-card
3
- :body-style="bodyStyle"
4
- class="content-card"
5
- @mouseleave="onHoverChanged($event, undefined)"
6
- >
2
+ <el-card :body-style="bodyStyle" class="content-card">
7
3
  <template #header>
8
- <div class="header">
4
+ <div class="header" @mouseleave="hoverChanged(undefined)">
9
5
  <el-input
10
6
  class="search-input"
11
7
  placeholder="Search"
@@ -30,6 +26,10 @@
30
26
  >
31
27
  Reset
32
28
  </el-button>
29
+ <el-radio-group v-model="filterVisibility">
30
+ <el-radio :value="true">Focused</el-radio>
31
+ <el-radio :value="false">Contextual</el-radio>
32
+ </el-radio-group>
33
33
  </div>
34
34
  </template>
35
35
  <SearchFilters
@@ -78,8 +78,8 @@
78
78
  :availableAnatomyFacets="availableAnatomyFacets"
79
79
  :envVars="envVars"
80
80
  :withCloseButton="true"
81
- @show-connectivity="$emit('show-connectivity', $event)"
82
- @show-reference-connectivities="$emit('show-reference-connectivities', $event)"
81
+ @show-connectivity="onShowConnectivity"
82
+ @show-reference-connectivities="onShowReferenceConnectivities"
83
83
  @connectivity-clicked="onConnectivityClicked"
84
84
  @connectivity-hovered="$emit('connectivity-hovered', $event)"
85
85
  @loaded="onConnectivityInfoLoaded(result)"
@@ -175,9 +175,11 @@ export default {
175
175
  display: "flex",
176
176
  },
177
177
  cascaderIsReady: false,
178
- displayConnectivity: false,
178
+ freezeTimeout: undefined,
179
+ freezed: false,
179
180
  initLoading: true,
180
181
  expanded: "",
182
+ filterVisibility: true,
181
183
  expandedData: null,
182
184
  };
183
185
  },
@@ -236,8 +238,29 @@ export default {
236
238
  paginatedResults: function () {
237
239
  this.loadingCards = false;
238
240
  },
241
+ filterVisibility: function (state) {
242
+ this.filterVisibility = state;
243
+ this.$emit('filter-visibility', this.filterVisibility);
244
+ },
239
245
  },
240
246
  methods: {
247
+ freezeHoverChange: function () {
248
+ this.freezed = true;
249
+ if (this.freezeTimeout) {
250
+ clearTimeout(this.freezeTimeout);
251
+ }
252
+ this.freezeTimeout = setTimeout(() => {
253
+ this.freezed = false;
254
+ }, 3000)
255
+ },
256
+ onShowConnectivity: function (data) {
257
+ this.freezeHoverChange();
258
+ this.$emit('show-connectivity', data);
259
+ },
260
+ onShowReferenceConnectivities: function (data) {
261
+ this.freezeHoverChange();
262
+ this.$emit('show-reference-connectivities', data);
263
+ },
241
264
  onConnectivityClicked: function (data) {
242
265
  this.searchInput = data.query;
243
266
  this.filter = data.filter;
@@ -276,15 +299,18 @@ export default {
276
299
  }
277
300
  },
278
301
  hoverChanged: function (data) {
279
- let payload = { tabType: "connectivity" };
280
-
281
- if (data) {
282
- payload = {...payload, ...data};
283
- } else if (this.expandedData) {
284
- payload = {...payload, ...this.expandedData};
302
+ // disable hover changes when show connectivity is clicked
303
+ if (!this.freezed) {
304
+ let payload = { tabType: "connectivity" };
305
+
306
+ if (data) {
307
+ payload = {...payload, ...data};
308
+ } else if (this.expandedData) {
309
+ payload = {...payload, ...this.expandedData};
310
+ }
311
+
312
+ this.$emit("hover-changed", payload);
285
313
  }
286
-
287
- this.$emit("hover-changed", payload);
288
314
  },
289
315
  resetSearch: function () {
290
316
  this.numberOfHits = 0;
@@ -293,7 +319,7 @@ export default {
293
319
  },
294
320
  resetSearchIfNoActiveSearch: function() {
295
321
  const hasValidFacet = this.filter.some(f => f.facet !== "Show all");
296
- if (!this.searchInput && !hasValidFacet) {
322
+ if ((!this.searchInput && !hasValidFacet) || this.numberOfHits === 0) {
297
323
  this.openSearch([], '');
298
324
  }
299
325
  },
@@ -508,6 +534,9 @@ export default {
508
534
  }
509
535
 
510
536
  .header {
537
+ display: flex;
538
+ align-items: center;
539
+
511
540
  .el-button {
512
541
  font-family: inherit;
513
542
 
@@ -515,7 +544,19 @@ export default {
515
544
  &:focus {
516
545
  background: $app-primary-color;
517
546
  box-shadow: -3px 2px 4px #00000040;
518
- color: #fff;
547
+ color: #ffffff;
548
+ }
549
+ }
550
+
551
+ .el-radio-group {
552
+ display: flex;
553
+ flex-direction: column;
554
+ align-items: flex-start;
555
+
556
+ .el-radio {
557
+ color: #ffffff;
558
+ margin-left: 20px;
559
+ height: 20px;
519
560
  }
520
561
  }
521
562
  }
@@ -61,7 +61,20 @@
61
61
  @expand-change="cascadeExpandChange"
62
62
  :show-all-levels="true"
63
63
  popper-class="sidebar-cascader-popper"
64
- />
64
+ >
65
+ <template #default="{ node, data }">
66
+ <el-row>
67
+ <el-col :span="4" v-if="hasLineStyles(data)">
68
+ <div class="path-visual" :style="getLineStyles(data)"></div>
69
+ </el-col>
70
+ <el-col :span="20">
71
+ <div :style="getBackgroundStyles(data)">
72
+ {{ data.label }}
73
+ </div>
74
+ </el-col>
75
+ </el-row>
76
+ </template>
77
+ </el-cascader>
65
78
  <div v-if="showFiltersText" class="filter-default-value">Filters</div>
66
79
  <el-popover
67
80
  title="How do filters work?"
@@ -851,6 +864,26 @@ export default {
851
864
  }
852
865
  return []
853
866
  },
867
+ hasLineStyles: function(item) {
868
+ return 'colour' in item && item.colourStyle === 'line'
869
+ },
870
+ getLineStyles: function (item) {
871
+ if ('colour' in item && item.colourStyle === 'line') {
872
+ if ('dashed' in item && item.dashed === true) {
873
+ const background = `repeating-linear-gradient(90deg,${item.colour},${item.colour} 6px,transparent 0,transparent 9px)`
874
+ return { background }
875
+ } else {
876
+ return { background: item.colour }
877
+ }
878
+ }
879
+ return { display: 'None' }
880
+ },
881
+ getBackgroundStyles: function (item) {
882
+ if ('colour' in item && item.colourStyle === 'background') {
883
+ return { background: item.colour }
884
+ }
885
+ return {}
886
+ },
854
887
  },
855
888
  mounted: function () {
856
889
  this.algoliaClient = markRaw(new AlgoliaClient(
@@ -1080,4 +1113,11 @@ export default {
1080
1113
  border-right-color: transparent !important;
1081
1114
  }
1082
1115
  }
1116
+ .path-visual {
1117
+ margin: 3px 0;
1118
+ height: 3px;
1119
+ width: 25px;
1120
+ margin-right: 5px;
1121
+ display: inline-block;
1122
+ }
1083
1123
  </style>
@@ -51,6 +51,7 @@
51
51
  :connectivityEntry="connectivityEntry"
52
52
  :availableAnatomyFacets="availableAnatomyFacets"
53
53
  :connectivityFilterOptions="filterOptions"
54
+ @filter-visibility="$emit('filter-visibility', $event)"
54
55
  @search-changed="searchChanged(tab.id, $event)"
55
56
  @hover-changed="hoverChanged(tab.id, $event)"
56
57
  @show-connectivity="showConnectivity"
@@ -1,94 +0,0 @@
1
- async function getReferenceConnectivitiesFromStorage(resource) {
2
- const flatmapKnowledgeRaw = sessionStorage.getItem('flatmap-knowledge');
3
-
4
- if (flatmapKnowledgeRaw) {
5
- const flatmapKnowledge = JSON.parse(flatmapKnowledgeRaw);
6
- const dataWithRefs = flatmapKnowledge.filter((x) => x.references && x.references.length);
7
- const foundData = dataWithRefs.filter((x) => x.references.includes(resource));
8
-
9
- if (foundData.length) {
10
- const featureIds = foundData.map((x) => x.id);
11
- return featureIds;
12
- }
13
- }
14
- return [];
15
- }
16
-
17
- async function getReferenceConnectivitiesByAPI(mapImp, resource, flatmapQueries) {
18
- const knowledgeSource = getKnowledgeSource(mapImp);
19
- const sql = `select knowledge from knowledge
20
- where source="${knowledgeSource}" and
21
- knowledge like "%${resource}%" order by source desc`;
22
- console.log(sql)
23
- const response = await flatmapQueries.flatmapQuery(sql);
24
- const mappedData = response.values.map((x) => x[0]);
25
- const parsedData = mappedData.map((x) => JSON.parse(x));
26
- const featureIds = parsedData.map((x) => x.id);
27
- return featureIds;
28
- }
29
-
30
- function getKnowledgeSource(mapImp) {
31
- let mapKnowledgeSource = '';
32
- if (mapImp.provenance?.connectivity) {
33
- const sckanProvenance = mapImp.provenance.connectivity;
34
- if ('knowledge-source' in sckanProvenance) {
35
- mapKnowledgeSource = sckanProvenance['knowledge-source'];
36
- } else if ('npo' in sckanProvenance) {
37
- mapKnowledgeSource = `${sckanProvenance.npo.release}-npo`;
38
- }
39
- }
40
-
41
- return mapKnowledgeSource;
42
- }
43
-
44
- function loadAndStoreKnowledge(mapImp, flatmapQueries) {
45
- const knowledgeSource = getKnowledgeSource(mapImp);
46
- const sql = `select knowledge from knowledge
47
- where source="${knowledgeSource}"
48
- order by source desc`;
49
- const flatmapKnowledge = sessionStorage.getItem('flatmap-knowledge');
50
-
51
- if (!flatmapKnowledge) {
52
- flatmapQueries.flatmapQuery(sql).then((response) => {
53
- const mappedData = response.values.map(x => x[0]);
54
- const parsedData = mappedData.map(x => JSON.parse(x));
55
- sessionStorage.setItem('flatmap-knowledge', JSON.stringify(parsedData));
56
- updateFlatmapKnowledgeCache();
57
- });
58
- }
59
- }
60
-
61
- function updateFlatmapKnowledgeCache() {
62
- const CACHE_LIFETIME = 24 * 60 * 60 * 1000; // One day
63
- const now = new Date();
64
- const expiry = now.getTime() + CACHE_LIFETIME;
65
-
66
- sessionStorage.setItem('flatmap-knowledge-expiry', expiry);
67
- }
68
-
69
- function removeFlatmapKnowledgeCache() {
70
- const keys = [
71
- 'flatmap-knowledge',
72
- 'flatmap-knowledge-expiry',
73
- ];
74
- keys.forEach((key) => {
75
- sessionStorage.removeItem(key);
76
- });
77
- }
78
-
79
- function refreshFlatmapKnowledgeCache() {
80
- const expiry = sessionStorage.getItem('flatmap-knowledge-expiry');
81
- const now = new Date();
82
-
83
- if (now.getTime() > expiry) {
84
- removeFlatmapKnowledgeCache();
85
- }
86
- }
87
-
88
- export {
89
- getReferenceConnectivitiesFromStorage,
90
- getReferenceConnectivitiesByAPI,
91
- loadAndStoreKnowledge,
92
- getKnowledgeSource,
93
- refreshFlatmapKnowledgeCache,
94
- }