@abi-software/map-side-bar 2.18.0 → 2.19.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 (36) hide show
  1. package/.postcssrc.json +5 -5
  2. package/README.md +8 -9
  3. package/cypress.config.js +6 -7
  4. package/dist/map-side-bar.js +5878 -5991
  5. package/dist/map-side-bar.umd.cjs +58 -58
  6. package/dist/style.css +1 -1
  7. package/eslint.config.js +44 -9
  8. package/package.json +10 -3
  9. package/reporter-config.json +1 -1
  10. package/src/App.vue +79 -78
  11. package/src/algolia/algolia.js +173 -167
  12. package/src/algolia/utils.js +34 -38
  13. package/src/assets/_variables.scss +12 -10
  14. package/src/assets/connectivity-explorer.scss +1 -1
  15. package/src/assets/fonts.scss +0 -1
  16. package/src/assets/searchPopover.scss +1 -2
  17. package/src/components/AnnotationTool.vue +9 -32
  18. package/src/components/BadgesGroup.vue +29 -32
  19. package/src/components/ConnectivityCard.vue +21 -18
  20. package/src/components/ConnectivityExplorer.vue +109 -130
  21. package/src/components/ConnectivityInfo.vue +143 -145
  22. package/src/components/ContributorItem.vue +15 -11
  23. package/src/components/DatasetCard.vue +166 -201
  24. package/src/components/DatasetExplorer.vue +160 -201
  25. package/src/components/ImageGallery.vue +35 -36
  26. package/src/components/SearchFilters.vue +377 -403
  27. package/src/components/SearchHistory.vue +61 -89
  28. package/src/components/SideBar.vue +83 -89
  29. package/src/components/Tabs.vue +10 -15
  30. package/src/components/index.js +3 -5
  31. package/src/components/species-map.js +7 -7
  32. package/src/exampleConnectivityInput.js +310 -318
  33. package/src/main.js +6 -6
  34. package/src/mixins/S3Bucket.vue +10 -13
  35. package/vite.config.js +62 -61
  36. package/vuese-generator.js +47 -55
@@ -3,13 +3,10 @@
3
3
  <MapSvgSpriteColor />
4
4
  <div v-if="showFilters && options.length > 0">
5
5
  <div class="cascader-tag" v-if="presentTags.length > 0">
6
- <el-tag
7
- class="ml-2"
8
- type="info"
9
- closable
10
- @close="cascadeTagClose(presentTags[0])"
11
- >
12
- <span class="tag-text" :class="modifyCascaderTagStyle(presentTags[0])">{{ presentTags[0] }}</span>
6
+ <el-tag class="ml-2" type="info" closable @close="cascadeTagClose(presentTags[0])">
7
+ <span class="tag-text" :class="modifyCascaderTagStyle(presentTags[0])">
8
+ {{ presentTags[0] }}
9
+ </span>
13
10
  </el-tag>
14
11
  <el-popover
15
12
  v-if="presentTags.length > 1"
@@ -35,92 +32,88 @@
35
32
  </template>
36
33
  <template #reference>
37
34
  <div class="el-tags-container">
38
- <el-tag
39
- v-if="presentTags.length > 1"
40
- class="ml-2"
41
- type="info"
42
- >
35
+ <el-tag v-if="presentTags.length > 1" class="ml-2" type="info">
43
36
  +{{ presentTags.length - 1 }}
44
37
  </el-tag>
45
38
  </div>
46
39
  </template>
47
40
  </el-popover>
48
41
  </div>
49
- <transition name="el-zoom-in-top">
50
- <span v-loading="!cascaderIsReady" class="search-filters transition-box">
51
- <el-cascader
52
- class="cascader"
53
- ref="cascader"
54
- v-model="cascadeSelected"
55
- size="large"
56
- placeholder=" "
57
- :collapse-tags="true"
58
- collapse-tags-tooltip
59
- :options="options"
60
- :props="cascaderProps"
61
- @change="cascadeEvent($event)"
62
- @expand-change="cascadeExpandChange"
63
- :show-all-levels="true"
64
- popper-class="sidebar-cascader-popper"
65
- >
66
- <template #default="{ node, data }">
67
- <div v-if="isFlatmapConnectionsFilterNode(node)">
68
- <div class="sidebar-cascader-search el-input">
69
- <div class="el-input__wrapper">
70
- <input
71
- class="el-input__inner"
72
- :ref="'searchInput_' + node.pathValues[0]"
73
- :value="searchInputs[node.pathValues[0]]"
74
- @input="searchInputChange($event, node)"
75
- @focus="searchInputFocusToggle($event, true)"
76
- @blur="searchInputFocusToggle($event, false)"
77
- style="width: 100%"
78
- autocomplete="off"
79
- placeholder="Search"
80
- />
81
- </div>
42
+ <span v-loading="!cascaderIsReady" class="search-filters transition-box">
43
+ <el-cascader
44
+ class="cascader"
45
+ ref="cascader"
46
+ v-model="cascadeSelected"
47
+ size="large"
48
+ placeholder=" "
49
+ :collapse-tags="true"
50
+ collapse-tags-tooltip
51
+ :options="options"
52
+ :props="cascaderProps"
53
+ @change="cascadeEvent($event)"
54
+ @expand-change="cascadeExpandChange"
55
+ :show-all-levels="true"
56
+ popper-class="sidebar-cascader-popper"
57
+ >
58
+ <template #default="{ node, data }">
59
+ <div v-if="isFlatmapConnectionsFilterNode(node)">
60
+ <div class="sidebar-cascader-search el-input">
61
+ <div class="el-input__wrapper">
62
+ <input
63
+ class="el-input__inner"
64
+ :ref="'searchInput_' + node.pathValues[0]"
65
+ :value="searchInputs[node.pathValues[0]]"
66
+ @input="searchInputChange($event, node)"
67
+ @focus="searchInputFocusToggle($event, true)"
68
+ @blur="searchInputFocusToggle($event, false)"
69
+ style="width: 100%"
70
+ autocomplete="off"
71
+ placeholder="Search"
72
+ />
82
73
  </div>
83
74
  </div>
84
- <div v-else>
85
- <el-row>
86
- <el-col :span="4" v-if="hasLineStyles(data)">
87
- <div class="path-visual" :style="getLineStyles(data)"></div>
88
- </el-col>
89
- <el-col :span="20">
90
- <span v-if="isFlatmapConnectionsNode(node)" class="sr-only">
91
- {{ getNodeKey(node.value) }}
92
- </span>
93
- <div :style="getBackgroundStyles(data)">
94
- {{ data.label }}
95
- </div>
96
- </el-col>
97
- </el-row>
98
- </div>
99
- </template>
100
- </el-cascader>
101
- <div v-if="showFiltersText" class="filter-default-value">Filters</div>
102
- <el-popover
103
- title="How do filters work?"
104
- width="250"
105
- trigger="hover"
106
- popper-class="filter-help-popover"
107
- >
108
- <template #reference>
109
- <MapSvgIcon icon="help" class="help" />
110
- </template>
111
- <div>
112
- <strong>Within categories:</strong> OR
113
- <br />
114
- example: {{ entry.helper.within }}
115
- <br />
116
- <br />
117
- <strong>Between categories:</strong> AND
118
- <br />
119
- example: {{ entry.helper.between }}
120
75
  </div>
