@abi-software/map-side-bar 1.5.4-beta.hierarchy.2 → 1.5.4-beta.hierarchy.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/map-side-bar.common.js +334 -78
- 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 +334 -78
- 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 +2 -2
- package/package.json +1 -1
- package/src/components/SearchFilters.vue +24 -13
- package/src/components/SearchHistory.vue +148 -0
- package/src/components/SidebarContent.vue +11 -1
package/package-lock.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@abi-software/map-side-bar",
|
|
3
|
-
"version": "1.5.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"lockfileVersion": 1,
|
|
5
5
|
"requires": true,
|
|
6
6
|
"dependencies": {
|
|
@@ -12205,7 +12205,7 @@
|
|
|
12205
12205
|
"simple-html-tokenizer": {
|
|
12206
12206
|
"version": "0.1.1",
|
|
12207
12207
|
"resolved": "https://registry.npmjs.org/simple-html-tokenizer/-/simple-html-tokenizer-0.1.1.tgz",
|
|
12208
|
-
"integrity": "
|
|
12208
|
+
"integrity": "sha1-BcLuxXn//+FFoDCsJs/qYbmA+r4="
|
|
12209
12209
|
},
|
|
12210
12210
|
"simple-swizzle": {
|
|
12211
12211
|
"version": "0.2.2",
|
package/package.json
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
v-model="cascadeSelected"
|
|
10
10
|
placeholder
|
|
11
11
|
:collapse-tags="true"
|
|
12
|
+
collapse-tags-tooltip
|
|
12
13
|
:options="options"
|
|
13
14
|
:props="props"
|
|
14
15
|
@change="cascadeEvent($event)"
|
|
@@ -209,7 +210,6 @@ export default {
|
|
|
209
210
|
},
|
|
210
211
|
// cascadeEvent: initiate searches based off cascader changes
|
|
211
212
|
cascadeEvent: function (event) {
|
|
212
|
-
console.log('cascadeEvent:',event)
|
|
213
213
|
if (event) {
|
|
214
214
|
// Check for show all in selected cascade options
|
|
215
215
|
event = this.showAllEventModifier(event);
|
|
@@ -251,14 +251,13 @@ export default {
|
|
|
251
251
|
|
|
252
252
|
this.$emit("filterResults", filters); // emit filters for apps above sidebar
|
|
253
253
|
this.setCascader(filterKeys); //update our cascader v-model if we modified the event
|
|
254
|
-
this.
|
|
254
|
+
this.cssMods(); // update css for the cascader
|
|
255
255
|
}
|
|
256
256
|
},
|
|
257
257
|
//this fucntion is needed as we previously stored booleans in the array of event that
|
|
258
258
|
// are stored in the cascader
|
|
259
259
|
findHierarachyStringAndBooleanString(cascadeEventItem){
|
|
260
260
|
let hString, bString
|
|
261
|
-
console.log('cascadeEventItem:', cascadeEventItem)
|
|
262
261
|
if (cascadeEventItem.length >= 3){
|
|
263
262
|
if (cascadeEventItem[2] && cascadeEventItem[2].split('>').length > 2){
|
|
264
263
|
hString = cascadeEventItem[2]
|
|
@@ -355,7 +354,7 @@ export default {
|
|
|
355
354
|
cascadeExpandChange: function (event) {
|
|
356
355
|
//work around as the expand item may change on modifying the cascade props
|
|
357
356
|
this.__expandItem__ = event;
|
|
358
|
-
this.
|
|
357
|
+
this.cssMods();
|
|
359
358
|
},
|
|
360
359
|
numberShownChanged: function (event) {
|
|
361
360
|
this.$emit("numberPerPage", parseInt(event));
|
|
@@ -407,7 +406,6 @@ export default {
|
|
|
407
406
|
//Do not set the value unless it is ready
|
|
408
407
|
if (this.cascaderIsReady && filter) {
|
|
409
408
|
filter = this.validateAndConvertFilterToHierarchical(filter)
|
|
410
|
-
console.log('we got:', filter)
|
|
411
409
|
if (filter) {
|
|
412
410
|
this.cascadeSelected.filter(f=>f.term != filter.term)
|
|
413
411
|
this.cascadeSelected.push([filter.facetPropPath,this.createCascaderItemValue(filter.term, filter.facet), this.createCascaderItemValue(filter.term, filter.facet, filter.facet2)])
|
|
@@ -435,8 +433,8 @@ export default {
|
|
|
435
433
|
makeCascadeLabelsClickable: function () {
|
|
436
434
|
// Next tick allows the cascader menu to change
|
|
437
435
|
this.$nextTick(() => {
|
|
438
|
-
|
|
439
|
-
.querySelectorAll(".el-cascader-node__label")
|
|
436
|
+
document
|
|
437
|
+
.querySelectorAll(".sidebar-cascader-popper .el-cascader-node__label")
|
|
440
438
|
.forEach((el) => {
|
|
441
439
|
// step through each cascade label
|
|
442
440
|
el.onclick = function () {
|
|
@@ -452,11 +450,25 @@ export default {
|
|
|
452
450
|
});
|
|
453
451
|
},
|
|
454
452
|
|
|
453
|
+
cssMods: function (){
|
|
454
|
+
this.makeCascadeLabelsClickable();
|
|
455
|
+
this.removeTopLevelCascaderCheckboxes();
|
|
456
|
+
},
|
|
457
|
+
|
|
458
|
+
removeTopLevelCascaderCheckboxes: function () {
|
|
459
|
+
// Next tick allows the cascader menu to change
|
|
460
|
+
this.$nextTick(() => {
|
|
461
|
+
let cascadePanels = document.querySelectorAll(".sidebar-cascader-popper .el-cascader-menu__list");
|
|
462
|
+
// Hide the checkboxes on the first level of the cascader
|
|
463
|
+
cascadePanels[0].querySelectorAll('.el-checkbox__input').forEach(el=>el.style.display='none');
|
|
464
|
+
});
|
|
465
|
+
},
|
|
466
|
+
|
|
467
|
+
|
|
455
468
|
/*
|
|
456
469
|
* Given a filter, the function below returns the filter in the format of the cascader, returns false if facet is not found
|
|
457
470
|
*/
|
|
458
471
|
validateAndConvertFilterToHierarchical: function (filter) {
|
|
459
|
-
console.log('validateAndConvertFilterToHierarchical:', filter)
|
|
460
472
|
if (filter && filter.facet && filter.term) {
|
|
461
473
|
if (filter.facet2) {
|
|
462
474
|
return filter // if it has a second term we will assume it is hierarchical and return it as is
|
|
@@ -475,7 +487,6 @@ export default {
|
|
|
475
487
|
// and populate facet1 with its parents label.
|
|
476
488
|
filter.facet2 = thirdLayer.label
|
|
477
489
|
filter.facet = secondLayer.label
|
|
478
|
-
console.log('found it! returning:', filter)
|
|
479
490
|
return filter
|
|
480
491
|
}
|
|
481
492
|
}
|
|
@@ -513,7 +524,7 @@ export default {
|
|
|
513
524
|
this.cascaderIsReady = true;
|
|
514
525
|
this.checkShowAllBoxes();
|
|
515
526
|
this.setCascader(this.entry.filterFacets);
|
|
516
|
-
this.
|
|
527
|
+
this.cssMods();
|
|
517
528
|
this.$emit("cascaderReady");
|
|
518
529
|
});
|
|
519
530
|
},
|
|
@@ -583,7 +594,6 @@ export default {
|
|
|
583
594
|
position: relative;
|
|
584
595
|
float: left;
|
|
585
596
|
padding-right: 15px;
|
|
586
|
-
padding-bottom: 12px;
|
|
587
597
|
}
|
|
588
598
|
|
|
589
599
|
.number-shown-select {
|
|
@@ -686,7 +696,8 @@ export default {
|
|
|
686
696
|
margin-bottom: 2px !important;
|
|
687
697
|
}
|
|
688
698
|
|
|
689
|
-
.sidebar-cascader-popper
|
|
690
|
-
|
|
699
|
+
.sidebar-cascader-popper .el-checkbox__input.is-checked .el-checkbox__inner, .el-checkbox__input.is-indeterminate .el-checkbox__inner{
|
|
700
|
+
background-color: $app-primary-color;
|
|
701
|
+
border-color: $app-primary-color;
|
|
691
702
|
}
|
|
692
703
|
</style>
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
<template>
|
|
2
|
+
<div class="container">
|
|
3
|
+
<!-- <span v-if="reversedSearchHistory.length > 0" class="title"> Search History </span> -->
|
|
4
|
+
<template v-for="(item, i) in reversedSearchHistory">
|
|
5
|
+
<el-tag class="search-tag" v-if="i < 3" v-bind:key="i" @click="search(item)">{{ item.search }} </el-tag>
|
|
6
|
+
</template>
|
|
7
|
+
<el-select
|
|
8
|
+
v-if="reversedSearchHistory.length > 0"
|
|
9
|
+
:value="selectValue"
|
|
10
|
+
class="m-2 search-select"
|
|
11
|
+
placeholder="Full search History"
|
|
12
|
+
size="small"
|
|
13
|
+
popper-class="sidebar-search-select-popper"
|
|
14
|
+
@change="selectChange"
|
|
15
|
+
>
|
|
16
|
+
<el-option
|
|
17
|
+
v-for="(item, i) in cascaderOptions"
|
|
18
|
+
:key="i"
|
|
19
|
+
:label="item.label"
|
|
20
|
+
:value="item.value"
|
|
21
|
+
/>
|
|
22
|
+
</el-select>
|
|
23
|
+
</div>
|
|
24
|
+
|
|
25
|
+
</template>
|
|
26
|
+
|
|
27
|
+
<script>
|
|
28
|
+
/* eslint-disable no-alert, no-console */
|
|
29
|
+
import Vue from "vue";
|
|
30
|
+
import {
|
|
31
|
+
Tag,
|
|
32
|
+
Select,
|
|
33
|
+
} from "element-ui";
|
|
34
|
+
|
|
35
|
+
Vue.use(Tag);
|
|
36
|
+
Vue.use(Select);
|
|
37
|
+
import EventBus from './EventBus';
|
|
38
|
+
|
|
39
|
+
// remove duplicates by stringifying the objects
|
|
40
|
+
const removeDuplicates = function(arrayOfAnything){
|
|
41
|
+
return [...new Set(arrayOfAnything.map(e => JSON.stringify(e)))].map(e => JSON.parse(e))
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export default {
|
|
45
|
+
name: 'SearchHistory',
|
|
46
|
+
data() {
|
|
47
|
+
return {
|
|
48
|
+
searchHistory: [],
|
|
49
|
+
selectValue: 'Full search history'
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
},
|
|
53
|
+
computed: {
|
|
54
|
+
reversedSearchHistory: function(){
|
|
55
|
+
return removeDuplicates(this.searchHistory.slice().reverse().filter(item => item.search !== ''))
|
|
56
|
+
},
|
|
57
|
+
cascaderOptions: function(){
|
|
58
|
+
return this.reversedSearchHistory.map(item => {
|
|
59
|
+
return {
|
|
60
|
+
value: item.search,
|
|
61
|
+
label: item.search
|
|
62
|
+
}
|
|
63
|
+
})
|
|
64
|
+
}
|
|
65
|
+
},
|
|
66
|
+
methods: {
|
|
67
|
+
getSearchHistory() {
|
|
68
|
+
if (localStorage.getItem('sparc.science-sidebar-search-history')) {
|
|
69
|
+
this.searchHistory = JSON.parse(localStorage.getItem('sparc.science-sidebar-search-history'));
|
|
70
|
+
} else {
|
|
71
|
+
this.searchHistory = [];
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
clearSearchHistory() {
|
|
75
|
+
localStorage.removeItem('sparc.science-sidebar-search-history');
|
|
76
|
+
this.searchHistory = [];
|
|
77
|
+
},
|
|
78
|
+
addSearchToHistory(filters, search) {
|
|
79
|
+
filters = [] // disable filters for now
|
|
80
|
+
search = search.trim() // remove whitespace
|
|
81
|
+
let searchHistory = JSON.parse(localStorage.getItem('sparc.science-sidebar-search-history'));
|
|
82
|
+
if (searchHistory) {
|
|
83
|
+
searchHistory.push({filters: filters, search: search});
|
|
84
|
+
this.searchHistory = removeDuplicates(searchHistory)
|
|
85
|
+
localStorage.setItem('sparc.science-sidebar-search-history', JSON.stringify(searchHistory));
|
|
86
|
+
} else {
|
|
87
|
+
localStorage.setItem('sparc.science-sidebar-search-history', JSON.stringify([{filters: filters, search: search}]));
|
|
88
|
+
}
|
|
89
|
+
},
|
|
90
|
+
search: function(item) {
|
|
91
|
+
this.$emit("search", item);
|
|
92
|
+
},
|
|
93
|
+
selectChange: function(value) {
|
|
94
|
+
this.selectValue = value;
|
|
95
|
+
this.search({search: value})
|
|
96
|
+
}
|
|
97
|
+
},
|
|
98
|
+
mounted: function () {
|
|
99
|
+
this.getSearchHistory();
|
|
100
|
+
EventBus.$on('search-changed', (data) => {
|
|
101
|
+
this.setSearchHistory(data);
|
|
102
|
+
})
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
</script>
|
|
106
|
+
|
|
107
|
+
<style scoped lang="scss">
|
|
108
|
+
@import "~element-ui/packages/theme-chalk/src/tag";
|
|
109
|
+
|
|
110
|
+
.container {
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
.search-tag {
|
|
114
|
+
margin: 0 5px 5px 0;
|
|
115
|
+
cursor: pointer;
|
|
116
|
+
max-width: 100px;
|
|
117
|
+
overflow: hidden;
|
|
118
|
+
text-overflow: ellipsis;
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
.title {
|
|
122
|
+
font-size: 14px;
|
|
123
|
+
font-weight: bold;
|
|
124
|
+
margin-right: 5px;
|
|
125
|
+
// center text vertically
|
|
126
|
+
display: flex;
|
|
127
|
+
align-items: center;
|
|
128
|
+
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
.search-select {
|
|
132
|
+
float: right;
|
|
133
|
+
}
|
|
134
|
+
</style>
|
|
135
|
+
|
|
136
|
+
<style lang="scss">
|
|
137
|
+
.sidebar-search-select-popper {
|
|
138
|
+
font-family: Asap;
|
|
139
|
+
font-size: 14px;
|
|
140
|
+
font-weight: 500;
|
|
141
|
+
font-stretch: normal;
|
|
142
|
+
font-style: normal;
|
|
143
|
+
line-height: normal;
|
|
144
|
+
letter-spacing: normal;
|
|
145
|
+
color: #292b66;
|
|
146
|
+
max-width: 200px;
|
|
147
|
+
}
|
|
148
|
+
</style>
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
@loading="filtersLoading"
|
|
22
22
|
@cascaderReady="cascaderReady"
|
|
23
23
|
></SearchFilters>
|
|
24
|
+
<search-history ref="searchHistory" @search="searchHistorySearch"></search-history>
|
|
24
25
|
<div class="content scrollbar" v-loading="loadingCards" ref="content">
|
|
25
26
|
<div class="error-feedback" v-if="results.length === 0 && !loadingCards">
|
|
26
27
|
No results found - Please change your search / filter criteria.
|
|
@@ -61,6 +62,7 @@ import {
|
|
|
61
62
|
import lang from "element-ui/lib/locale/lang/en";
|
|
62
63
|
import locale from "element-ui/lib/locale";
|
|
63
64
|
import SearchFilters from "./SearchFilters";
|
|
65
|
+
import SearchHistory from "./SearchHistory";
|
|
64
66
|
import DatasetCard from "./DatasetCard";
|
|
65
67
|
import EventBus from "./EventBus";
|
|
66
68
|
|
|
@@ -106,7 +108,7 @@ var initial_state = {
|
|
|
106
108
|
};
|
|
107
109
|
|
|
108
110
|
export default {
|
|
109
|
-
components: { SearchFilters, DatasetCard },
|
|
111
|
+
components: { SearchFilters, DatasetCard, SearchHistory },
|
|
110
112
|
name: "SideBarContent",
|
|
111
113
|
props: {
|
|
112
114
|
visible: {
|
|
@@ -207,11 +209,14 @@ export default {
|
|
|
207
209
|
this.searchInput = "";
|
|
208
210
|
this.resetPageNavigation();
|
|
209
211
|
this.searchAlgolia(this.filters, this.searchInput);
|
|
212
|
+
this.$refs.searchHistory.selectValue = 'Full search history'
|
|
210
213
|
},
|
|
211
214
|
searchEvent: function (event = false) {
|
|
212
215
|
if (event.keyCode === 13 || event instanceof MouseEvent) {
|
|
213
216
|
this.resetPageNavigation();
|
|
214
217
|
this.searchAlgolia(this.filters, this.searchInput);
|
|
218
|
+
this.$refs.searchHistory.selectValue = 'Full search history'
|
|
219
|
+
this.$refs.searchHistory.addSearchToHistory(this.filters, this.searchInput);
|
|
215
220
|
}
|
|
216
221
|
},
|
|
217
222
|
filterUpdate: function (filters) {
|
|
@@ -408,6 +413,11 @@ export default {
|
|
|
408
413
|
getAlgoliaFacets: async function(){
|
|
409
414
|
let facets = await this.algoliaClient.getAlgoliaFacets(facetPropPathMapping)
|
|
410
415
|
return facets;
|
|
416
|
+
},
|
|
417
|
+
searchHistorySearch: function(item){
|
|
418
|
+
this.searchInput = item.search;
|
|
419
|
+
this.filters = item.filters;
|
|
420
|
+
this.openSearch(item.filters, item.search);
|
|
411
421
|
}
|
|
412
422
|
},
|
|
413
423
|
mounted: function () {
|