@abi-software/map-side-bar 1.3.7 → 1.3.10
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 +123 -103
- 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 +123 -103
- 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.json +1 -1
- package/src/App.vue +9 -2
- package/src/algolia/algolia.js +4 -4
- package/src/algolia/utils.js +14 -7
- package/src/components/SearchFilters.vue +21 -2
- package/src/components/SideBar.vue +1 -1
- package/src/components/SidebarContent.vue +2 -2
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -4,7 +4,8 @@
|
|
|
4
4
|
href="https://fonts.googleapis.com/css?family=Asap:400,400i,500,600,700&display=swap">
|
|
5
5
|
Click arrow to open sidebar
|
|
6
6
|
<el-button @click="openSearch">search 'heart' from refs</el-button>
|
|
7
|
-
<el-button @click="singleFacets">Add to Filter</el-button>
|
|
7
|
+
<el-button @click="singleFacets">Add heart to Filter</el-button>
|
|
8
|
+
<el-button @click="addStomach">Add stomach to Filter</el-button>
|
|
8
9
|
<el-button @click="multiFacets">multiple facets</el-button>
|
|
9
10
|
<el-button @click="neuronSearch">open neuron search</el-button>
|
|
10
11
|
<el-button @click="keywordSearch">keyword search</el-button>
|
|
@@ -109,7 +110,10 @@ export default {
|
|
|
109
110
|
this.$refs.sideBar.openSearch([], 'heart')
|
|
110
111
|
},
|
|
111
112
|
singleFacets: function(){
|
|
112
|
-
this.$refs.sideBar.addFilter({facet: 'Heart', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name'})
|
|
113
|
+
this.$refs.sideBar.addFilter({facet: 'Heart', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND: true})
|
|
114
|
+
},
|
|
115
|
+
addStomach: function(){
|
|
116
|
+
this.$refs.sideBar.addFilter({facet: 'Stomach', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND: true})
|
|
113
117
|
},
|
|
114
118
|
multiFacets: function(){
|
|
115
119
|
this.$refs.sideBar.openSearch([{facet: 'Male', term:'Sex', facetPropPath:'attributes.subject.sex.value'}, {facet: 'Heart', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name'}], '')
|
|
@@ -117,6 +121,9 @@ export default {
|
|
|
117
121
|
keywordSearch: function(){
|
|
118
122
|
this.$refs.sideBar.openSearch([{facet: 'http://purl.obolibrary.org/obo/UBERON_0001103', term:'Keywords', facetPropPath:'item.keywords.keyword'}])
|
|
119
123
|
},
|
|
124
|
+
markerFromFlatmap: function(){
|
|
125
|
+
this.$refs.sideBar.openSearch([{facet: 'http://purl.obolibrary.org/obo/UBERON_0001103', term:'Keywords', facetPropPath:'item.keywords.keyword'}])
|
|
126
|
+
},
|
|
120
127
|
neuronSearch: function(){
|
|
121
128
|
this.$refs.sideBar.openNeuronSearch('ilxtr:neuron-type-keast-10')
|
|
122
129
|
}
|
package/src/algolia/algolia.js
CHANGED
|
@@ -92,7 +92,7 @@ export class AlgoliaClient {
|
|
|
92
92
|
return newResults
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
|
|
95
|
+
_processAnatomy(hits) {
|
|
96
96
|
let foundKeyWords = []
|
|
97
97
|
let uniqueKeywords = []
|
|
98
98
|
hits.forEach(hit => {
|
|
@@ -161,7 +161,7 @@ export class AlgoliaClient {
|
|
|
161
161
|
* Get key words
|
|
162
162
|
* This is used to return all keywords for a given search. Note that you often want the hits per page to be maxed out
|
|
163
163
|
*/
|
|
164
|
-
|
|
164
|
+
anatomyInSearch(filter, query = '', hitsperPage = 999999, page = 1) {
|
|
165
165
|
return new Promise(resolve => {
|
|
166
166
|
this.index
|
|
167
167
|
.search(query, {
|
|
@@ -176,8 +176,8 @@ export class AlgoliaClient {
|
|
|
176
176
|
],
|
|
177
177
|
})
|
|
178
178
|
.then(response => {
|
|
179
|
-
let
|
|
180
|
-
resolve(
|
|
179
|
+
let anatomyAsUberons = this._processAnatomy(response.hits)
|
|
180
|
+
resolve(anatomyAsUberons)
|
|
181
181
|
})
|
|
182
182
|
})
|
|
183
183
|
}
|
package/src/algolia/utils.js
CHANGED
|
@@ -11,6 +11,7 @@ export const facetPropPathMapping = {
|
|
|
11
11
|
'item.keywords.keyword' : 'Keywords'
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
+
// Same as above, but these show on the sidebar filters
|
|
14
15
|
export const shownFilters = {
|
|
15
16
|
'anatomy.organ.name' : 'Anatomical Structure',
|
|
16
17
|
'organisms.primary.species.name' : 'Species',
|
|
@@ -39,18 +40,24 @@ export function getFilters(selectedFacetArray=undefined) {
|
|
|
39
40
|
|
|
40
41
|
const facetPropPaths = Object.keys(facetPropPathMapping);
|
|
41
42
|
facetPropPaths.map((facetPropPath) => {
|
|
42
|
-
const
|
|
43
|
+
const facetsToBool = facets.filter(
|
|
43
44
|
(facet) => facet.facetPropPath == facetPropPath
|
|
44
45
|
);
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
46
|
+
let orFilters = "";
|
|
47
|
+
let andFilters = "";
|
|
48
|
+
facetsToBool.map((facet) => {
|
|
49
|
+
if (facet.AND){
|
|
50
|
+
andFilters += `AND "${facetPropPath}":"${facet.label}"`;
|
|
51
|
+
} else {
|
|
52
|
+
orFilters += `"${facetPropPath}":"${facet.label}" OR `;
|
|
53
|
+
}
|
|
48
54
|
});
|
|
49
|
-
if (
|
|
55
|
+
if (orFilters == "" && andFilters =="") {
|
|
50
56
|
return;
|
|
51
57
|
}
|
|
52
|
-
|
|
53
|
-
filters += `${
|
|
58
|
+
orFilters = `(${orFilters.substring(0, orFilters.lastIndexOf(" OR "))})` // remove last OR
|
|
59
|
+
filters += `${orFilters + andFilters} AND `; // Put them together
|
|
60
|
+
// (Note that we add an extra AND in case there are facets at a higher level)
|
|
54
61
|
});
|
|
55
62
|
return filters.substring(0, filters.lastIndexOf(" AND "));
|
|
56
63
|
}
|
|
@@ -122,6 +122,7 @@ export default {
|
|
|
122
122
|
showFilters: true,
|
|
123
123
|
showFiltersText: true,
|
|
124
124
|
cascadeSelected: [],
|
|
125
|
+
cascadeSelectedWithBoolean: [],
|
|
125
126
|
numberShown: 10,
|
|
126
127
|
filters: [],
|
|
127
128
|
facets: ["Species", "Gender", "Organ", "Datasets"],
|
|
@@ -202,6 +203,7 @@ export default {
|
|
|
202
203
|
facetPropPath: fs[0],
|
|
203
204
|
facet: fs[1].split("/")[1],
|
|
204
205
|
term: fs[1].split("/")[0],
|
|
206
|
+
AND: fs[2] // for setting the boolean
|
|
205
207
|
}))
|
|
206
208
|
|
|
207
209
|
// Move results from arrays to object for use on scicrunch (note that we remove 'duplicate' as that is only needed for filter keys)
|
|
@@ -211,6 +213,7 @@ export default {
|
|
|
211
213
|
facetPropPath: propPath,
|
|
212
214
|
facet: fs[1].split("/")[1],
|
|
213
215
|
term: fs[1].split("/")[0],
|
|
216
|
+
AND: fs[2] // for setting the boolean
|
|
214
217
|
}
|
|
215
218
|
})
|
|
216
219
|
|
|
@@ -333,6 +336,7 @@ export default {
|
|
|
333
336
|
// facetPropPath: 'anatomy.organ.name',
|
|
334
337
|
// term: 'Sex',
|
|
335
338
|
// facet: 'Male'
|
|
339
|
+
// AND: true // Optional value for setting the boolean within a facet
|
|
336
340
|
// }
|
|
337
341
|
setCascader: function (filterFacets) {
|
|
338
342
|
//Do not set the value unless it is ready
|
|
@@ -343,6 +347,16 @@ export default {
|
|
|
343
347
|
this.createCascaderItemValue(capitalise(e.term), e.facet),
|
|
344
348
|
]
|
|
345
349
|
});
|
|
350
|
+
|
|
351
|
+
// Unforttunately the cascader is very particular about it's v-model
|
|
352
|
+
// to get around this we create a clone of it and use this clone for adding our boolean information
|
|
353
|
+
this.cascadeSelectedWithBoolean= filterFacets.map(e => {
|
|
354
|
+
return [
|
|
355
|
+
e.facetPropPath,
|
|
356
|
+
this.createCascaderItemValue(capitalise(e.term), e.facet),
|
|
357
|
+
e.AND
|
|
358
|
+
]
|
|
359
|
+
});
|
|
346
360
|
this.updatePreviousShowAllChecked(this.cascadeSelected);
|
|
347
361
|
}
|
|
348
362
|
},
|
|
@@ -350,11 +364,16 @@ export default {
|
|
|
350
364
|
//Do not set the value unless it is ready
|
|
351
365
|
if (this.cascaderIsReady && filter) {
|
|
352
366
|
this.cascadeSelected.filter(f=>f.term != filter.term)
|
|
353
|
-
this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet)])
|
|
367
|
+
this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
|
|
368
|
+
|
|
369
|
+
this.cascadeSelectedWithBoolean.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
|
|
370
|
+
// The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
|
|
371
|
+
|
|
372
|
+
|
|
354
373
|
}
|
|
355
374
|
},
|
|
356
375
|
initiateSearch: function() {
|
|
357
|
-
this.cascadeEvent(this.
|
|
376
|
+
this.cascadeEvent(this.cascadeSelectedWithBoolean)
|
|
358
377
|
},
|
|
359
378
|
// checkShowAllBoxes: Checks each 'Show all' cascade option by using the setCascader function
|
|
360
379
|
checkShowAllBoxes: function(){
|
|
@@ -139,7 +139,7 @@ export default {
|
|
|
139
139
|
EventBus.$on("PopoverActionClick", (payLoad) => {
|
|
140
140
|
this.$emit("actionClick", payLoad);
|
|
141
141
|
})
|
|
142
|
-
EventBus.$on('
|
|
142
|
+
EventBus.$on('anatomyFound', (payLoad)=> {
|
|
143
143
|
this.$emit('search-changed', {
|
|
144
144
|
type: 'keyword-update',
|
|
145
145
|
value: payLoad
|
|
@@ -192,8 +192,8 @@ export default {
|
|
|
192
192
|
searchAlgolia(filters, query=''){
|
|
193
193
|
// Algolia search
|
|
194
194
|
this.loadingCards = true
|
|
195
|
-
this.algoliaClient.
|
|
196
|
-
EventBus.$emit("
|
|
195
|
+
this.algoliaClient.anatomyInSearch(getFilters(filters), query).then(anatomy => {
|
|
196
|
+
EventBus.$emit("anatomyFound", anatomy)
|
|
197
197
|
})
|
|
198
198
|
this.algoliaClient.search(getFilters(filters), query, this.numberPerPage, this.page).then(searchData => {
|
|
199
199
|
this.numberOfHits = searchData.total
|