121
- </el-popover>
122
- </span>
123
- </transition>
76
+ <div v-else>
77
+ <el-row>
78
+ <el-col :span="4" v-if="hasLineStyles(data)">
79
+ <div class="path-visual" :style="getLineStyles(data)"></div>
80
+ </el-col>
81
+ <el-col :span="20">
82
+ <span v-if="isFlatmapConnectionsNode(node)" class="sr-only">
83
+ {{ getNodeKey(node.value) }}
84
+ </span>
85
+ <div :style="getBackgroundStyles(data)">
86
+ {{ data.label }}
87
+ </div>
88
+ </el-col>
89
+ </el-row>
90
+ </div>
91
+ </template>
92
+ </el-cascader>
93
+ <div v-if="showFiltersText" class="filter-default-value">Filters</div>
94
+ <el-popover
95
+ title="How do filters work?"
96
+ width="250"
97
+ trigger="hover"
98
+ popper-class="filter-help-popover"
99
+ >
100
+ <template #reference>
101
+ <MapSvgIcon icon="help" class="help" />
102
+ </template>
103
+ <div>
104
+ <strong>Within categories:</strong>
105
+ OR
106
+ <br />
107
+ example: {{ entry.helper.within }}
108
+ <br />
109
+ <br />
110
+ <strong>Between categories:</strong>
111
+ AND
112
+ <br />
113
+ example: {{ entry.helper.between }}
114
+ </div>
115
+ </el-popover>
116
+ </span>
124
117
  </div>
125
118
  <div class="dataset-shown">
126
119
  <span class="dataset-results-feedback">{{ numberOfResultsText }}</span>
@@ -142,47 +135,36 @@
142
135
  </template>
143
136
 
144
137
  <script>
145
- /* eslint-disable no-alert, no-console */
146
- import { markRaw } from 'vue'
147
- import {
148
- ElOption as Option,
149
- ElSelect as Select,
150
- ElPopover as Popover,
151
- ElCascader as Cascader,
152
- } from 'element-plus'
153
- import speciesMap from './species-map.js'
154
- import { MapSvgIcon, MapSvgSpriteColor } from "@abi-software/svg-sprite";
155
- import '@abi-software/svg-sprite/dist/style.css'
156
-
157
- import { AlgoliaClient } from '../algolia/algolia.js'
158
- import { facetPropPathMapping } from '../algolia/utils.js'
159
- import EventBus from './EventBus.js'
138
+ import { markRaw } from 'vue';
139
+ import speciesMap from './species-map.js';
140
+ import { MapSvgIcon, MapSvgSpriteColor } from '@abi-software/svg-sprite';
141
+ import '@abi-software/svg-sprite/dist/style.css';
142
+
143
+ import { AlgoliaClient } from '../algolia/algolia.js';
144
+ import { facetPropPathMapping } from '../algolia/utils.js';
145
+ import EventBus from './EventBus.js';
160
146
 
161
147
  const capitalise = function (txt) {
162
- return txt.charAt(0).toUpperCase() + txt.slice(1)
163
- }
148
+ return txt.charAt(0).toUpperCase() + txt.slice(1);
149
+ };
164
150
 
165
151
  const convertReadableLabel = function (original) {
166
- const name = original.toLowerCase()
152
+ const name = original.toLowerCase();
167
153
  if (speciesMap[name]) {
168
- return capitalise(speciesMap[name])
154
+ return capitalise(speciesMap[name]);
169
155
  } else {
170
156
  if (original === original.toUpperCase()) {
171
- return original
157
+ return original;
172
158
  }
173
- return capitalise(name)
159
+ return capitalise(name);
174
160
  }
175
- }
161
+ };
176
162
 
