@abi-software/map-side-bar 2.5.3-beta.1 → 2.5.3-beta.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/map-side-bar.js +7425 -7424
- package/dist/map-side-bar.umd.cjs +110 -110
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/components/SearchHistory.vue +46 -7
- package/src/components/SidebarContent.vue +23 -5
- package/src/components.d.ts +0 -2
package/package.json
CHANGED
|
@@ -48,13 +48,17 @@
|
|
|
48
48
|
popper-class="popover-dropdown"
|
|
49
49
|
>
|
|
50
50
|
<template #reference>
|
|
51
|
-
|
|
51
|
+
<span class="dropdown-clickable-item" @click="search(item)">
|
|
52
|
+
{{ item.label }}
|
|
53
|
+
</span>
|
|
52
54
|
</template>
|
|
53
55
|
{{ item.longLabel }}
|
|
54
56
|
</el-popover>
|
|
55
57
|
</template>
|
|
56
58
|
<template v-else>
|
|
57
|
-
|
|
59
|
+
<span class="dropdown-clickable-item" @click="search(item)">
|
|
60
|
+
{{ item.label }}
|
|
61
|
+
</span>
|
|
58
62
|
</template>
|
|
59
63
|
</div>
|
|
60
64
|
<div>
|
|
@@ -71,8 +75,20 @@
|
|
|
71
75
|
:disabled="savedSearchHistory.length > 1 && !item.saved"
|
|
72
76
|
>
|
|
73
77
|
<el-icon color="#8300BF">
|
|
74
|
-
<
|
|
75
|
-
|
|
78
|
+
<template v-if="item.saved">
|
|
79
|
+
<svg
|
|
80
|
+
viewBox="0 0 24 24"
|
|
81
|
+
>
|
|
82
|
+
<path d="m12 21.35-1.45-1.32C5.4 15.36 2 12.28 2 8.5 2 5.42 4.42 3 7.5 3c1.74 0 3.41.81 4.5 2.09C13.09 3.81 14.76 3 16.5 3 19.58 3 22 5.42 22 8.5c0 3.78-3.4 6.86-8.55 11.54z"></path>
|
|
83
|
+
</svg>
|
|
84
|
+
</template>
|
|
85
|
+
<template v-else>
|
|
86
|
+
<svg
|
|
87
|
+
viewBox="0 0 24 24"
|
|
88
|
+
>
|
|
89
|
+
<path d="M16.5 3c-1.74 0-3.41.81-4.5 2.09C10.91 3.81 9.24 3 7.5 3 4.42 3 2 5.42 2 8.5c0 3.78 3.4 6.86 8.55 11.54L12 21.35l1.45-1.32C18.6 15.36 22 12.28 22 8.5 22 5.42 19.58 3 16.5 3m-4.4 15.55-.1.1-.1-.1C7.14 14.24 4 11.39 4 8.5 4 6.5 5.5 5 7.5 5c1.54 0 3.04.99 3.57 2.36h1.87C13.46 5.99 14.96 5 16.5 5c2 0 3.5 1.5 3.5 3.5 0 2.89-3.14 5.74-7.9 10.05"></path>
|
|
90
|
+
</svg>
|
|
91
|
+
</template>
|
|
76
92
|
</el-icon>
|
|
77
93
|
</el-button>
|
|
78
94
|
</template>
|
|
@@ -94,7 +110,9 @@
|
|
|
94
110
|
popper-class="popover-dropdown"
|
|
95
111
|
>
|
|
96
112
|
<template #reference>
|
|
97
|
-
<el-button circle text size="small"
|
|
113
|
+
<el-button circle text size="small"
|
|
114
|
+
@click="removeFromSavedSearch(item)"
|
|
115
|
+
>
|
|
98
116
|
<el-icon color="#8300BF">
|
|
99
117
|
<el-icon-delete />
|
|
100
118
|
</el-icon>
|
|
@@ -171,12 +189,15 @@ export default {
|
|
|
171
189
|
localStorage.removeItem('sparc.science-sidebar-search-history')
|
|
172
190
|
this.searchHistory = []
|
|
173
191
|
},
|
|
192
|
+
sortFilters(a, b) {
|
|
193
|
+
return a.facetPropPath.localeCompare(b.facetPropPath);
|
|
194
|
+
},
|
|
174
195
|
addSearchToHistory(filters = [], search = '') {
|
|
175
196
|
search = search.trim() // remove whitespace
|
|
176
197
|
|
|
177
198
|
const isExistingItem = this.searchHistory.some((item) => (
|
|
178
199
|
item.search === search &&
|
|
179
|
-
JSON.stringify(item.filters) === JSON.stringify(filters)
|
|
200
|
+
JSON.stringify(item.filters.sort(this.sortFilters)) === JSON.stringify(filters.sort(this.sortFilters))
|
|
180
201
|
));
|
|
181
202
|
|
|
182
203
|
if (!isExistingItem) {
|
|
@@ -206,14 +227,25 @@ export default {
|
|
|
206
227
|
if (!item.id) {
|
|
207
228
|
item['id'] = generateUUID();
|
|
208
229
|
}
|
|
230
|
+
|
|
209
231
|
if (!item.label) {
|
|
210
232
|
const {label, longLabel} = this.searchHistoryItemLabel(item.search, item.filters);
|
|
211
233
|
item['label'] = label;
|
|
212
234
|
item['longLabel'] = longLabel;
|
|
213
235
|
}
|
|
236
|
+
|
|
237
|
+
// filters won't work correctly with facet2
|
|
238
|
+
item.filters.forEach((filter) => {
|
|
239
|
+
if (filter.facet2) {
|
|
240
|
+
filter['facet'] = filter.facet2;
|
|
241
|
+
delete filter.facet2;
|
|
242
|
+
}
|
|
243
|
+
});
|
|
244
|
+
|
|
214
245
|
if (!item.saved) {
|
|
215
246
|
item['saved'] = false;
|
|
216
247
|
}
|
|
248
|
+
|
|
217
249
|
if (!item.updated) {
|
|
218
250
|
item['updated'] = (new Date()).getTime();
|
|
219
251
|
}
|
|
@@ -351,7 +383,6 @@ export default {
|
|
|
351
383
|
transition: var(--el-transition-duration);
|
|
352
384
|
transform: translateZ(0);
|
|
353
385
|
box-shadow: 0 0 0 1px var(--el-border-color) inset;
|
|
354
|
-
cursor: pointer;
|
|
355
386
|
}
|
|
356
387
|
|
|
357
388
|
.el-dropdown-select {
|
|
@@ -385,6 +416,14 @@ export default {
|
|
|
385
416
|
overflow: hidden;
|
|
386
417
|
}
|
|
387
418
|
|
|
419
|
+
.dropdown-clickable-item {
|
|
420
|
+
cursor: pointer;
|
|
421
|
+
|
|
422
|
+
&:hover {
|
|
423
|
+
color: $app-primary-color;
|
|
424
|
+
}
|
|
425
|
+
}
|
|
426
|
+
|
|
388
427
|
+ .el-dropdown-menu__item {
|
|
389
428
|
&::before {
|
|
390
429
|
content: "";
|
|
@@ -173,7 +173,7 @@ export default {
|
|
|
173
173
|
this.results = []
|
|
174
174
|
this.loadingCards = false
|
|
175
175
|
},
|
|
176
|
-
openSearch: function (filter, search = '') {
|
|
176
|
+
openSearch: function (filter, search = '', option = { withSearch: true }) {
|
|
177
177
|
this.searchInput = search
|
|
178
178
|
this.resetPageNavigation()
|
|
179
179
|
//Proceed normally if cascader is ready
|
|
@@ -192,14 +192,16 @@ export default {
|
|
|
192
192
|
this.$refs.filtersRef.checkShowAllBoxes()
|
|
193
193
|
this.resetSearch()
|
|
194
194
|
} else if (this.filter) {
|
|
195
|
-
|
|
195
|
+
if (option.withSearch) {
|
|
196
|
+
this.searchAlgolia(this.filter, search)
|
|
197
|
+
}
|
|
196
198
|
this.$refs.filtersRef.setCascader(this.filter)
|
|
197
199
|
}
|
|
198
200
|
} else {
|
|
199
201
|
//cascader is not ready, perform search if no filter is set,
|
|
200
202
|
//otherwise waith for cascader to be ready
|
|
201
203
|
this.filter = filter
|
|
202
|
-
if (!filter || filter.length == 0) {
|
|
204
|
+
if ((!filter || filter.length == 0) && option.withSearch) {
|
|
203
205
|
this.searchAlgolia(this.filter, search)
|
|
204
206
|
}
|
|
205
207
|
}
|
|
@@ -242,9 +244,23 @@ export default {
|
|
|
242
244
|
type: 'filter-update',
|
|
243
245
|
})
|
|
244
246
|
},
|
|
247
|
+
/**
|
|
248
|
+
* Transform filters for third level items to perform search
|
|
249
|
+
* because cascader keeps adding it back.
|
|
250
|
+
*/
|
|
251
|
+
transformFiltersBeforeSearch: function (filters) {
|
|
252
|
+
return filters.map((filter) => {
|
|
253
|
+
if (filter.facet2) {
|
|
254
|
+
filter.facet = filter.facet2;
|
|
255
|
+
delete filter.facet2;
|
|
256
|
+
}
|
|
257
|
+
return filter;
|
|
258
|
+
});
|
|
259
|
+
},
|
|
245
260
|
searchAndFilterUpdate: function () {
|
|
246
261
|
this.resetPageNavigation();
|
|
247
|
-
this.
|
|
262
|
+
const transformedFilters = this.transformFiltersBeforeSearch(this.filters);
|
|
263
|
+
this.searchAlgolia(transformedFilters, this.searchInput);
|
|
248
264
|
this.$refs.searchHistory.selectValue = 'Search history';
|
|
249
265
|
// save history only if there has value
|
|
250
266
|
if (this.filters.length || this.searchInput?.trim()) {
|
|
@@ -445,7 +461,9 @@ export default {
|
|
|
445
461
|
searchHistorySearch: function (item) {
|
|
446
462
|
this.searchInput = item.search
|
|
447
463
|
this.filters = item.filters
|
|
448
|
-
this.
|
|
464
|
+
this.searchAndFilterUpdate();
|
|
465
|
+
// withSearch: false to prevent algoliaSearch in openSearch
|
|
466
|
+
this.openSearch([...item.filters], item.search, { withSearch: false });
|
|
449
467
|
},
|
|
450
468
|
},
|
|
451
469
|
mounted: function () {
|
package/src/components.d.ts
CHANGED
|
@@ -25,8 +25,6 @@ declare module 'vue' {
|
|
|
25
25
|
ElIconArrowRight: typeof import('@element-plus/icons-vue')['ArrowRight']
|
|
26
26
|
ElIconDelete: typeof import('@element-plus/icons-vue')['Delete']
|
|
27
27
|
ElIconLocation: typeof import('@element-plus/icons-vue')['Location']
|
|
28
|
-
ElIconStar: typeof import('@element-plus/icons-vue')['Star']
|
|
29
|
-
ElIconStarFilled: typeof import('@element-plus/icons-vue')['StarFilled']
|
|
30
28
|
ElIconWarning: typeof import('@element-plus/icons-vue')['Warning']
|
|
31
29
|
ElIconWarnTriangleFilled: typeof import('@element-plus/icons-vue')['WarnTriangleFilled']
|
|
32
30
|
ElInput: typeof import('element-plus/es')['ElInput']
|