@abi-software/map-side-bar 1.3.6 → 1.3.9
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 +300 -105
- 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 +300 -105
- 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 +1 -1
- package/package.json +1 -1
- package/src/App.vue +9 -2
- package/src/algolia/algolia.js +67 -56
- package/src/algolia/markerZoomLevels.js +213 -0
- package/src/algolia/utils.js +14 -7
- package/src/components/SearchFilters.vue +6 -1
- package/src/components/SideBar.vue +1 -1
- package/src/components/SidebarContent.vue +2 -2
package/package-lock.json
CHANGED
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
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/* eslint-disable no-alert, no-console */
|
|
2
2
|
import algoliasearch from 'algoliasearch'
|
|
3
|
+
import markerZoomLevels from './markerZoomLevels';
|
|
3
4
|
|
|
4
5
|
// export `createAlgoliaClient` to use it in page components
|
|
5
6
|
export class AlgoliaClient {
|
|
6
|
-
constructor(algoliaId, algoliaKey, PENNSIEVE_API_LOCATION='https://api.pennsieve.io') {
|
|
7
|
+
constructor(algoliaId, algoliaKey, PENNSIEVE_API_LOCATION = 'https://api.pennsieve.io') {
|
|
7
8
|
this.client = algoliasearch(
|
|
8
9
|
algoliaId,
|
|
9
10
|
algoliaKey
|
|
@@ -14,9 +15,9 @@ export class AlgoliaClient {
|
|
|
14
15
|
this.index = this.client.initIndex(ALGOLIA_INDEX);
|
|
15
16
|
}
|
|
16
17
|
|
|
17
|
-
getAlgoliaFacets
|
|
18
|
+
getAlgoliaFacets(propPathMapping) {
|
|
18
19
|
const map = new Map(Object.entries(propPathMapping));
|
|
19
|
-
const facetPropPaths = Array.from(map.keys()
|
|
20
|
+
const facetPropPaths = Array.from(map.keys());
|
|
20
21
|
let facetData = []
|
|
21
22
|
let facetId = 0
|
|
22
23
|
return this.index
|
|
@@ -28,7 +29,7 @@ export class AlgoliaClient {
|
|
|
28
29
|
facetPropPaths.map((facetPropPath) => {
|
|
29
30
|
var children = []
|
|
30
31
|
const responseFacets = response.facets
|
|
31
|
-
if (responseFacets === undefined) {return}
|
|
32
|
+
if (responseFacets === undefined) { return }
|
|
32
33
|
const responseFacetChildren =
|
|
33
34
|
responseFacets[facetPropPath] == undefined
|
|
34
35
|
? {}
|
|
@@ -52,18 +53,18 @@ export class AlgoliaClient {
|
|
|
52
53
|
return facetData
|
|
53
54
|
})
|
|
54
55
|
}
|
|
55
|
-
|
|
56
|
+
|
|
56
57
|
// Returns all DOIs of all versions for a given discover dataset
|
|
57
|
-
_discoverAllDois
|
|
58
|
+
_discoverAllDois(discoverId, PENNSIEVE_API_LOCATION = 'https://api.pennsieve.io') {
|
|
58
59
|
return new Promise(resolve => {
|
|
59
|
-
fetch(`${PENNSIEVE_API_LOCATION}/discover/datasets/${discoverId}/versions`).then(r=>r.json()).then(dataset => {
|
|
60
|
+
fetch(`${PENNSIEVE_API_LOCATION}/discover/datasets/${discoverId}/versions`).then(r => r.json()).then(dataset => {
|
|
60
61
|
resolve(dataset.map(version => version.doi))
|
|
61
62
|
})
|
|
62
63
|
})
|
|
63
64
|
}
|
|
64
|
-
|
|
65
|
+
|
|
65
66
|
// Get all dois given a list of discoverIds
|
|
66
|
-
_expandDois
|
|
67
|
+
_expandDois(discoverIds, PENNSIEVE_API_LOCATION = 'https://api.pennsieve.io') {
|
|
67
68
|
return new Promise(resolve => {
|
|
68
69
|
let promiseList = discoverIds.map(discoverId => this._discoverAllDois(discoverId, PENNSIEVE_API_LOCATION))
|
|
69
70
|
Promise.all(promiseList).then((values) => {
|
|
@@ -76,7 +77,7 @@ export class AlgoliaClient {
|
|
|
76
77
|
let newResults = []
|
|
77
78
|
let newResult = {}
|
|
78
79
|
for (let res of results) {
|
|
79
|
-
newResult = {...res}
|
|
80
|
+
newResult = { ...res }
|
|
80
81
|
newResult = {
|
|
81
82
|
doi: res.item.curie.split(':')[1],
|
|
82
83
|
name: res.item.name,
|
|
@@ -91,83 +92,93 @@ export class AlgoliaClient {
|
|
|
91
92
|
return newResults
|
|
92
93
|
}
|
|
93
94
|
|
|
94
|
-
|
|
95
|
+
_processAnatomy(hits) {
|
|
95
96
|
let foundKeyWords = []
|
|
96
97
|
let uniqueKeywords = []
|
|
97
|
-
hits.forEach(hit=>{
|
|
98
|
-
if (
|
|
99
|
-
hit.item.keywords.forEach(keywordObj=>{
|
|
98
|
+
hits.forEach(hit => {
|
|
99
|
+
if (hit.item && hit.item.keywords) {
|
|
100
|
+
hit.item.keywords.forEach(keywordObj => {
|
|
100
101
|
let keyword = keywordObj.keyword
|
|
101
102
|
if (keyword.includes('UBERON') || keyword.includes('ilxtr') || keyword.includes('ILX')) {
|
|
102
103
|
foundKeyWords.push(this._processUberonURL(keyword))
|
|
103
|
-
uniqueKeywords = [...new Set(foundKeyWords)]
|
|
104
104
|
}
|
|
105
105
|
})
|
|
106
106
|
}
|
|
107
|
+
if (hit.anatomy && hit.anatomy.organ) {
|
|
108
|
+
hit.anatomy.organ.forEach(anatomy => {
|
|
109
|
+
markerZoomLevels.forEach(marker => {
|
|
110
|
+
if (anatomy.name.toLowerCase() === marker.name.toLowerCase()) {
|
|
111
|
+
foundKeyWords.push(marker.id)
|
|
112
|
+
}
|
|
113
|
+
})
|
|
114
|
+
})
|
|
115
|
+
}
|
|
107
116
|
})
|
|
117
|
+
uniqueKeywords = [...new Set(foundKeyWords)]
|
|
108
118
|
return uniqueKeywords
|
|
109
119
|
}
|
|
110
120
|
|
|
111
|
-
_processUberonURL(url){
|
|
121
|
+
_processUberonURL(url) {
|
|
112
122
|
let ub = url.split('/').pop()
|
|
113
|
-
return ub.replace('_',':')
|
|
123
|
+
return ub.replace('_', ':')
|
|
114
124
|
}
|
|
115
|
-
|
|
125
|
+
|
|
116
126
|
/**
|
|
117
127
|
* Get Search results
|
|
118
128
|
* This is using fetch from the Algolia API
|
|
119
129
|
*/
|
|
120
|
-
search
|
|
130
|
+
search(filter, query = '', hitsperPage = 10, page = 1) {
|
|
121
131
|
return new Promise(resolve => {
|
|
122
132
|
this.index
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
133
|
+
.search(query, {
|
|
134
|
+
facets: ['*'],
|
|
135
|
+
hitsPerPage: hitsperPage,
|
|
136
|
+
page: page - 1,
|
|
137
|
+
filters: filter,
|
|
138
|
+
attributesToHighlight: [],
|
|
139
|
+
attributesToRetrieve: [
|
|
140
|
+
'pennsieve.publishDate',
|
|
141
|
+
'pennsieve.updatedAt',
|
|
142
|
+
'item.curie',
|
|
143
|
+
'item.name',
|
|
144
|
+
'item.description',
|
|
145
|
+
'objectID',
|
|
146
|
+
],
|
|
147
|
+
})
|
|
148
|
+
.then(response => {
|
|
149
|
+
let searchData = {
|
|
150
|
+
items: this._processResultsForCards(response.hits),
|
|
151
|
+
total: response.nbHits,
|
|
152
|
+
discoverIds: response.hits.map(r => r.pennsieve.identifier),
|
|
153
|
+
dois: response.hits.map(r => r.item.curie.split(':')[1])
|
|
154
|
+
}
|
|
155
|
+
resolve(searchData)
|
|
156
|
+
})
|
|
147
157
|
})
|
|
148
158
|
}
|
|
149
159
|
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
160
|
+
/**
|
|
161
|
+
* Get key words
|
|
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
|
+
*/
|
|
164
|
+
anatomyInSearch(filter, query = '', hitsperPage = 999999, page = 1) {
|
|
165
|
+
return new Promise(resolve => {
|
|
166
|
+
this.index
|
|
157
167
|
.search(query, {
|
|
158
|
-
facets:['*'],
|
|
168
|
+
facets: ['*'],
|
|
159
169
|
hitsPerPage: hitsperPage,
|
|
160
|
-
page: page-1,
|
|
170
|
+
page: page - 1,
|
|
161
171
|
filters: filter,
|
|
162
172
|
attributesToHighlight: [],
|
|
163
173
|
attributesToRetrieve: [
|
|
164
174
|
'item.keywords.keyword',
|
|
175
|
+
'anatomy.organ.name',
|
|
165
176
|
],
|
|
166
177
|
})
|
|
167
178
|
.then(response => {
|
|
168
|
-
let
|
|
169
|
-
resolve(
|
|
179
|
+
let anatomyAsUberons = this._processAnatomy(response.hits)
|
|
180
|
+
resolve(anatomyAsUberons)
|
|
170
181
|
})
|
|
171
|
-
|
|
172
|
-
|
|
182
|
+
})
|
|
183
|
+
}
|
|
173
184
|
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// Set zoom values for micro and mesoscopic
|
|
2
|
+
let microscopic = 7
|
|
3
|
+
let mesoscopic = 5
|
|
4
|
+
|
|
5
|
+
// Set what level each uberon shows at
|
|
6
|
+
export default [
|
|
7
|
+
{
|
|
8
|
+
"id": "UBERON:0000948",
|
|
9
|
+
"name": "heart",
|
|
10
|
+
"showAtZoom": 1,
|
|
11
|
+
},
|
|
12
|
+
{
|
|
13
|
+
"id": "UBERON:0001759",
|
|
14
|
+
"name": "vagus nerve",
|
|
15
|
+
"showAtZoom": 1
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
"id": "UBERON:0001155",
|
|
19
|
+
"name": "colon",
|
|
20
|
+
"showAtZoom": 1
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
"id": "UBERON:0000945",
|
|
24
|
+
"name": "stomach",
|
|
25
|
+
"showAtZoom": 1
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"id": "UBERON:0001013",
|
|
29
|
+
"name": "adipose tissue",
|
|
30
|
+
"showAtZoom": 1
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
"id": "UBERON:0001255",
|
|
34
|
+
"name": "urinary bladder",
|
|
35
|
+
"showAtZoom": 1
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"id": "UBERON:0001348",
|
|
39
|
+
"name": "brown adipose tissue",
|
|
40
|
+
"showAtZoom": 6
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
"id": "UBERON:0002008",
|
|
44
|
+
"name": "cardiac nerve plexus",
|
|
45
|
+
"showAtZoom": 1
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
"id": "UBERON:0002240",
|
|
49
|
+
"name": "spinal cord",
|
|
50
|
+
"showAtZoom": 1
|
|
51
|
+
},
|
|
52
|
+
{
|
|
53
|
+
"id": "UBERON:0002005",
|
|
54
|
+
"name": "Enteric Nervous System",
|
|
55
|
+
"showAtZoom": 4
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
"id": "UBERON:0013702",
|
|
59
|
+
"name": "body proper",
|
|
60
|
+
"showAtZoom": 1
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
"id": "UBERON:0002298",
|
|
64
|
+
"name": "brainstem",
|
|
65
|
+
"showAtZoom": 1
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
"id": "UBERON:0002439",
|
|
69
|
+
"name": "myenteric nerve plexus",
|
|
70
|
+
"showAtZoom": 6
|
|
71
|
+
},
|
|
72
|
+
{
|
|
73
|
+
"id": "UBERON:0000010",
|
|
74
|
+
"name": "peripheral nervous system",
|
|
75
|
+
"showAtZoom": 6
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"id": "UBERON:0002048",
|
|
79
|
+
"name": "lung",
|
|
80
|
+
"showAtZoom": 1
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
"id": "UBERON:0002410",
|
|
84
|
+
"name": "autonomic nervous system",
|
|
85
|
+
"showAtZoom": 6
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"id": "UBERON:0002441",
|
|
89
|
+
"name": "cervicothoracic ganglion",
|
|
90
|
+
"showAtZoom": 6
|
|
91
|
+
},
|
|
92
|
+
{
|
|
93
|
+
"id": "UBERON:0005363",
|
|
94
|
+
"name": "inferior vagus X ganglion",
|
|
95
|
+
"showAtZoom": 6
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"id": "UBERON:0001264",
|
|
99
|
+
"name": "pancreas",
|
|
100
|
+
"showAtZoom": 1
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
"id": "UBERON:0001884",
|
|
104
|
+
"name": "phrenic nerve",
|
|
105
|
+
"showAtZoom": 6
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
"id": "UBERON:0002059",
|
|
109
|
+
"name": "submandibular ganglion",
|
|
110
|
+
"showAtZoom": 7
|
|
111
|
+
},
|
|
112
|
+
{
|
|
113
|
+
"id": "UBERON:0001347",
|
|
114
|
+
"name": "white adipose tissue",
|
|
115
|
+
"showAtZoom": 6
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"id": "UBERON:0001556",
|
|
119
|
+
"name": "lower urinary tract",
|
|
120
|
+
"showAtZoom": 1
|
|
121
|
+
},
|
|
122
|
+
{
|
|
123
|
+
"id": "UBERON:0002262",
|
|
124
|
+
"name": "celiac ganglion",
|
|
125
|
+
"showAtZoom": 5
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"id": "UBERON:0000955",
|
|
129
|
+
"name": "Brain",
|
|
130
|
+
"showAtZoom": 1
|
|
131
|
+
},
|
|
132
|
+
{
|
|
133
|
+
"id": "UBERON:0000160",
|
|
134
|
+
"name": "intestine",
|
|
135
|
+
"showAtZoom": 1
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
"id": "UBERON:0001322",
|
|
139
|
+
"name": "sciatic nerve",
|
|
140
|
+
"showAtZoom": 1
|
|
141
|
+
},
|
|
142
|
+
{
|
|
143
|
+
"id": "UBERON:0001649",
|
|
144
|
+
"name": "glossopharyngeal nerve",
|
|
145
|
+
"showAtZoom": 6
|
|
146
|
+
},
|
|
147
|
+
{
|
|
148
|
+
"id": "UBERON:0002063",
|
|
149
|
+
"name": "sinus venosus",
|
|
150
|
+
"showAtZoom": 6
|
|
151
|
+
},
|
|
152
|
+
{
|
|
153
|
+
"id": "UBERON:0002107",
|
|
154
|
+
"name": "liver",
|
|
155
|
+
"showAtZoom": 1
|
|
156
|
+
},
|
|
157
|
+
{
|
|
158
|
+
"id": "UBERON:0002113",
|
|
159
|
+
"name": "kidney",
|
|
160
|
+
"showAtZoom": 1
|
|
161
|
+
},
|
|
162
|
+
{
|
|
163
|
+
"id": "UBERON:0002481",
|
|
164
|
+
"name": "bone tissue",
|
|
165
|
+
"showAtZoom": 1
|
|
166
|
+
},
|
|
167
|
+
{
|
|
168
|
+
"id": "UBERON:0004907",
|
|
169
|
+
"name": "lower digestive tract",
|
|
170
|
+
"showAtZoom": 4
|
|
171
|
+
},
|
|
172
|
+
{
|
|
173
|
+
"id": "UBERON:0000044",
|
|
174
|
+
"name": "Dorsal root ganglion",
|
|
175
|
+
"showAtZoom": 5
|
|
176
|
+
},
|
|
177
|
+
// New levels from Keeran
|
|
178
|
+
{
|
|
179
|
+
"id": "UBERON:0001736",
|
|
180
|
+
"name": "Submandibular gland",
|
|
181
|
+
"showAtZoom": microscopic
|
|
182
|
+
},
|
|
183
|
+
{
|
|
184
|
+
"id": "UBERON:0001103",
|
|
185
|
+
"name": "Diaphragm",
|
|
186
|
+
"showAtZoom": mesoscopic
|
|
187
|
+
},
|
|
188
|
+
{
|
|
189
|
+
"id": "UBERON:0001160",
|
|
190
|
+
"name": "Fundus of stomach",
|
|
191
|
+
"showAtZoom": mesoscopic
|
|
192
|
+
},
|
|
193
|
+
{
|
|
194
|
+
"id": "UBERON:0000955",
|
|
195
|
+
"name": "Brain",
|
|
196
|
+
"showAtZoom": mesoscopic
|
|
197
|
+
},
|
|
198
|
+
{
|
|
199
|
+
"id": "UBERON:0003708",
|
|
200
|
+
"name": "Carotid sinus",
|
|
201
|
+
"showAtZoom": microscopic
|
|
202
|
+
},
|
|
203
|
+
{
|
|
204
|
+
"id": "UBERON:0002079",
|
|
205
|
+
"name": "Left cardiac atrium",
|
|
206
|
+
"showAtZoom": mesoscopic
|
|
207
|
+
},
|
|
208
|
+
{
|
|
209
|
+
"id": "ILX:0485722",
|
|
210
|
+
"name": "Nodose ganglion",
|
|
211
|
+
"showAtZoom": microscopic
|
|
212
|
+
},
|
|
213
|
+
]
|
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
|
}
|
|
@@ -202,6 +202,7 @@ export default {
|
|
|
202
202
|
facetPropPath: fs[0],
|
|
203
203
|
facet: fs[1].split("/")[1],
|
|
204
204
|
term: fs[1].split("/")[0],
|
|
205
|
+
AND: fs[2] // for setting the boolean
|
|
205
206
|
}))
|
|
206
207
|
|
|
207
208
|
// 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 +212,7 @@ export default {
|
|
|
211
212
|
facetPropPath: propPath,
|
|
212
213
|
facet: fs[1].split("/")[1],
|
|
213
214
|
term: fs[1].split("/")[0],
|
|
215
|
+
AND: fs[2] // for setting the boolean
|
|
214
216
|
}
|
|
215
217
|
})
|
|
216
218
|
|
|
@@ -333,6 +335,7 @@ export default {
|
|
|
333
335
|
// facetPropPath: 'anatomy.organ.name',
|
|
334
336
|
// term: 'Sex',
|
|
335
337
|
// facet: 'Male'
|
|
338
|
+
// AND: true // Optional value for setting the boolean within a facet
|
|
336
339
|
// }
|
|
337
340
|
setCascader: function (filterFacets) {
|
|
338
341
|
//Do not set the value unless it is ready
|
|
@@ -341,6 +344,7 @@ export default {
|
|
|
341
344
|
return [
|
|
342
345
|
e.facetPropPath,
|
|
343
346
|
this.createCascaderItemValue(capitalise(e.term), e.facet),
|
|
347
|
+
e.AND
|
|
344
348
|
]
|
|
345
349
|
});
|
|
346
350
|
this.updatePreviousShowAllChecked(this.cascadeSelected);
|
|
@@ -350,7 +354,8 @@ export default {
|
|
|
350
354
|
//Do not set the value unless it is ready
|
|
351
355
|
if (this.cascaderIsReady && filter) {
|
|
352
356
|
this.cascadeSelected.filter(f=>f.term != filter.term)
|
|
353
|
-
this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet)])
|
|
357
|
+
this.cascadeSelected.push([filter.facetPropPath, this.createCascaderItemValue(filter.term, filter.facet), filter.AND])
|
|
358
|
+
// The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
|
|
354
359
|
}
|
|
355
360
|
},
|
|
356
361
|
initiateSearch: 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
|