177
163
  export default {
178
164
  name: 'SearchFilters',
179
165
  components: {
180
166
  MapSvgIcon,
181
167
  MapSvgSpriteColor,
182
- Option,
183
- Select,
184
- Popover,
185
- Cascader
186
168
  },
187
169
  props: {
188
170
  /**
@@ -225,9 +207,9 @@ export default {
225
207
  children: [{}],
226
208
  },
227
209
  ],
228
- presentTags:[],
210
+ presentTags: [],
229
211
  searchInputs: {},
230
- }
212
+ };
231
213
  },
232
214
  setup() {
233
215
  const cascaderTags = markRaw({});
@@ -237,15 +219,15 @@ export default {
237
219
  facet2: new Set(),
238
220
  facet3: new Set(),
239
221
  });
240
- return { cascaderTags, correctnessCheck }
222
+ return { cascaderTags, correctnessCheck };
241
223
  },
242
224
  computed: {
243
225
  numberOfResultsText: function () {
244
- return `${this.entry.numberOfHits} results | Showing`
226
+ return `${this.entry.numberOfHits} results | Showing`;
245
227
  },
246
228
  showFilters: function () {
247
- return this.entry.showFilters
248
- }
229
+ return this.entry.showFilters;
230
+ },
249
231
  },
250
232
  watch: {
251
233
  entry: {
@@ -253,18 +235,18 @@ export default {
253
235
  immediate: true,
254
236
  handler: function (newVal, oldVal) {
255
237
  if (JSON.stringify(newVal?.options) !== JSON.stringify(oldVal?.options)) {
256
- this.options = []
257
- this.filters = []
258
- this.cascaderIsReady = false
238
+ this.options = [];
239
+ this.filters = [];
240
+ this.cascaderIsReady = false;
259
241
  // Populate the cascader with new options
260
242
  this.populateCascader().then(() => {
261
- this.cascaderIsReady = true
243
+ this.cascaderIsReady = true;
262
244
  if (this.options.length) {
263
- this.checkShowAllBoxes()
245
+ this.checkShowAllBoxes();
264
246
  // this.setCascader(this.entry.filterFacets)
265
- this.$emit('cascaderReady')
247
+ this.$emit('cascaderReady');
266
248
  }
267
- })
249
+ });
268
250
  }
269
251
  },
270
252
  },
@@ -276,29 +258,27 @@ export default {
276
258
  * Takes an array of label to create the value
277
259
  */
278
260
  createCascaderItemValue: function (labelsArray) {
279
- let value = undefined
261
+ let value = undefined;
280
262
  if (labelsArray?.length) {
281
- value = labelsArray[0]
263
+ value = labelsArray[0];
282
264
  for (let i = 1; labelsArray.length > i; i++) {
283
- value = `${value}>${labelsArray[i]}`
265
+ value = `${value}>${labelsArray[i]}`;
284
266
  }
285
- if (value.includes("undefined")) {
267
+ if (value.includes('undefined')) {
286
268
  console.warn(
287
- `Warning: One or more of the facets is undefined, this will not be shown in the cascader`
288
- )
269
+ `Warning: One or more of the facets is undefined, this will not be shown in the cascader`,
270
+ );
289
271
  }
290
272
  }
291
273
  return value;
292
274
  },
293
- createChildrenCascaderValue: function(children, facet, facets) {
275
+ createChildrenCascaderValue: function (children, facet, facets) {
294
276
  if (children?.length) {
295
277
  for (let i = 0; i < children.length; i++) {
296
278
  const facetItem = children[i];
297
279
  //copy the facets into
298
280
  if (children[i].facetPropPath !== 'supportingAwards.consortium.name') {
299
- children[i].label = convertReadableLabel(
300
- facetItem.label
301
- )
281
+ children[i].label = convertReadableLabel(facetItem.label);
302
282
  }
303
283
  if (facetItem.key && facet.key.includes('flatmap.connectivity.source.')) {
304
284
  const childKey = facetItem.key;
@@ -306,10 +286,10 @@ export default {
306
286
  const key = childKey.replace(`${parentKey}.`, '');
307
287
  children[i].value = this.createCascaderItemValue([facet.label, key]);
308
288
  } else {
309
- const newFacets = facets.slice()
310
- newFacets.push(facetItem.label)
311
- children[i].value = this.createCascaderItemValue(newFacets)
312
- this.createChildrenCascaderValue(facetItem.children, facet, newFacets)
289
+ const newFacets = facets.slice();
290
+ newFacets.push(facetItem.label);
291
+ children[i].value = this.createCascaderItemValue(newFacets);
292
+ this.createChildrenCascaderValue(facetItem.children, facet, newFacets);
313
293
  }
314
294
  }
315
295
  }
@@ -318,10 +298,7 @@ export default {
318
298
  return nodeValue ? nodeValue.split('>')[1] : '';
319
299
  },
320
300
  isFlatmapConnectionsNode: function (node) {
321
- return (
322
- node.pathValues[0].includes('flatmap.connectivity.source') &&
323
- node.isLeaf
324
- )
301
+ return node.pathValues[0].includes('flatmap.connectivity.source') && node.isLeaf;
325
302
  },
326
303
  isFlatmapConnectionsFilterNode: function (node) {
327
304
  return (
@@ -329,7 +306,7 @@ export default {
329
306
  node.pathLabels.includes('Filters') &&
330
307
  node.isDisabled &&
331
308
  node.isLeaf
332
- )
309
+ );
333
310
  },
334
311
  processOptions: function () {
335
312
  // Create a deep copy to avoid triggering reactivity during processing
@@ -337,19 +314,17 @@ export default {
337
314
 
338
315
  // create top level of options in cascader
339
316
  processedOptions.forEach((facet, i) => {
340
- processedOptions[i].total = this.countTotalFacet(facet)
317
+ processedOptions[i].total = this.countTotalFacet(facet);
341
318
 
342
- processedOptions[i].label = convertReadableLabel(facet.label)
343
- processedOptions[i].value = this.createCascaderItemValue(
344
- [facet.key]
345
- )
319
+ processedOptions[i].label = convertReadableLabel(facet.label);
320
+ processedOptions[i].value = this.createCascaderItemValue([facet.key]);
346
321
 
347
322
  if (!processedOptions[i].children.find((child) => child.label === 'Show all')) {
348
323
  // put "Show all" as first option
349
324
  processedOptions[i].children.unshift({
350
325
  value: this.createCascaderItemValue(['Show all']),
351
326
  label: 'Show all',
352
- })
327
+ });
353
328
  }
354
329
 
355
330
  if (facet.key.includes('flatmap.connectivity.source')) {
@@ -361,8 +336,8 @@ export default {
361
336
  }
362
337
 
363
338
  // populate second level of options
364
- this.createChildrenCascaderValue(processedOptions[i].children, facet, [facet.label])
365
- })
339
+ this.createChildrenCascaderValue(processedOptions[i].children, facet, [facet.label]);
340
+ });
366
341
 
367
342
  // trigger reactivity only once
368
343
  Object.assign(this.options, processedOptions);
@@ -370,9 +345,9 @@ export default {
370
345
  populateCascader: function () {
371
346
  if (this.entry.options) {
372
347
  return new Promise((resolve) => {
373
- this.facets = this.entry.options
374
- this.options = this.entry.options
375
- this.processOptions()
348
+ this.facets = this.entry.options;
349
+ this.options = this.entry.options;
350
+ this.processOptions();
376
351
  resolve();
377
352
  });
378
353
  }
@@ -381,22 +356,22 @@ export default {
381
356
  this.algoliaClient
382
357
  .getAlgoliaFacets(facetPropPathMapping)
383
358
  .then((data) => {
384
- this.facets = data
385
- EventBus.emit('available-facets', data)
386
- this.options = data
387
- this.processOptions()
359
+ this.facets = data;
360
+ EventBus.emit('available-facets', data);
361
+ this.options = data;
362
+ this.processOptions();
388
363
  })
389
364
  .finally(() => {
390
- resolve()
391
- })
392
- })
365
+ resolve();
366
+ });
367
+ });
393
368
  },
394
369
  isConnectivityTag: function (tag) {
395
370
  const regex = /^[A-Za-z]:/; // starts with O: D: V:
396
371
  return regex.test(tag);
397
372
  },
398
373
  getConnectivityTag: function (tag) {
399
- const index = tag.indexOf(":");
374
+ const index = tag.indexOf(':');
400
375
  const result = index !== -1 ? tag.substring(index + 1) : tag;
401
376
  return result;
402
377
  },
@@ -407,54 +382,54 @@ export default {
407
382
  return '';
408
383
  },
409
384
  flattenToEvents: function (tag, facetObject, targetOption, optionKey = undefined) {
410
- const eventsArray = []
385
+ const eventsArray = [];
411
386
 
412
387
  // loop nested object
413
388
  // if a object has no value and not match with the 'tag', it should be checked in the cascader
414
389
  // otherwise continue looping to find matched facet
415
390
  for (const [key, value] of Object.entries(facetObject)) {
416
- const option = targetOption.find((option) => option.label === key)
391
+ const option = targetOption.find((option) => option.label === key);
417
392
  if (Object.entries(value).length) {
418
393
  // 'show all' has no facetPropPath
419
394
  // therefore passed in the filter option key
420
- const oKey = option.key || optionKey
421
- const events = this.flattenToEvents(tag, value, option.children, oKey)
422
- eventsArray.push(...events)
395
+ const oKey = option.key || optionKey;
396
+ const events = this.flattenToEvents(tag, value, option.children, oKey);
397
+ eventsArray.push(...events);
423
398
  } else {
424
399
  if (key !== tag) {
425
- eventsArray.push([optionKey, option.value])
400
+ eventsArray.push([optionKey, option.value]);
426
401
  }
427
402
  }
428
403
  }
429
404
 
430
- return eventsArray
405
+ return eventsArray;
431
406
  },
432
407
  /**
433
408
  * Create manual events when cascader tag is closed
434
409
  */
435
410
  cascadeTagClose: function (_tag) {
436
411
  const tag = this.isConnectivityTag(_tag) ? this.getConnectivityTag(_tag) : _tag;
437
- const manualEvent = this.flattenToEvents(tag, this.cascaderTags, this.options)
438
- this.cascadeEvent(manualEvent)
412
+ const manualEvent = this.flattenToEvents(tag, this.cascaderTags, this.options);
413
+ this.cascadeEvent(manualEvent);
439
414
  },
