@abi-software/map-side-bar 2.8.3-beta.1 → 2.8.3-beta.3

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.1",
3
+ "version": "2.8.3-beta.3",
4
4
  "files": [
5
5
  "dist/*",
6
6
  "src/*",
@@ -5,7 +5,7 @@
5
5
  @mouseleave="hoverChanged(undefined)"
6
6
  >
7
7
  <template #header>
8
- <div class="header">
8
+ <div class="header" @mouseleave="hoverChanged(undefined)">
9
9
  <el-input
10
10
  class="search-input"
11
11
  placeholder="Search"
@@ -30,6 +30,10 @@
30
30
  >
31
31
  Reset
32
32
  </el-button>
33
+ <el-radio-group v-model="filterVisibility">
34
+ <el-radio :value="true">Focused</el-radio>
35
+ <el-radio :value="false">Contextual</el-radio>
36
+ </el-radio-group>
33
37
  </div>
34
38
  </template>
35
39
  <SearchFilters
@@ -78,8 +82,8 @@
78
82
  :availableAnatomyFacets="availableAnatomyFacets"
79
83
  :envVars="envVars"
80
84
  :withCloseButton="true"
81
- @show-connectivity="$emit('show-connectivity', $event)"
82
- @show-reference-connectivities="$emit('show-reference-connectivities', $event)"
85
+ @show-connectivity="onShowConnectivity"
86
+ @show-reference-connectivities="onShowReferenceConnectivities"
83
87
  @connectivity-clicked="onConnectivityClicked"
84
88
  @connectivity-hovered="$emit('connectivity-hovered', $event)"
85
89
  @loaded="onConnectivityInfoLoaded(result)"
@@ -109,14 +113,12 @@ import {
109
113
  ElInput as Input,
110
114
  ElPagination as Pagination,
111
115
  } from "element-plus";
112
- import EventBus from './EventBus.js'
113
116
  import SearchFilters from "./SearchFilters.vue";
114
117
  import SearchHistory from "./SearchHistory.vue";
115
118
  import ConnectivityCard from "./ConnectivityCard.vue";
116
119
  import ConnectivityInfo from "./ConnectivityInfo.vue";
117
120
 
118
121
  var initial_state = {
119
- filters: [],
120
122
  searchInput: "",
121
123
  lastSearch: "",
122
124
  results: [],
@@ -162,6 +164,10 @@ export default {
162
164
  type: Object,
163
165
  default: [],
164
166
  },
167
+ connectivityFilterOptions: {
168
+ type: Array,
169
+ default: [],
170
+ },
165
171
  },
166
172
  data: function () {
167
173
  return {
@@ -171,34 +177,12 @@ export default {
171
177
  "flex-flow": "column",
172
178
  display: "flex",
173
179
  },
174
- filterOptions: [
175
- {
176
- id: 3,
177
- key: "flatmap.connectivity.source",
178
- label: "Connectivity",
179
- children: [
180
- {
181
- facetPropPath: "flatmap.connectivity.source",
182
- id: 0,
183
- label: "Origins",
184
- },
185
- {
186
- facetPropPath: "flatmap.connectivity.source",
187
- id: 1,
188
- label: "Components",
189
- },
190
- {
191
- facetPropPath: "flatmap.connectivity.source",
192
- id: 2,
193
- label: "Destinations",
194
- },
195
- ],
196
- },
197
- ],
198
180
  cascaderIsReady: false,
199
- displayConnectivity: false,
181
+ freezeTimeout: undefined,
182
+ freezed: false,
200
183
  initLoading: true,
201
- expanded: ""
184
+ expanded: "",
185
+ filterVisibility: true
202
186
  };
203
187
  },
204
188
  computed: {
@@ -207,8 +191,8 @@ export default {
207
191
  return {
208
192
  numberOfHits: this.numberOfHits,
209
193
  filterFacets: this.filter,
210
- options: this.filterOptions,
211
- showFilters: false
194
+ options: this.connectivityFilterOptions,
195
+ showFilters: true
212
196
  };
213
197
  },
214
198
  paginatedResults: function () {
@@ -246,20 +230,37 @@ export default {
246
230
  paginatedResults: function () {
247
231
  this.loadingCards = false;
248
232
  },
233
+ filterVisibility: function (state) {
234
+ this.filterVisibility = state;
235
+ this.$emit('filter-visibility', this.filterVisibility);
236
+ },
249
237
  },
250
238
  methods: {
239
+ freezeHoverChange: function () {
240
+ this.freezed = true;
241
+ if (this.freezeTimeout) {
242
+ clearTimeout(this.freezeTimeout);
243
+ }
244
+ this.freezeTimeout = setTimeout(() => {
245
+ this.freezed = false;
246
+ }, 3000)
247
+ },
248
+ onShowConnectivity: function (data) {
249
+ this.freezeHoverChange();
250
+ this.$emit('show-connectivity', data);
251
+ },
252
+ onShowReferenceConnectivities: function (data) {
253
+ this.freezeHoverChange();
254
+ this.$emit('show-reference-connectivities', data);
255
+ },
251
256
  onConnectivityClicked: function (data) {
252
257
  this.searchInput = data.query;
253
- this.filters = data.filter;
258
+ this.filter = data.filter;
254
259
  this.searchAndFilterUpdate();
255
260
  },
256
261
  collapseChange:function (data) {
257
262
  this.expanded = this.expanded === data.id ? "" : data.id;
258
263
  },
259
- closeConnectivity: function (data) {
260
- this.expanded = '';
261
- this.$emit('connectivity-item-close');
262
- },
263
264
  onConnectivityCollapseChange: function (data) {
264
265
  // close connectivity event will not trigger emit
265
266
  if (this.connectivityEntry.find(entry => entry.featureId[0] === data.id)) {
@@ -273,8 +274,11 @@ export default {
273
274
  }
274
275
  },
275
276
  hoverChanged: function (data) {
276
- const payload = data ? { ...data, type: "connectivity" } : data;
277
- this.$emit("hover-changed", payload);
277
+ // disable hover changes when show connectivity is clicked
278
+ if (!this.freezed) {
279
+ const payload = data ? { ...data, tabType: "connectivity" } : { tabType: "connectivity" };
280
+ this.$emit("hover-changed", payload);
281
+ }
278
282
  },
279
283
  resetSearch: function () {
280
284
  this.numberOfHits = 0;
@@ -282,9 +286,12 @@ export default {
282
286
  this.loadingCards = false;
283
287
  },
284
288
  resetSearchIfNoActiveSearch: function() {
285
- if (!this.searchInput) this.openSearch([], '');
289
+ const hasValidFacet = this.filter.some(f => f.facet !== "Show all");
290
+ if (!this.searchInput && !hasValidFacet) {
291
+ this.openSearch([], '');
292
+ }
286
293
  },
287
- openSearch: function (filter, search = "", option = { withSearch: true }) {
294
+ openSearch: function (filter, search = "") {
288
295
  this.searchInput = search;
289
296
  this.resetPageNavigation();
290
297
  //Proceed normally if cascader is ready
@@ -303,17 +310,17 @@ export default {
303
310
  this.$refs.filtersRef.checkShowAllBoxes();
304
311
  this.resetSearch();
305
312
  } else if (this.filter) {
306
- if (option.withSearch) {
307
- this.searchKnowledge(this.filter, search);
308
- }
313
+ this.searchKnowledge(this.filter, search);
309
314
  this.$refs.filtersRef.setCascader(this.filter);
315
+ this.searchHistoryUpdate(this.filter, search);
310
316
  }
311
317
  } else {
312
318
  //cascader is not ready, perform search if no filter is set,
313
319
  //otherwise waith for cascader to be ready
314
320
  this.filter = filter;
315
- if ((!filter || filter.length == 0) && option.withSearch) {
321
+ if (!filter || filter.length == 0) {
316
322
  this.searchKnowledge(this.filter, search);
323
+ this.searchHistoryUpdate(this.filter, search);
317
324
  }
318
325
  }
319
326
  },
@@ -339,63 +346,44 @@ export default {
339
346
  clearSearchClicked: function () {
340
347
  this.searchInput = "";
341
348
  this.searchAndFilterUpdate();
342
- this.$refs.filtersRef.checkShowAllBoxes();
343
349
  },
344
350
  searchEvent: function (event = false) {
345
351
  if (event.keyCode === 13 || event instanceof MouseEvent) {
346
352
  this.searchInput = this.searchInput.trim();
347
353
  this.searchAndFilterUpdate();
348
- if (!this.searchInput) {
349
- this.$refs.filtersRef.checkShowAllBoxes();
350
- }
351
354
  }
352
355
  },
353
356
  filterUpdate: function (filters) {
354
- this.filters = [...filters];
357
+ this.filter = [...filters];
355
358
  this.searchAndFilterUpdate();
356
- this.$emit("search-changed", {
357
- value: filters,
358
- type: "filter-update",
359
- });
360
- },
361
- /**
362
- * Transform filters for third level items to perform search
363
- * because cascader keeps adding it back.
364
- */
365
- transformFiltersBeforeSearch: function (filters) {
366
- return filters.map((filter) => {
367
- if (filter.facet2) {
368
- filter.facet = filter.facet2;
369
- delete filter.facet2;
370
- }
371
- return filter;
372
- });
359
+ // this.$emit("search-changed", {
360
+ // value: filters,
361
+ // tabType: "connectivity",
362
+ // type: "filter-update",
363
+ // });
373
364
  },
374
365
  searchAndFilterUpdate: function () {
375
366
  this.resetPageNavigation();
376
- const transformedFilters = this.transformFiltersBeforeSearch(
377
- this.filters
378
- );
379
- this.searchKnowledge(transformedFilters, this.searchInput);
367
+ this.searchKnowledge(this.filter, this.searchInput);
368
+ this.searchHistoryUpdate(this.filter, this.searchInput);
380
369
  },
381
370
  searchHistoryUpdate: function (filters, search) {
382
371
  this.$refs.searchHistory.selectValue = 'Search history';
383
372
  // save history only if there has value
384
- if (search?.trim()) {
385
- this.$refs.searchHistory.addSearchToHistory(
386
- filters,
387
- search
388
- );
373
+ if (filters.length || search?.trim()) {
374
+ this.$refs.searchHistory.addSearchToHistory(this.filter, search);
389
375
  }
390
376
  },
391
377
  searchKnowledge: function (filters, query = "") {
392
378
  this.expanded = "";
393
- this.searchHistoryUpdate(filters, query);
394
379
  this.loadingCards = true;
395
380
  this.scrollToTop();
396
381
  this.$emit("search-changed", {
397
- value: this.searchInput,
398
- type: "query-update",
382
+ // value: this.searchInput,
383
+ // type: "query-update",
384
+ query: query,
385
+ filter: filters,
386
+ tabType: "connectivity",
399
387
  });
400
388
  this.lastSearch = query;
401
389
  },
@@ -409,7 +397,7 @@ export default {
409
397
  pageChange: function (page) {
410
398
  this.start = (page - 1) * this.numberPerPage;
411
399
  this.page = page;
412
- this.searchKnowledge(this.filters, this.searchInput);
400
+ this.searchKnowledge(this.filter, this.searchInput);
413
401
  },
414
402
  scrollToTop: function () {
415
403
  if (this.$refs.content) {
@@ -422,8 +410,8 @@ export default {
422
410
  },
423
411
  searchHistorySearch: function (item) {
424
412
  this.searchInput = item.search;
425
- this.filters = item.filters;
426
- this.searchAndFilterUpdate();
413
+ this.filter = item.filters;
414
+ this.openSearch([...item.filters], item.search);
427
415
  },
428
416
  onConnectivityInfoLoaded: function (result) {
429
417
  const stepItemRef = this.$refs['stepItem-' + result.id];
@@ -438,10 +426,6 @@ export default {
438
426
  mounted: function () {
439
427
  localStorage.removeItem('connectivity-active-view');
440
428
  this.openSearch(this.filter, this.searchInput);
441
-
442
- EventBus.on('close-connectivity', () => {
443
- this.closeConnectivity();
444
- });
445
429
  },
446
430
  };
447
431
  </script>
@@ -512,6 +496,9 @@ export default {
512
496
  }
513
497
 
514
498
  .header {
499
+ display: flex;
500
+ align-items: center;
501
+
515
502
  .el-button {
516
503
  font-family: inherit;
517
504
 
@@ -519,7 +506,19 @@ export default {
519
506
  &:focus {
520
507
  background: $app-primary-color;
521
508
  box-shadow: -3px 2px 4px #00000040;
522
- color: #fff;
509
+ color: #ffffff;
510
+ }
511
+ }
512
+
513
+ .el-radio-group {
514
+ display: flex;
515
+ flex-direction: column;
516
+ align-items: flex-start;
517
+
518
+ .el-radio {
519
+ color: #ffffff;
520
+ margin-left: 20px;
521
+ height: 20px;
523
522
  }
524
523
  }
525
524
  }
@@ -1,7 +1,7 @@
1
1
  <template>
2
2
  <div class="filters">
3
3
  <MapSvgSpriteColor />
4
- <div v-show="showFilters">
4
+ <div v-if="showFilters">
5
5
  <div class="cascader-tag" v-if="presentTags.length > 0">
6
6
  <el-tag
7
7
  class="ml-2"
@@ -9,12 +9,12 @@
9
9
  closable
10
10
  @close="cascadeTagClose(presentTags[0])"
11
11
  >
12
- {{ presentTags[0] }}
12
+ <p class="tag-text">{{ presentTags[0] }}</p>
13
13
  </el-tag>
14
14
  <el-popover
15
15
  v-if="presentTags.length > 1"
16
16
  placement="bottom-start"
17
- :width="200"
17
+ :width="250"
18
18
  trigger="hover"
19
19
  popper-class="cascade-tags-popover"
20
20
  >
@@ -131,6 +131,9 @@ const convertReadableLabel = function (original) {
131
131
  if (speciesMap[name]) {
132
132
  return capitalise(speciesMap[name])
133
133
  } else {
134
+ if (original === original.toUpperCase()) {
135
+ return original
136
+ }
134
137
  return capitalise(name)
135
138
  }
136
139
  }
@@ -202,6 +205,27 @@ export default {
202
205
  return this.entry.showFilters
203
206
  }
204
207
  },
208
+ watch: {
209
+ entry: {
210
+ deep: true,
211
+ immediate: true,
212
+ handler: function (newVal, oldVal) {
213
+ if (JSON.stringify(newVal?.options) !== JSON.stringify(oldVal?.options)) {
214
+ this.options = []
215
+ this.filters = []
216
+ this.cascaderIsReady = false
217
+ // Populate the cascader with new options
218
+ this.populateCascader().then(() => {
219
+ this.cascaderIsReady = true
220
+ this.checkShowAllBoxes()
221
+ // this.setCascader(this.entry.filterFacets)
222
+ this.cssMods()
223
+ this.$emit('cascaderReady')
224
+ })
225
+ }
226
+ },
227
+ },
228
+ },
205
229
  methods: {
206
230
  createCascaderItemValue: function (
207
231
  term,
@@ -228,11 +252,13 @@ export default {
228
252
  undefined
229
253
  )
230
254
 
231
- // put "Show all" as first option
232
- this.options[i].children.unshift({
233
- value: this.createCascaderItemValue('Show all'),
234
- label: 'Show all',
235
- })
255
+ if (!this.options[i].children.find((child) => child.label === 'Show all')) {
256
+ // put "Show all" as first option
257
+ this.options[i].children.unshift({
258
+ value: this.createCascaderItemValue('Show all'),
259
+ label: 'Show all',
260
+ })
261
+ }
236
262
 
237
263
  // populate second level of options
238
264
  this.options[i].children.forEach((facetItem, j) => {
@@ -488,13 +514,6 @@ export default {
488
514
  }
489
515
  })
490
516
 
491
- // if all checkboxes are checked
492
- // there has no filter values
493
- const filtersLength = filters.filter((item) => item.facet !== 'Show all');
494
- if (!filtersLength.length) {
495
- filters = [];
496
- }
497
-
498
517
  // timeout: add delay for filter checkboxes
499
518
  if (this.filterTimeout) {
500
519
  clearTimeout(this.filterTimeout);
@@ -866,6 +885,13 @@ export default {
866
885
  gap: 4px;
867
886
  }
868
887
 
888
+ .tag-text {
889
+ max-width: 75px;
890
+ white-space: nowrap;
891
+ overflow: hidden;
892
+ text-overflow: ellipsis;
893
+ }
894
+
869
895
  .el-tags-container {
870
896
  display: flex;
871
897
  flex-wrap: wrap;
@@ -215,14 +215,6 @@ export default {
215
215
  }
216
216
  return 0;
217
217
  },
218
- formatFilters(filterItem) {
219
- // because filters do not work correctly with facet2
220
- if (filterItem.facet2) {
221
- filterItem.facet = filterItem.facet2;
222
- delete filterItem.facet2;
223
- }
224
- return filterItem;
225
- },
226
218
  addSearchToHistory(filters = [], search = '') {
227
219
  search = search.trim() // remove whitespace
228
220
 
@@ -230,10 +222,6 @@ export default {
230
222
  let historyFilters = item.filters;
231
223
  let newFilters = filters;
232
224
 
233
- // make all filters same format
234
- historyFilters.forEach((filter) => this.formatFilters(filter));
235
- newFilters.forEach((filter) => this.formatFilters(filter));
236
-
237
225
  // sort filters (to check duplicates in string format)
238
226
  historyFilters = historyFilters.sort(this.sortFilters);
239
227
  newFilters = newFilters.sort(this.sortFilters);
@@ -333,11 +321,6 @@ export default {
333
321
  item['longLabel'] = longLabel;
334
322
  }
335
323
 
336
- // make all filters same format
337
- item.filters.forEach((filter) =>
338
- this.formatFilters(filter)
339
- );
340
-
341
324
  // sort filters (to check duplicates in string format)
342
325
  item.filters = item.filters.sort(this.sortFilters);
343
326
 
@@ -372,7 +355,7 @@ export default {
372
355
 
373
356
  if (filters) {
374
357
  filterItems = filters.filter((filterItem) => filterItem.facet !== 'Show all');
375
- filterLabels = filterItems.map((item) => item.facet2 || item.facet);
358
+ filterLabels = filterItems.map((item) => item.facet);
376
359
  }
377
360
 
378
361
  if (label && filterItems.length) {
@@ -49,13 +49,14 @@
49
49
  :envVars="envVars"
50
50
  :connectivityEntry="connectivityEntry"
51
51
  :availableAnatomyFacets="availableAnatomyFacets"
52
+ :connectivityFilterOptions="filterOptions"
53
+ @filter-visibility="$emit('filter-visibility', $event)"
52
54
  @search-changed="searchChanged(tab.id, $event)"
53
- @hover-changed="hoverChanged($event)"
55
+ @hover-changed="hoverChanged(tab.id, $event)"
54
56
  @show-connectivity="showConnectivity"
55
57
  @show-reference-connectivities="onShowReferenceConnectivities"
56
58
  @connectivity-hovered="onConnectivityHovered"
57
59
  @connectivity-collapse-change="onConnectivityCollapseChange"
58
- @connectivity-item-close="onConnectivityItemClose"
59
60
  />
60
61
  </template>
61
62
  <template v-else>
@@ -66,7 +67,7 @@
66
67
  :envVars="envVars"
67
68
  :ref="'datasetExplorerTab_' + tab.id"
68
69
  @search-changed="searchChanged(tab.id, $event)"
69
- @hover-changed="hoverChanged($event)"
70
+ @hover-changed="hoverChanged(tab.id, $event)"
70
71
  />
71
72
  </template>
72
73
  </template>
@@ -165,6 +166,10 @@ export default {
165
166
  type: Array,
166
167
  default: [],
167
168
  },
169
+ filterOptions: {
170
+ type: Array,
171
+ default: [],
172
+ },
168
173
  },
169
174
  data: function () {
170
175
  return {
@@ -177,20 +182,12 @@ export default {
177
182
  onConnectivityCollapseChange: function (data) {
178
183
  this.$emit('connectivity-collapse-change', data)
179
184
  },
180
- /**
181
- * This event is emitted when
182
- * the close button of the opened connectivity card
183
- * in connectivity explorer is clicked.
184
- */
185
- onConnectivityItemClose: function () {
186
- this.$emit('connectivity-item-close');
187
- },
188
185
  /**
189
186
  * This event is emitted when the mouse hover are changed.
190
187
  * @arg data
191
188
  */
192
- hoverChanged: function (data) {
193
- this.$emit('hover-changed', data)
189
+ hoverChanged: function (id, data) {
190
+ this.$emit('hover-changed', {...data, tabId: id })
194
191
  },
195
192
  /**
196
193
  * This event is emitted when the show connectivity button is clicked.
@@ -218,7 +215,7 @@ export default {
218
215
  * @arg `obj` {data, id}
219
216
  */
220
217
  searchChanged: function (id, data) {
221
- this.$emit('search-changed', { ...data, id: id })
218
+ this.$emit('search-changed', { ...data, tabId: id })
222
219
  },
223
220
  /**
224
221
  * The function to close sidebar.
@@ -332,9 +329,6 @@ export default {
332
329
  storeAvailableAnatomyFacets: function (availableAnatomyFacets) {
333
330
  localStorage.setItem('available-anatomy-facets', JSON.stringify(availableAnatomyFacets))
334
331
  },
335
- closeConnectivity: function () {
336
- EventBus.emit('close-connectivity');
337
- },
338
332
  },
339
333
  computed: {
340
334
  // This should respect the information provided by the property