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