440
415
  flattenToTags: function (facetObject) {
441
- const tagsArray = []
416
+ const tagsArray = [];
442
417
 
443
418
  // loop nested object
444
419
  // if a object has no value, it will be display as tag
445
420
  // otherwise continue looping through
446
421
  for (const [key, value] of Object.entries(facetObject)) {
447
422
  if (Object.entries(value).length) {
448
- const tags = this.flattenToTags(value)
449
- tagsArray.push(...tags)
423
+ const tags = this.flattenToTags(value);
424
+ tagsArray.push(...tags);
450
425
  } else {
451
- if (key !== "Show all") {
452
- tagsArray.push(key)
426
+ if (key !== 'Show all') {
427
+ tagsArray.push(key);
453
428
  }
454
429
  }
455
430
  }
456
431
 
457
- return tagsArray
432
+ return tagsArray;
458
433
  },
459
434
  /**
460
435
  * Re-generate 'cascaderTags' and 'presentTags'
@@ -468,24 +443,24 @@ export default {
468
443
  this.correctnessCheck.facet3
469
444
  ) {
470
445
  this.options.map((option) => {
471
- this.correctnessCheck.term.add(option.label)
446
+ this.correctnessCheck.term.add(option.label);
472
447
  option.children?.map((child) => {
473
- this.correctnessCheck.facet.add(child.label)
448
+ this.correctnessCheck.facet.add(child.label);
474
449
  child.children?.map((child2) => {
475
- this.correctnessCheck.facet2.add(child2.label)
450
+ this.correctnessCheck.facet2.add(child2.label);
476
451
  child2.children?.map((child3) => {
477
- this.correctnessCheck.facet3.add(child3.label)
478
- })
479
- })
480
- })
481
- })
452
+ this.correctnessCheck.facet3.add(child3.label);
453
+ });
454
+ });
455
+ });
456
+ });
482
457
  }
483
458
 
484
- this.cascaderTags = {}
485
- this.cascaderTagsClone = {}
486
- this.presentTags = []
459
+ this.cascaderTags = {};
460
+ this.cascaderTagsClone = {};
461
+ this.presentTags = [];
487
462
  event.map((item) => {
488
- const { facet, facet2, facet3, term, tagLabel, facetPropPath } = item
463
+ const { facet, facet2, facet3, term, tagLabel, facetPropPath } = item;
489
464
  let facetLabel = facet;
490
465
  let termId = '';
491
466
  // Connectivity filter has different value and label
@@ -499,38 +474,38 @@ export default {
499
474
  // values will be either empty object or another object with next level's facet as key
500
475
  if (term && this.correctnessCheck.term.has(term)) {
501
476
  if (!(term in this.cascaderTags)) {
502
- this.cascaderTags[term] = {}
503
- this.cascaderTagsClone[term] = {}
477
+ this.cascaderTags[term] = {};
478
+ this.cascaderTagsClone[term] = {};
504
479
  }
505
480
  if (facetLabel && this.correctnessCheck.facet.has(facetLabel)) {
506
481
  if (!(facetLabel in this.cascaderTags[term])) {
507
- this.cascaderTags[term][facetLabel] = {}
482
+ this.cascaderTags[term][facetLabel] = {};
508
483
  if (termId) {
509
- this.cascaderTagsClone[term][termId + ':' + facetLabel] = {}
484
+ this.cascaderTagsClone[term][termId + ':' + facetLabel] = {};
510
485
  } else {
511
- this.cascaderTagsClone[term][facetLabel] = {}
486
+ this.cascaderTagsClone[term][facetLabel] = {};
512
487
  }
513
488
  }
514
489
  if (facet2 && this.correctnessCheck.facet2.has(facet2)) {
515
490
  if (!(facet2 in this.cascaderTags[term][facetLabel])) {
516
- this.cascaderTags[term][facetLabel][facet2] = {}
517
- this.cascaderTagsClone[term][facetLabel][facet2] = {}
491
+ this.cascaderTags[term][facetLabel][facet2] = {};
492
+ this.cascaderTagsClone[term][facetLabel][facet2] = {};
518
493
  }
519
494
  if (facet3 && this.correctnessCheck.facet3.has(facet3)) {
520
495
  if (!(facet3 in this.cascaderTags[term][facetLabel][facet2])) {
521
- this.cascaderTags[term][facetLabel][facet2][facet3] = {}
522
- this.cascaderTagsClone[term][facetLabel][facet2][facet3] = {}
496
+ this.cascaderTags[term][facetLabel][facet2][facet3] = {};
497
+ this.cascaderTagsClone[term][facetLabel][facet2][facet3] = {};
523
498
  }
524
499
  }
525
500
  }
526
501
  }
527
502
  }
528
- })
503
+ });
529
504
 
530
- this.presentTags = [...this.presentTags, ...this.flattenToTags(this.cascaderTagsClone)]
531
- this.presentTags = [...new Set(this.presentTags)].sort()
532
- if (this.presentTags.length > 0) this.showFiltersText = false
533
- else this.showFiltersText = true
505
+ this.presentTags = [...this.presentTags, ...this.flattenToTags(this.cascaderTagsClone)];
506
+ this.presentTags = [...new Set(this.presentTags)].sort();
507
+ if (this.presentTags.length > 0) this.showFiltersText = false;
508
+ else this.showFiltersText = true;
534
509
  },
535
510
  /**
536
511
  * Support for function 'showAllEventModifierForAutoCheckAll'
@@ -540,57 +515,57 @@ export default {
540
515
  if (['anatomy.organ.category.name'].includes(facet.key)) {
541
516
  const count = facet.children.reduce((total, num) => {
542
517
  // The first 'total' will be an object
543
- total = typeof total == 'number' ? total : total.children.length
544
- return total + num.children.length
545
- })
546
- return count
518
+ total = typeof total == 'number' ? total : total.children.length;
519
+ return total + num.children.length;
520
+ });
521
+ return count;
547
522
  }
548
- return facet.children.length
523
+ return facet.children.length;
549
524
  },
550
525
  /**
551
526
  * When check/uncheck all child items, automatically check "Show all"
552
527
  */
553
528
  showAllEventModifierForAutoCheckAll: function (event) {
554
- const currentKeys = {}
529
+ const currentKeys = {};
555
530
  event.map((e) => {
556
- const eventKey = e[0]
557
- if (eventKey in currentKeys) currentKeys[eventKey] += 1
558
- else currentKeys[eventKey] = 1
559
- })
531
+ const eventKey = e[0];
532
+ if (eventKey in currentKeys) currentKeys[eventKey] += 1;
533
+ else currentKeys[eventKey] = 1;
534
+ });
560
535
  this.options.map((option) => {
561
- const key = option.key
562
- const value = option.children.filter((child) => child.label === "Show all")[0].value
563
- const total = option.total
536
+ const key = option.key;
537
+ const value = option.children.filter((child) => child.label === 'Show all')[0].value;
538
+ const total = option.total;
564
539
  // Remove events if all child items is checked
565
540
  if (currentKeys[key] === total) {
566
- event = event.filter((e) => e[0] !== option.key)
567
- delete currentKeys[key]
541
+ event = event.filter((e) => e[0] !== option.key);
542
+ delete currentKeys[key];
568
543
  }
569
544
  // Add 'Show all' if facet type not exist in event
570
- if (!(key in currentKeys)) event.unshift([key, value])
571
- })
572
- return event
545
+ if (!(key in currentKeys)) event.unshift([key, value]);
546
+ });
547
+ return event;
573
548
  },
574
549
  // cascadeEvent: initiate searches based off cascader changes
