@abi-software/map-side-bar 1.1.3 → 1.1.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +201 -201
- package/README.md +53 -44
- package/babel.config.js +14 -14
- package/dist/map-side-bar.common.js +666 -380
- package/dist/map-side-bar.common.js.map +1 -1
- package/dist/map-side-bar.css +1 -1
- package/dist/map-side-bar.umd.js +666 -380
- package/dist/map-side-bar.umd.js.map +1 -1
- package/dist/map-side-bar.umd.min.js +1 -1
- package/dist/map-side-bar.umd.min.js.map +1 -1
- package/package-lock.json +13669 -13431
- package/package.json +64 -62
- package/public/index.html +17 -17
- package/src/App.vue +112 -105
- package/src/algolia/algolia.js +98 -0
- package/src/algolia/utils.js +52 -0
- package/src/components/Cascader.vue +49 -49
- package/src/components/ContextCard.vue +95 -95
- package/src/components/DatasetCard.vue +372 -362
- package/src/components/EventBus.js +3 -3
- package/src/components/SearchFilters.vue +443 -434
- package/src/components/SideBar.vue +239 -234
- package/src/components/SidebarContent.vue +440 -454
- package/src/components/Tabs.vue +78 -78
- package/src/components/index.js +8 -8
- package/src/components/scaffold-meta-map.js +29 -29
- package/src/components/species-map.js +8 -8
- package/src/main.js +8 -8
- package/static.json +6 -6
- package/vue.config.js +11 -11
|
@@ -1,434 +1,443 @@
|
|
|
1
|
-
<template>
|
|
2
|
-
<div class="filters">
|
|
3
|
-
<SvgSpriteColor />
|
|
4
|
-
<transition name="el-zoom-in-top">
|
|
5
|
-
<span v-show="showFilters" class="search-filters transition-box">
|
|
6
|
-
<custom-cascader
|
|
7
|
-
class="cascader"
|
|
8
|
-
ref="cascader"
|
|
9
|
-
v-model="cascadeSelected"
|
|
10
|
-
placeholder
|
|
11
|
-
:collapse-tags="true"
|
|
12
|
-
:options="options"
|
|
13
|
-
:props="props"
|
|
14
|
-
@change="cascadeEvent($event)"
|
|
15
|
-
@expand-change="cascadeExpandChange"
|
|
16
|
-
:show-all-levels="false"
|
|
17
|
-
:append-to-body="false"
|
|
18
|
-
@tags-changed="tagsChangedCallback"
|
|
19
|
-
></custom-cascader>
|
|
20
|
-
<div v-if="showFiltersText" class="filter-default-value">
|
|
21
|
-
<svg-icon icon="noun-filter" class="filter-icon-inside" />Apply
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
import
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
locale
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
}
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
name
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
]
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
return
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
this.
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
}
|
|
173
|
-
},
|
|
174
|
-
//
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
},
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}
|
|
295
|
-
},
|
|
296
|
-
|
|
297
|
-
//Do not set the value unless it is ready
|
|
298
|
-
if (this.cascaderIsReady) {
|
|
299
|
-
this.cascadeSelected
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
this.
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
}
|
|
382
|
-
|
|
383
|
-
.cascader >>>
|
|
384
|
-
|
|
385
|
-
}
|
|
386
|
-
|
|
387
|
-
.
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
}
|
|
426
|
-
|
|
427
|
-
.
|
|
428
|
-
|
|
429
|
-
}
|
|
430
|
-
|
|
431
|
-
.
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
1
|
+
<template>
|
|
2
|
+
<div class="filters">
|
|
3
|
+
<SvgSpriteColor />
|
|
4
|
+
<transition name="el-zoom-in-top">
|
|
5
|
+
<span v-show="showFilters" class="search-filters transition-box">
|
|
6
|
+
<custom-cascader
|
|
7
|
+
class="cascader"
|
|
8
|
+
ref="cascader"
|
|
9
|
+
v-model="cascadeSelected"
|
|
10
|
+
placeholder
|
|
11
|
+
:collapse-tags="true"
|
|
12
|
+
:options="options"
|
|
13
|
+
:props="props"
|
|
14
|
+
@change="cascadeEvent($event)"
|
|
15
|
+
@expand-change="cascadeExpandChange"
|
|
16
|
+
:show-all-levels="false"
|
|
17
|
+
:append-to-body="false"
|
|
18
|
+
@tags-changed="tagsChangedCallback"
|
|
19
|
+
></custom-cascader>
|
|
20
|
+
<div v-if="showFiltersText" class="filter-default-value">
|
|
21
|
+
<svg-icon icon="noun-filter" class="filter-icon-inside" />Apply
|
|
22
|
+
Filters
|
|
23
|
+
</div>
|
|
24
|
+
</span>
|
|
25
|
+
</transition>
|
|
26
|
+
|
|
27
|
+
<el-select
|
|
28
|
+
class="number-shown-select"
|
|
29
|
+
v-model="numberShown"
|
|
30
|
+
placeholder="10"
|
|
31
|
+
@change="numberShownChanged($event)"
|
|
32
|
+
>
|
|
33
|
+
<el-option
|
|
34
|
+
v-for="item in numberDatasetsShown"
|
|
35
|
+
:key="item"
|
|
36
|
+
:label="item"
|
|
37
|
+
:value="item"
|
|
38
|
+
></el-option>
|
|
39
|
+
</el-select>
|
|
40
|
+
<span class="dataset-results-feedback">{{ this.numberOfResultsText }}</span>
|
|
41
|
+
</div>
|
|
42
|
+
</template>
|
|
43
|
+
|
|
44
|
+
|
|
45
|
+
<script>
|
|
46
|
+
/* eslint-disable no-alert, no-console */
|
|
47
|
+
import Vue from "vue";
|
|
48
|
+
import { Option, Select } from "element-ui";
|
|
49
|
+
import CustomCascader from "./Cascader";
|
|
50
|
+
import lang from "element-ui/lib/locale/lang/en";
|
|
51
|
+
import locale from "element-ui/lib/locale";
|
|
52
|
+
import speciesMap from "./species-map";
|
|
53
|
+
import { SvgIcon, SvgSpriteColor } from "@abi-software/svg-sprite";
|
|
54
|
+
|
|
55
|
+
import {AlgoliaClient} from "../algolia/algolia.js";
|
|
56
|
+
import { facetPropPathMapping } from "../algolia/utils.js";
|
|
57
|
+
|
|
58
|
+
Vue.component("svg-icon", SvgIcon);
|
|
59
|
+
|
|
60
|
+
locale.use(lang);
|
|
61
|
+
Vue.use(Option);
|
|
62
|
+
Vue.use(Select);
|
|
63
|
+
|
|
64
|
+
const capitalise = function (txt) {
|
|
65
|
+
return txt.charAt(0).toUpperCase() + txt.slice(1);
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const convertReadableLabel = function (original) {
|
|
69
|
+
const name = original.toLowerCase();
|
|
70
|
+
if (speciesMap[name]) {
|
|
71
|
+
return capitalise(speciesMap[name]);
|
|
72
|
+
} else {
|
|
73
|
+
return capitalise(name);
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
export default {
|
|
78
|
+
name: "SearchFilters",
|
|
79
|
+
components: {
|
|
80
|
+
CustomCascader,
|
|
81
|
+
SvgSpriteColor,
|
|
82
|
+
},
|
|
83
|
+
props: {
|
|
84
|
+
/**
|
|
85
|
+
* Object containing information for
|
|
86
|
+
* the required viewing.
|
|
87
|
+
*/
|
|
88
|
+
entry: Object,
|
|
89
|
+
envVars: {
|
|
90
|
+
type: Object,
|
|
91
|
+
default: ()=>{}
|
|
92
|
+
},
|
|
93
|
+
},
|
|
94
|
+
data: function () {
|
|
95
|
+
return {
|
|
96
|
+
cascaderIsReady: false,
|
|
97
|
+
previousShowAllChecked: {
|
|
98
|
+
species: false,
|
|
99
|
+
gender: false,
|
|
100
|
+
organ: false,
|
|
101
|
+
datasets: false,
|
|
102
|
+
},
|
|
103
|
+
showFilters: true,
|
|
104
|
+
showFiltersText: true,
|
|
105
|
+
cascadeSelected: [],
|
|
106
|
+
numberShown: 10,
|
|
107
|
+
filters: [],
|
|
108
|
+
facets: ["Species", "Gender", "Organ", "Datasets"],
|
|
109
|
+
numberDatasetsShown: ["10", "20", "50"],
|
|
110
|
+
props: { multiple: true },
|
|
111
|
+
options: [
|
|
112
|
+
{
|
|
113
|
+
value: "Species",
|
|
114
|
+
label: "Species",
|
|
115
|
+
children: [{}],
|
|
116
|
+
},
|
|
117
|
+
],
|
|
118
|
+
};
|
|
119
|
+
},
|
|
120
|
+
computed: {
|
|
121
|
+
numberOfResultsText: function () {
|
|
122
|
+
return `${this.entry.numberOfHits} results | Showing`;
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
methods: {
|
|
126
|
+
createCascaderItemValue: function (term, facet) {
|
|
127
|
+
if (facet) return term + "/" + facet;
|
|
128
|
+
else return term;
|
|
129
|
+
},
|
|
130
|
+
populateCascader: function () {
|
|
131
|
+
return new Promise((resolve) => {
|
|
132
|
+
// Algolia facet serach
|
|
133
|
+
this.algoliaClient.getAlgoliaFacets(facetPropPathMapping)
|
|
134
|
+
.then((data) => {
|
|
135
|
+
this.facets = data;
|
|
136
|
+
this.options = data;
|
|
137
|
+
|
|
138
|
+
// create top level of options in cascader
|
|
139
|
+
this.options.forEach((facet, i) => {
|
|
140
|
+
this.options[i].label = convertReadableLabel(facet.label);
|
|
141
|
+
this.options[i].value = this.createCascaderItemValue(
|
|
142
|
+
facet.key,
|
|
143
|
+
undefined
|
|
144
|
+
);
|
|
145
|
+
|
|
146
|
+
// put "Show all" as first option
|
|
147
|
+
this.options[i].children.unshift({
|
|
148
|
+
value: this.createCascaderItemValue("Show all"),
|
|
149
|
+
label: "Show all",
|
|
150
|
+
});
|
|
151
|
+
|
|
152
|
+
// populate second level of options
|
|
153
|
+
this.options[i].children.forEach((facetItem, j) => {
|
|
154
|
+
this.options[i].children[j].label = convertReadableLabel(
|
|
155
|
+
facetItem.label
|
|
156
|
+
);
|
|
157
|
+
this.options[i].children[j].value =
|
|
158
|
+
this.createCascaderItemValue(facet.label, facetItem.label);
|
|
159
|
+
});
|
|
160
|
+
});
|
|
161
|
+
})
|
|
162
|
+
.finally(() => {
|
|
163
|
+
resolve();
|
|
164
|
+
});
|
|
165
|
+
});
|
|
166
|
+
},
|
|
167
|
+
tagsChangedCallback: function (presentTags) {
|
|
168
|
+
if (presentTags.length > 0) {
|
|
169
|
+
this.showFiltersText = false;
|
|
170
|
+
} else {
|
|
171
|
+
this.showFiltersText = true;
|
|
172
|
+
}
|
|
173
|
+
},
|
|
174
|
+
// cascadeEvent: initiate searches based off cascader changes
|
|
175
|
+
cascadeEvent: function (event) {
|
|
176
|
+
if (event) {
|
|
177
|
+
// Check for show all in selected cascade options
|
|
178
|
+
event = this.showAllEventModifier(event);
|
|
179
|
+
|
|
180
|
+
// Move results from arrays to object
|
|
181
|
+
let filters = event.filter( selection => selection !== undefined).map( fs => ({
|
|
182
|
+
facetPropPath: fs[0],
|
|
183
|
+
facet: fs[1].split("/")[1],
|
|
184
|
+
term: fs[1].split("/")[0],
|
|
185
|
+
}))
|
|
186
|
+
|
|
187
|
+
this.$emit('loading', true) // let sidebarcontent wait for the requests
|
|
188
|
+
|
|
189
|
+
this.$emit("filterResults", filters); // emit filters for apps above sidebar
|
|
190
|
+
this.setCascader(filters); //update our cascader v-model if we modified the event
|
|
191
|
+
this.makeCascadeLabelsClickable();
|
|
192
|
+
}
|
|
193
|
+
},
|
|
194
|
+
// showAllEventModifier: Modifies a cascade event to unlick all selections in category if "show all" is clicked. Also unchecks "Show all" if any secection is clicked
|
|
195
|
+
// *NOTE* Does NOT remove 'Show all' selections from showing in 'cascadeSelected'
|
|
196
|
+
showAllEventModifier: function (event) {
|
|
197
|
+
// check if show all is in the cascader checked option list
|
|
198
|
+
let hasShowAll = event
|
|
199
|
+
.map((ev) => (ev ? ev[1].toLowerCase().includes("show all") : false))
|
|
200
|
+
.includes(true);
|
|
201
|
+
// remove all selected options below the show all if checked
|
|
202
|
+
if (hasShowAll) {
|
|
203
|
+
let modifiedEvent = [];
|
|
204
|
+
let facetMaps = {};
|
|
205
|
+
//catagorised different facet items
|
|
206
|
+
for (const i in event) {
|
|
207
|
+
if (facetMaps[event[i][0]] === undefined) facetMaps[event[i][0]] = [];
|
|
208
|
+
facetMaps[event[i][0]].push(event[i]);
|
|
209
|
+
}
|
|
210
|
+
// go through each facets
|
|
211
|
+
for (const facet in facetMaps) {
|
|
212
|
+
let showAll = undefined;
|
|
213
|
+
// Find the show all item if any
|
|
214
|
+
for (let i = facetMaps[facet].length - 1; i >= 0; i--) {
|
|
215
|
+
if (facetMaps[facet][i][1].toLowerCase().includes("show all")) {
|
|
216
|
+
//seperate the showAll item and the rest
|
|
217
|
+
showAll = facetMaps[facet].splice(i, 1)[0];
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
if (showAll) {
|
|
222
|
+
if (this.previousShowAllChecked[facet]) {
|
|
223
|
+
//Unset the show all if it was present previously
|
|
224
|
+
//and there are other items
|
|
225
|
+
if (facetMaps[facet].length > 0)
|
|
226
|
+
modifiedEvent.push(...facetMaps[facet]);
|
|
227
|
+
else modifiedEvent.push(showAll);
|
|
228
|
+
} else {
|
|
229
|
+
//showAll is turned on
|
|
230
|
+
modifiedEvent.push(showAll);
|
|
231
|
+
}
|
|
232
|
+
} else {
|
|
233
|
+
modifiedEvent.push(...facetMaps[facet]);
|
|
234
|
+
}
|
|
235
|
+
}
|
|
236
|
+
//Make sure the expanded item are sorted first.
|
|
237
|
+
return modifiedEvent.sort((a, b) => {
|
|
238
|
+
if (this.__expandItem__) {
|
|
239
|
+
if (a[0] == this.__expandItem__) {
|
|
240
|
+
if (b[0] == this.__expandItem__) {
|
|
241
|
+
return 0;
|
|
242
|
+
} else {
|
|
243
|
+
return -1;
|
|
244
|
+
}
|
|
245
|
+
} else if (b[0] == this.__expandItem__) {
|
|
246
|
+
if (a[0] == this.__expandItem__) {
|
|
247
|
+
return 0;
|
|
248
|
+
} else {
|
|
249
|
+
return 1;
|
|
250
|
+
}
|
|
251
|
+
} else {
|
|
252
|
+
return 0;
|
|
253
|
+
}
|
|
254
|
+
} else return 0;
|
|
255
|
+
});
|
|
256
|
+
}
|
|
257
|
+
return event;
|
|
258
|
+
},
|
|
259
|
+
cascadeExpandChange: function (event) {
|
|
260
|
+
//work around as the expand item may change on modifying the cascade props
|
|
261
|
+
this.__expandItem__ = event;
|
|
262
|
+
this.makeCascadeLabelsClickable();
|
|
263
|
+
},
|
|
264
|
+
numberShownChanged: function (event) {
|
|
265
|
+
this.$emit("numberPerPage", parseInt(event));
|
|
266
|
+
},
|
|
267
|
+
updatePreviousShowAllChecked: function (options) {
|
|
268
|
+
//Reset the states
|
|
269
|
+
for (const facet in this.previousShowAllChecked) {
|
|
270
|
+
this.previousShowAllChecked[facet] = false;
|
|
271
|
+
}
|
|
272
|
+
options.forEach((element) => {
|
|
273
|
+
if (element[1].toLowerCase().includes("show all"))
|
|
274
|
+
this.previousShowAllChecked[element[0]] = true;
|
|
275
|
+
});
|
|
276
|
+
},
|
|
277
|
+
// setCascader: Clears previous selections and takes in an array of facets to select: filterFacets
|
|
278
|
+
// facets are in the form:
|
|
279
|
+
// {
|
|
280
|
+
// facetPropPath: 'anatomy.organ.name',
|
|
281
|
+
// term: 'Sex',
|
|
282
|
+
// facet: 'Male'
|
|
283
|
+
// }
|
|
284
|
+
setCascader: function (filterFacets) {
|
|
285
|
+
//Do not set the value unless it is ready
|
|
286
|
+
if (this.cascaderIsReady && filterFacets && filterFacets.length != 0) {
|
|
287
|
+
this.cascadeSelected = filterFacets.map(e => {
|
|
288
|
+
return [
|
|
289
|
+
e.facetPropPath,
|
|
290
|
+
this.createCascaderItemValue(capitalise(e.term), e.facet),
|
|
291
|
+
]
|
|
292
|
+
});
|
|
293
|
+
this.updatePreviousShowAllChecked(this.cascadeSelected);
|
|
294
|
+
}
|
|
295
|
+
},
|
|
296
|
+
addFilter: function (filter) {
|
|
297
|
+
//Do not set the value unless it is ready
|
|
298
|
+
if (this.cascaderIsReady && filter) {
|
|
299
|
+
this.cascadeSelected.filter(f=>f.term != filter.term)
|
|
300
|
+
this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet)])
|
|
301
|
+
}
|
|
302
|
+
},
|
|
303
|
+
initiateSearch: function() {
|
|
304
|
+
this.cascadeEvent(this.cascadeSelected)
|
|
305
|
+
},
|
|
306
|
+
// checkShowAllBoxes: Checks each 'Show all' cascade option by using the setCascader function
|
|
307
|
+
checkShowAllBoxes: function(){
|
|
308
|
+
this.setCascader(
|
|
309
|
+
this.options.map(option => {
|
|
310
|
+
return {
|
|
311
|
+
facetPropPath: option.value,
|
|
312
|
+
term: option.label,
|
|
313
|
+
facet: 'Show all'
|
|
314
|
+
}
|
|
315
|
+
})
|
|
316
|
+
)
|
|
317
|
+
},
|
|
318
|
+
makeCascadeLabelsClickable: function () {
|
|
319
|
+
// Next tick allows the cascader menu to change
|
|
320
|
+
this.$nextTick(() => {
|
|
321
|
+
this.$refs.cascader.$el
|
|
322
|
+
.querySelectorAll(".el-cascader-node__label")
|
|
323
|
+
.forEach((el) => {
|
|
324
|
+
// step through each cascade label
|
|
325
|
+
el.onclick = function () {
|
|
326
|
+
const checkbox = this.previousElementSibling;
|
|
327
|
+
if (checkbox) {
|
|
328
|
+
if (!checkbox.parentElement.attributes["aria-owns"]) {
|
|
329
|
+
// check if we are at the lowest level of cascader
|
|
330
|
+
this.previousElementSibling.click(); // Click the checkbox
|
|
331
|
+
}
|
|
332
|
+
}
|
|
333
|
+
};
|
|
334
|
+
});
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
},
|
|
338
|
+
mounted: function () {
|
|
339
|
+
this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
|
|
340
|
+
this.algoliaClient.initIndex(this.envVars.ALGOLIA_INDEX);
|
|
341
|
+
this.populateCascader().then(() => {
|
|
342
|
+
this.cascaderIsReady = true;
|
|
343
|
+
this.checkShowAllBoxes()
|
|
344
|
+
this.setCascader(this.entry.filterFacets);
|
|
345
|
+
this.makeCascadeLabelsClickable();
|
|
346
|
+
});
|
|
347
|
+
},
|
|
348
|
+
};
|
|
349
|
+
</script>
|
|
350
|
+
|
|
351
|
+
<!-- Add "scoped" attribute to limit CSS to this component only -->
|
|
352
|
+
<style scoped>
|
|
353
|
+
.filter-default-value {
|
|
354
|
+
pointer-events: none;
|
|
355
|
+
position: absolute;
|
|
356
|
+
top: 0;
|
|
357
|
+
left: 0;
|
|
358
|
+
padding-top: 10px;
|
|
359
|
+
padding-left: 16px;
|
|
360
|
+
}
|
|
361
|
+
|
|
362
|
+
.filter-icon-inside {
|
|
363
|
+
width: 12px !important;
|
|
364
|
+
height: 12px !important;
|
|
365
|
+
color: #292b66;
|
|
366
|
+
transform: scale(2) !important;
|
|
367
|
+
margin-bottom: 0px !important;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
.cascader {
|
|
371
|
+
font-family: Asap;
|
|
372
|
+
font-size: 14px;
|
|
373
|
+
font-weight: 500;
|
|
374
|
+
font-stretch: normal;
|
|
375
|
+
font-style: normal;
|
|
376
|
+
line-height: normal;
|
|
377
|
+
letter-spacing: normal;
|
|
378
|
+
color: #292b66;
|
|
379
|
+
text-align: center;
|
|
380
|
+
padding-bottom: 6px;
|
|
381
|
+
}
|
|
382
|
+
|
|
383
|
+
.cascader >>> .el-cascder-panel {
|
|
384
|
+
max-height: 500px;
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
.cascader >>> .el-scrollbar__wrap {
|
|
388
|
+
overflow-x: hidden;
|
|
389
|
+
margin-bottom: 2px !important;
|
|
390
|
+
}
|
|
391
|
+
|
|
392
|
+
.cascader >>> li[aria-owns*="cascader"] > .el-checkbox {
|
|
393
|
+
display: none;
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
.dataset-results-feedback {
|
|
397
|
+
float: right;
|
|
398
|
+
text-align: right;
|
|
399
|
+
color: rgb(48, 49, 51);
|
|
400
|
+
font-family: Asap;
|
|
401
|
+
font-size: 18px;
|
|
402
|
+
font-weight: 500;
|
|
403
|
+
padding-top: 8px;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
.search-filters {
|
|
407
|
+
position: relative;
|
|
408
|
+
float: left;
|
|
409
|
+
padding-right: 15px;
|
|
410
|
+
padding-bottom: 12px;
|
|
411
|
+
}
|
|
412
|
+
|
|
413
|
+
.number-shown-select {
|
|
414
|
+
float: right;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
.number-shown-select >>> .el-input__inner {
|
|
418
|
+
width: 68px;
|
|
419
|
+
height: 40px;
|
|
420
|
+
color: rgb(48, 49, 51);
|
|
421
|
+
}
|
|
422
|
+
|
|
423
|
+
.search-filters >>> .el-cascader-node.is-active {
|
|
424
|
+
color: #8300bf;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
.search-filters >>> .el-cascader-node.in-active-path {
|
|
428
|
+
color: #8300bf;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
.search-filters >>> .el-checkbox__input.is-checked > .el-checkbox__inner {
|
|
432
|
+
background-color: #8300bf;
|
|
433
|
+
border-color: #8300bf;
|
|
434
|
+
}
|
|
435
|
+
|
|
436
|
+
.cascader >>> .el-cascader-menu:nth-child(2) .el-cascader-node:first-child {
|
|
437
|
+
border-bottom: 1px solid #e4e7ed;
|
|
438
|
+
}
|
|
439
|
+
|
|
440
|
+
.cascader >>> .el-cascader-node__label {
|
|
441
|
+
text-align: left;
|
|
442
|
+
}
|
|
443
|
+
</style>
|