575
550
  cascadeEvent: function (eventIn) {
576
551
  // Ignore the echoed @change el-cascader fires
577
552
  // after we reassign cascadeSelected in setCascader
578
553
  if (this.cascadeEventLocked) {
579
- return
554
+ return;
580
555
  }
581
- this.cascadeEventLocked = true
582
- let event = [...eventIn]
556
+ this.cascadeEventLocked = true;
557
+ let event = [...eventIn];
583
558
  if (event) {
584
559
  // Check for show all in selected cascade options
585
560
 
586
- event = this.showAllEventModifier(event)
561
+ event = this.showAllEventModifier(event);
587
562
 
588
- event = this.showAllEventModifierForAutoCheckAll(event)
563
+ event = this.showAllEventModifierForAutoCheckAll(event);
589
564
 
590
565
  const cascaderRef = this.$refs.cascader;
591
566
  const checkedNodes = cascaderRef?.getCheckedNodes(true);
592
- const filteredCheckedNodes = checkedNodes.filter((checkedNode) =>
593
- checkedNode.checked && checkedNode.label !== 'Show all'
567
+ const filteredCheckedNodes = checkedNodes.filter(
568
+ (checkedNode) => checkedNode.checked && checkedNode.label !== 'Show all',
594
569
  );
595
570
 
596
571
  /**
@@ -598,25 +573,23 @@ export default {
598
573
  * Otherwise, cascader will show different expand item
599
574
  */
600
575
  if (this.__expandItem__) {
601
- let position = 0
576
+ let position = 0;
602
577
  if (this.__expandItem__.length > 1) {
603
- position = 1
578
+ position = 1;
604
579
  }
605
580
  const current = event.filter((e) => e[position] == this.__expandItem__[position]);
606
581
  const rest = event.filter((e) => e[position] !== this.__expandItem__[position]);
607
- event = [...current, ...rest]
582
+ event = [...current, ...rest];
608
583
  }
609
584
  // Create results for the filter update
610
585
  let filterKeys = event
611
586
  .filter((selection) => selection !== undefined)
612
587
  .map((fs) => {
613
- let { hString, bString } =
614
- this.findHierarachyStringAndBooleanString(fs)
615
- let { facet, facet2, facet3, term } =
616
- this.getFacetsFromHierarchyString(hString)
588
+ let { hString, bString } = this.findHierarachyStringAndBooleanString(fs);
589
+ let { facet, facet2, facet3, term } = this.getFacetsFromHierarchyString(hString);
617
590
 
618
- const foundNode = filteredCheckedNodes.find((checkedNode) =>
619
- fs.join() === checkedNode.pathValues.join()
591
+ const foundNode = filteredCheckedNodes.find(
592
+ (checkedNode) => fs.join() === checkedNode.pathValues.join(),
620
593
  );
621
594
  const tagLabel = foundNode ? foundNode.label : undefined;
622
595
  return {
@@ -626,34 +599,30 @@ export default {
626
599
  facet3: facet3,
627
600
  term: term,
628
601
  AND: bString, // for setting the boolean
629
- tagLabel: tagLabel // for connectivity filter's cascader tag
630
- }
631
- })
602
+ tagLabel: tagLabel, // for connectivity filter's cascader tag
603
+ };
604
+ });
632
605
 
633
606
  // Move results from arrays to object for use on scicrunch (note that we remove 'duplicate' as that is only needed for filter keys)
634
607
  let filters = event
635
608
  .filter((selection) => selection !== undefined)
636
609
  .map((fs) => {
637
- let propPath = fs[0].includes('duplicate')
638
- ? fs[0].split('duplicate')[0]
639
- : fs[0]
640
- let { hString, bString } =
641
- this.findHierarachyStringAndBooleanString(fs)
642
- let { facet, facet2, facet3, term } =
643
- this.getFacetsFromHierarchyString(hString)
610
+ let propPath = fs[0].includes('duplicate') ? fs[0].split('duplicate')[0] : fs[0];
611
+ let { hString, bString } = this.findHierarachyStringAndBooleanString(fs);
612
+ let { facet, facet2, facet3, term } = this.getFacetsFromHierarchyString(hString);
644
613
  //REMOVE THIS:Temporary work around.
645
614
  if (facet3) {
646
- if (facet3 === "Non specific") {
647
- facet = facet2
615
+ if (facet3 === 'Non specific') {
616
+ facet = facet2;
648
617
  } else {
649
- facet = facet3
618
+ facet = facet3;
650
619
  }
651
620
  } else if (facet2) {
652
- facet = facet2
621
+ facet = facet2;
653
622
  }
654
623
 
655
- const foundNode = filteredCheckedNodes.find((checkedNode) =>
656
- fs.join() === checkedNode.pathValues.join()
624
+ const foundNode = filteredCheckedNodes.find(
625
+ (checkedNode) => fs.join() === checkedNode.pathValues.join(),
657
626
  );
658
627
  const tagLabel = foundNode ? foundNode.label : undefined;
659
628
 
@@ -662,55 +631,57 @@ export default {
662
631
  facet: facet,
663
632
  term: term,
664
633
  AND: bString, // for setting the boolean
665
- tagLabel: tagLabel // for connectivity filter's cascader tag
666
- }
667
- })
634
+ tagLabel: tagLabel, // for connectivity filter's cascader tag
635
+ };
636
+ });
668
637
 
669
638
  // timeout: add delay for filter checkboxes
670
639
  if (this.filterTimeout) {
671
640
  clearTimeout(this.filterTimeout);
672
641
  }
673
642
 
674
- this.$emit('loading', true) // let dataset explorer wait for the requests
675
- this.setCascader(filterKeys) //update our cascader v-model if we modified the event
643
+ this.$emit('loading', true); // let dataset explorer wait for the requests
644
+ this.setCascader(filterKeys); //update our cascader v-model if we modified the event
676
645
 
677
646
  this.filterTimeout = setTimeout(() => {
678
- this.$emit('filterResults', filters) // emit filters for apps above sidebar
679
- this.cascadeEventLocked = false // safe to process real cascader changes again
647
+ this.$emit('filterResults', filters); // emit filters for apps above sidebar
648
+ this.cascadeEventLocked = false; // safe to process real cascader changes again
680
649
  }, 600);
681
650
  }
682
651
  },
683
652
  //this fucntion is needed as we previously stored booleans in the array of event that
684
653
  // are stored in the cascader
685
654
  findHierarachyStringAndBooleanString(cascadeEventItem) {
686
- let hString, bString
687
- const layers = cascadeEventItem.length
655
+ let hString, bString;
656
+ const layers = cascadeEventItem.length;
688
657
  if (layers >= 3) {
689
- if (cascadeEventItem[layers - 1] &&
658
+ if (
659
+ cascadeEventItem[layers - 1] &&
690
660
  (typeof cascadeEventItem[layers - 1] === 'string' ||
691
- cascadeEventItem[layers - 1] instanceof String) &&
692
- cascadeEventItem[layers - 1].split('>').length > 2) {
693
- hString = cascadeEventItem[layers - 1]
661
+ cascadeEventItem[layers - 1] instanceof String) &&
662
+ cascadeEventItem[layers - 1].split('>').length > 2
663
+ ) {
664
+ hString = cascadeEventItem[layers - 1];
694
665
  } else {
695
- hString = cascadeEventItem[layers - 2]
666
+ hString = cascadeEventItem[layers - 2];
696
667
  }
697
668
  } else {
698
- hString = cascadeEventItem[1]
669
+ hString = cascadeEventItem[1];
699
670
  }
700
- if (layers >= 3 && typeof cascadeEventItem[layers - 1] === "boolean") {
701
- bString = cascadeEventItem[layers - 1]
671
+ if (layers >= 3 && typeof cascadeEventItem[layers - 1] === 'boolean') {
672
+ bString = cascadeEventItem[layers - 1];
702
673
  }
703
- return { hString, bString }
674
+ return { hString, bString };
704
675
  },
705
676
  // Splits the terms and facets from the string stored in the cascader
706
677
  getFacetsFromHierarchyString(hierarchyString) {
707
- let fsSplit = hierarchyString.split('>')
678
+ let fsSplit = hierarchyString.split('>');
708
679
  return {
709
680
  term: fsSplit[0],
710
681
  facet: fsSplit[1],
711
682
  facet2: fsSplit[2],
712
683
  facet3: fsSplit[3],
713
- }
684
+ };
714
685
  },
715
686
  // showAllEventModifier: Modifies a cascade event to unclick all selections in category if "show all" is clicked. Also unchecks "Show all" if any secection is clicked
716
687
  // *NOTE* Does NOT remove 'Show all' selections from showing in 'cascadeSelected'
@@ -718,40 +689,39 @@ export default {
718
689
  // check if show all is in the cascader checked option list
719
690
  let hasShowAll = event
720
691
  .map((ev) => (ev ? ev[1].toLowerCase().includes('show all') : false))
721
- .includes(true)
692
+ .includes(true);
722
693
  // remove all selected options below the show all if checked
723
694
  if (hasShowAll) {
724
- let modifiedEvent = []
725
- let facetMaps = {}
695
+ let modifiedEvent = [];
696
+ let facetMaps = {};
726
697
  //catagorised different facet items
727
698
  for (const i in event) {
728
- if (facetMaps[event[i][0]] === undefined) facetMaps[event[i][0]] = []
729
- facetMaps[event[i][0]].push(event[i])
699
+ if (facetMaps[event[i][0]] === undefined) facetMaps[event[i][0]] = [];
700
+ facetMaps[event[i][0]].push(event[i]);
730
701
  }
731
702
  // go through each facets
732
703
  for (const facet in facetMaps) {
733
- let showAll = undefined
704
+ let showAll = undefined;
734
705
  // Find the show all item if any
735
706
  for (let i = facetMaps[facet].length - 1; i >= 0; i--) {
736
707
  if (facetMaps[facet][i][1].toLowerCase().includes('show all')) {
737
708
  //seperate the showAll item and the rest
738
- showAll = facetMaps[facet].splice(i, 1)[0]
739
- break
709
+ showAll = facetMaps[facet].splice(i, 1)[0];
710
+ break;
740
711
  }
741
712
  }
742
713
  if (showAll) {
743
714
  if (this.previousShowAllChecked[facet]) {
744
715
  //Unset the show all if it was present previously
745
716
  //and there are other items
746
- if (facetMaps[facet].length > 0)
747
- modifiedEvent.push(...facetMaps[facet])
748
- else modifiedEvent.push(showAll)
717
+ if (facetMaps[facet].length > 0) modifiedEvent.push(...facetMaps[facet]);
718
+ else modifiedEvent.push(showAll);
749
719
  } else {
750
720
  //showAll is turned on
751
- modifiedEvent.push(showAll)
721
+ modifiedEvent.push(showAll);
752
722
  }
753
723
  } else {
754
- modifiedEvent.push(...facetMaps[facet])
724
+ modifiedEvent.push(...facetMaps[facet]);
755
725
  }
756
726
  }
757
727
  //Make sure the expanded item are sorted first.
@@ -759,31 +729,31 @@ export default {
759
729
  if (this.__expandItem__) {
760
730
  if (a[0] == this.__expandItem__) {
761
731
  if (b[0] == this.__expandItem__) {
762
- return 0
732
+ return 0;
763
733
  } else {
764
- return -1
734
+ return -1;
765
735
  }
766
736
  } else if (b[0] == this.__expandItem__) {
767
737
  if (a[0] == this.__expandItem__) {
768
- return 0
738
+ return 0;
769
739
  } else {
770
- return 1
740
+ return 1;
771
741
  }
772
742
  } else {
773
- return 0
743
+ return 0;
774
744
  }
775
- } else return 0
776
- })
745
+ } else return 0;
746
+ });
777
747
  }
778
- return event
748
+ return event;
779
749
  },
780
750
  cascadeExpandChange: function (event) {
781
751
  //work around as the expand item may change on modifying the cascade props
782
- this.__expandItem__ = event
752
+ this.__expandItem__ = event;
783
753
  if (this.__expandItem__) {
784
- this.updateListFilters(this.__expandItem__[0])
754
+ this.updateListFilters(this.__expandItem__[0]);
785
755
  }
786
- this.updateListStyleOrder()
756
+ this.updateListStyleOrder();
787
757
  },
788
758
  updateListStyleOrder: function () {
789
759
  this.$nextTick(() => {
@@ -803,7 +773,7 @@ export default {
803
773
  } else {
804
774
  ul.classList.remove('cascader-menu-with-search');
805
775
  }
806
- })
776
+ });
807
777
  }
808
778
  }
809
779
  });
@@ -856,17 +826,17 @@ export default {
856
826
  });
857
827
  },
858
828
  numberShownChanged: function (event) {
859
- this.$emit('numberPerPage', parseInt(event))
829
+ this.$emit('numberPerPage', parseInt(event));
860
830
  },
861
831
  updatePreviousShowAllChecked: function (options) {
862
832
  //Reset the states
863
833
  for (const facet in this.previousShowAllChecked) {
864
- this.previousShowAllChecked[facet] = false
834
+ this.previousShowAllChecked[facet] = false;
865
835
  }
866
836
  options.forEach((element) => {
867
837
  if (element[1].toLowerCase().includes('show all'))
868
- this.previousShowAllChecked[element[0]] = true
869
- })
838
+ this.previousShowAllChecked[element[0]] = true;
839
+ });
870
840
  },
871
841
  // setCascader: Clears previous selections and takes in an array of facets to select: filterFacets
872
842
  // facets are in the form:
@@ -884,71 +854,76 @@ export default {
884
854
  let filters = [
885
855
  e.facetPropPath,
886
856
  this.createCascaderItemValue([capitalise(e.term), e.facet]),
887
- ]
857
+ ];
888
858
  // Add the third level of the cascader if it exists
889
859
  if (e.facet2) {
890
- filters.push(
891
- this.createCascaderItemValue([capitalise(e.term), e.facet, e.facet2])
892
- )
860
+ filters.push(this.createCascaderItemValue([capitalise(e.term), e.facet, e.facet2]));
893
861
  if (e.facet3) {
894
862
  filters.push(
895
- this.createCascaderItemValue([capitalise(e.term), e.facet, e.facet2, e.facet3])
896
- )
863
+ this.createCascaderItemValue([capitalise(e.term), e.facet, e.facet2, e.facet3]),
864
+ );
897
865
  }
898
866
  }
899
867
  return filters;
900
- }
868
+ };
901
869
 
902
870
  this.cascadeSelected = filterFacets.map((e) => {
903
- let filters = createFilter(e)
904
- return filters
905
- })
871
+ let filters = createFilter(e);
872
+ return filters;
873
+ });
906
874
 
907
875
  // Unfortunately the cascader is very particular about it's v-model
908
876
  // to get around this we create a clone of it and use this clone for adding our boolean information
909
877
  this.cascadeSelectedWithBoolean = filterFacets.map((e) => {
910
- let filters = createFilter(e)
911
- filters.push(e.AND)
912
- return filters
913
- })
914
- this.updatePreviousShowAllChecked(this.cascadeSelected)
878
+ let filters = createFilter(e);
879
+ filters.push(e.AND);
880
+ return filters;
881
+ });
882
+ this.updatePreviousShowAllChecked(this.cascadeSelected);
915
883
  }
916
884
  this.tagsChangedCallback(filterFacets);
917
885
  },
918
886
  addFilter: function (filterToAdd) {
919
887
  //Do not set the value unless it is ready
920
888
  if (this.cascaderIsReady && filterToAdd) {
921
- let filters = this.validateAndConvertFilterToHierarchical(filterToAdd)
889
+ let filters = this.validateAndConvertFilterToHierarchical(filterToAdd);
922
890
  if (filters && filters.length) {
923
891
  filters.forEach((filter) => {
924
- this.cascadeSelected.filter((f) => f.term != filter.term)
892
+ this.cascadeSelected.filter((f) => f.term != filter.term);
925
893
  const paths = [
926
894
  filter.facetPropPath,
927
895
  this.createCascaderItemValue([filter.term, filter.facet]),
928
896
  this.createCascaderItemValue([filter.term, filter.facet, filter.facet2]),
929
- ]
897
+ ];
930
898
  if (filter.facet3) {
931
- paths.push(this.createCascaderItemValue([filter.term, filter.facet, filter.facet2, filter.facet3]))
899
+ paths.push(
900
+ this.createCascaderItemValue([
901
+ filter.term,
902
+ filter.facet,
903
+ filter.facet2,
904
+ filter.facet3,
905
+ ]),
906
+ );
932
907
  }
933
- this.cascadeSelected.push([...paths])
934
- this.cascadeSelectedWithBoolean.push([...paths, filter.AND])
908
+ this.cascadeSelected.push([...paths]);
909
+ this.cascadeSelectedWithBoolean.push([...paths, filter.AND]);
935
910
  // The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
936
911
  });
937
- return true
912
+ return true;
938
913
  }
939
914
  }
940
915
  },
941
916
  addFilters: function (filters) {
942
- let filterHasChanged = false
917
+ let filterHasChanged = false;
943
918
  if (this.cascaderIsReady) {
944
- filters.forEach(filter => {
945
- filterHasChanged = filterHasChanged || this.addFilter(filter)
946
- })
919
+ filters.forEach((filter) => {
920
+ filterHasChanged = filterHasChanged || this.addFilter(filter);
921
+ });
947
922
  }
948
- return filterHasChanged
923
+ return filterHasChanged;
949
924
  },
950
925
  initiateSearch: function () {
951
- this.cascadeEvent(this.cascadeSelectedWithBoolean)
926
+ this.cascadeEvent(this.cascadeSelectedWithBoolean);
952
927
  },
953
928
  // checkShowAllBoxes: Checks each 'Show all' cascade option by using the setCascader function
954
929
  checkShowAllBoxes: function () {
@@ -958,34 +933,35 @@ export default {
958
933
  facetPropPath: option.value,
959
934
  term: option.label,
960
935
  facet: 'Show all',
961
- }
962
- })
963
- )
936
+ };
937
+ }),
938
+ );
964
939
  },
965
940
  flattenToFilters: function (filter, targetOption, previousMatched = false) {
966
- let filtersArray = []
941
+ let filtersArray = [];
967
942
 
968
943
  if (targetOption) {
969
944
  // Convert terms to lower case.
970
945
  // Flatmap gives us Inferior vagus X ganglion but the term in Algolia
971
946
  // is Inferior vagus x ganglion (there are other cases as well)
972
- const facetLabel = filter.facet.toLowerCase()
973
- let nonSpecificFound = false
947
+ const facetLabel = filter.facet.toLowerCase();
948
+ let nonSpecificFound = false;
974
949
  for (const child of targetOption) {
975
- const isConnectivity = filter.facetPropPath.includes('flatmap.connectivity.source.') && child.key
976
- const labelMatched = isConnectivity ?
977
- child.key.replace(`${filter.facetPropPath}.`, '').toLowerCase() === facetLabel :
978
- child.label.toLowerCase() === facetLabel
950
+ const isConnectivity =
951
+ filter.facetPropPath.includes('flatmap.connectivity.source.') && child.key;
952
+ const labelMatched = isConnectivity
953
+ ? child.key.replace(`${filter.facetPropPath}.`, '').toLowerCase() === facetLabel
954
+ : child.label.toLowerCase() === facetLabel;
979
955
  if (child.children && child.children.length) {
980
- const matched = labelMatched || previousMatched
981
- const filters = this.flattenToFilters(filter, child.children, matched)
982
- filtersArray.push(...filters)
956
+ const matched = labelMatched || previousMatched;
957
+ const filters = this.flattenToFilters(filter, child.children, matched);
958
+ filtersArray.push(...filters);
983
959
  } else {
984
960
  // 'show all' or first item will be skipped
985
961
  if (child.facetPropPath || child.key) {
986
962
  const [term, facet, facet2, facet3] = child.value.split('>');
987
- if (facet3 === "Non specific") {
988
- nonSpecificFound = true
963
+ if (facet3 === 'Non specific') {
964
+ nonSpecificFound = true;
989
965
  }
990
966
  const fObject = {
991
967
  term,
@@ -995,14 +971,14 @@ export default {
995
971
  ...(facet3 && { facet3 }),
996
972
  };
997
973
  if ('AND' in filter) {
998
- fObject.AND = filter.AND
974
+ fObject.AND = filter.AND;
999
975
  }
1000
976
  // all the child fact will be checked if parent is matched
1001
977
  if (previousMatched || labelMatched) {
1002
978
  if (isConnectivity) {
1003
- filtersArray.push(filter)
979
+ filtersArray.push(filter);
1004
980
  } else {
1005
- filtersArray.push(fObject)
981
+ filtersArray.push(fObject);
1006
982
  }
1007
983
  }
1008
984
  }
@@ -1011,16 +987,16 @@ export default {
1011
987
  //Previously matched and Non specific found
1012
988
  if (previousMatched && nonSpecificFound) {
1013
989
  filtersArray = filtersArray.filter((item) => {
1014
- if (!item.facet3 || item.facet3 === "Non specific") {
1015
- return true
990
+ if (!item.facet3 || item.facet3 === 'Non specific') {
991
+ return true;
1016
992
  } else {
1017
- return false
993
+ return false;
1018
994
  }
1019
- })
995
+ });
1020
996
  }
1021
997
  }
1022
998
 
1023
- return filtersArray
999
+ return filtersArray;
1024
1000
  },
1025
1001
  /*
1026
1002
  * Given a filter, the function below returns the filter in the format of the cascader, returns false if facet is not found
@@ -1028,37 +1004,36 @@ export default {
1028
1004
  validateAndConvertFilterToHierarchical: function (filter) {
1029
1005
  if (filter && filter.facet && filter.term) {
1030
1006
  if (filter.facet2 || filter.facet3) {
1031
- return [filter] // if it has a second term we will assume it is hierarchical and return it as is
1007
+ return [filter]; // if it has a second term we will assume it is hierarchical and return it as is
1032
1008
  } else {
1033
- const option = this.options.find(option => option.label === filter.term)
1009
+ const option = this.options.find((option) => option.label === filter.term);
1034
1010
  if (option) {
1035
- const filters = this.flattenToFilters(filter, option.children)
1036
- return filters
1011
+ const filters = this.flattenToFilters(filter, option.children);
1012
+ return filters;
1037
1013
  }
1038
1014
  }
1039
1015
  }
1040
- return undefined
1016
+ return undefined;
1041
1017
  },
1042
1018
  getHierarchicalValidatedFilters: function (filters) {
1043
- const result = []
1044
- const terms = []
1045
- const notFound = []
1019
+ const result = [];
1020
+ const terms = [];
1021
+ const notFound = [];
1046
1022
 
1047
1023
  if (filters) {
1048
1024
  if (!this.cascaderIsReady) {
1049
1025
  return {
1050
1026
  result: filters,
1051
1027
  notFound: notFound,
1052
- }
1028
+ };
1053
1029
  }
1054
1030
 
1055
1031
  filters.forEach((filter) => {
1056
- const validatedFilters =
1057
- this.validateAndConvertFilterToHierarchical(filter)
1032
+ const validatedFilters = this.validateAndConvertFilterToHierarchical(filter);
1058
1033
  if (validatedFilters && validatedFilters.length) {
1059
- validatedFilters.forEach(validatedFilter => {
1060
- result.push(validatedFilter)
1061
- terms.push(validatedFilter.term)
1034
+ validatedFilters.forEach((validatedFilter) => {
1035
+ result.push(validatedFilter);
1036
+ terms.push(validatedFilter.term);
1062
1037
  });
1063
1038
  } else {
1064
1039
  const validOption = this.options.find((option) => {
@@ -1066,74 +1041,75 @@ export default {
1066
1041
  });
1067
1042
  if (validOption) {
1068
1043
  // not found items
1069
- notFound.push(filter)
1044
+ notFound.push(filter);
1070
1045
  }
1071
1046
  }
1072
- })
1047
+ });
1073
1048
 
1074
1049
  // make sure unused filter terms' show all checkbox is always checked
1075
- this.options.forEach((option)=>{
1050
+ this.options.forEach((option) => {
1076
1051
  if (!terms.includes(option.label)) {
1077
1052
  result.push({
1078
- facet: "Show all",
1053
+ facet: 'Show all',
1079
1054
  facetPropPath: option.key,
1080
- label: "Show all",
1081
- term: option.label
1082
- })
1055
+ label: 'Show all',
1056
+ term: option.label,
1057
+ });
1083
1058
  }
1084
- })
1059
+ });
1085
1060
  }
1086
1061
 
1087
1062
  return {
1088
1063
  result: result,
1089
1064
  notFound: notFound,
1090
- }
1065
+ };
1091
1066
  },
1092
- hasLineStyles: function(item) {
1093
- return 'colour' in item && item.colourStyle === 'line'
1067
+ hasLineStyles: function (item) {
1068
+ return 'colour' in item && item.colourStyle === 'line';
1094
1069
  },
1095
1070
  getLineStyles: function (item) {
1096
1071
  if ('colour' in item && item.colourStyle === 'line') {
1097
1072
  if ('dashed' in item && item.dashed === true) {
1098
- const background = `repeating-linear-gradient(90deg,${item.colour},${item.colour} 6px,transparent 0,transparent 9px)`
1099
- return { background }
1073
+ const background = `repeating-linear-gradient(90deg,${item.colour},${item.colour} 6px,transparent 0,transparent 9px)`;
1074
+ return { background };
1100
1075
  } else {
1101
- return { background: item.colour }
1076
+ return { background: item.colour };
1102
1077
  }
1103
1078
  }
1104
- return { display: 'None' }
1079
+ return { display: 'None' };
1105
1080
  },
1106
1081
  getBackgroundStyles: function (item) {
1107
1082
  if ('colour' in item && item.colourStyle === 'background') {
1108
- return { background: item.colour }
1083
+ return { background: item.colour };
1109
1084
  }
1110
- return {}
1085
+ return {};
1111
1086
  },
1112
1087
  },
1113
1088
  mounted: function () {
1114
1089
  // in populateCascader function,
1115
1090
  // algoliaClient run only when there are no this.entry.options
1116
1091
  if (!this.entry.options) {
1117
- this.algoliaClient = markRaw(new AlgoliaClient(
1118
- this.envVars.ALGOLIA_ID,
1119
- this.envVars.ALGOLIA_KEY,
1120
- this.envVars.PENNSIEVE_API_LOCATION
1121
- ))
1122
- this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX)
1123
- this.algoliaClient.setLocalStorageForTermMapping()
1092
+ this.algoliaClient = markRaw(
1093
+ new AlgoliaClient(
1094
+ this.envVars.ALGOLIA_ID,
1095
+ this.envVars.ALGOLIA_KEY,
1096
+ this.envVars.PENNSIEVE_API_LOCATION,
1097
+ ),
1098
+ );
1099
+ this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
1100
+ this.algoliaClient.setLocalStorageForTermMapping();
1124
1101
  }
1125
1102
  this.populateCascader().then(() => {
1126
- this.cascaderIsReady = true
1127
- this.checkShowAllBoxes()
1128
- this.setCascader(this.entry.filterFacets)
1129
- this.$emit('cascaderReady')
1130
- })
1103
+ this.cascaderIsReady = true;
1104
+ this.checkShowAllBoxes();
1105
+ this.setCascader(this.entry.filterFacets);
1106
+ this.$emit('cascaderReady');
1107
+ });
1131
1108
  },
1132
- }
1109
+ };
1133
1110
  </script>
1134
1111
 
1135
1112
  <style lang="scss" scoped>
1136
-
1137
1113
  .filters {
1138
1114
  position: relative;
1139
1115
  }
@@ -1250,7 +1226,7 @@ export default {
1250
1226
  }
1251
1227
 
1252
1228
  .dataset-results-feedback {
1253
- white-space:nowrap;
1229
+ white-space: nowrap;
1254
1230
  text-align: right;
1255
1231
  color: rgb(48, 49, 51);
1256
1232
  font-family: Asap;
@@ -1272,7 +1248,7 @@ export default {
1272
1248
  }
1273
1249
 
1274
1250
  .el-select-dropdown__item.is-selected {
1275
- color: #8300BF;
1251
+ color: #8300bf;
1276
1252
  }
1277
1253
 
1278
1254
  .filters :deep(.el-popover) {
@@ -1322,9 +1298,7 @@ export default {
1322
1298
  border-color: $app-primary-color;
1323
1299
  }
1324
1300
 
1325
- .sidebar-cascader-popper
1326
- .el-cascader-menu:nth-child(2)
1327
- .el-cascader-node:first-child {
1301
+ .sidebar-cascader-popper .el-cascader-menu:nth-child(2) .el-cascader-node:first-child {
1328
1302
  border-bottom: 1px solid #e4e7ed;
1329
1303
  }
1330
1304
 
@@ -1414,7 +1388,7 @@ export default {
1414
1388
  border-color: $app-primary-color !important;
1415
1389
  }
1416
1390
 
1417
- &[data-popper-placement^=bottom] .el-popper__arrow:before {
1391
+ &[data-popper-placement^='bottom'] .el-popper__arrow:before {
1418
1392
  border-bottom-color: transparent !important;
1419
1393
  border-right-color: transparent !important;
1420
1394
  }