@abi-software/map-side-bar 1.3.7 → 1.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@abi-software/map-side-bar",
3
- "version": "1.3.7",
3
+ "version": "1.3.8",
4
4
  "main": "./dist/map-side-bar.common.js",
5
5
  "files": [
6
6
  "dist/*",
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
  }
@@ -92,7 +92,7 @@ export class AlgoliaClient {
92
92
  return newResults
93
93
  }
94
94
 
95
- _processKeywords(hits) {
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
- keywordsInSearch(filter, query = '', hitsperPage = 999999, page = 1) {
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 keywords = this._processKeywords(response.hits)
180
- resolve(keywords)
179
+ let anatomyAsUberons = this._processAnatomy(response.hits)
180
+ resolve(anatomyAsUberons)
181
181
  })
182
182
  })
183
183
  }
@@ -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 facetsToOr = facets.filter(
43
+ const facetsToBool = facets.filter(
43
44
  (facet) => facet.facetPropPath == facetPropPath
44
45
  );
45
- var filter = "";
46
- facetsToOr.map((facet) => {
47
- filter += `"${facetPropPath}":"${facet.label}" OR `;
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 (filter == "") {
55
+ if (orFilters == "" && andFilters =="") {
50
56
  return;
51
57
  }
52
- filter = `(${filter.substring(0, filter.lastIndexOf(" OR "))})`;
53
- filters += `${filter} AND `;
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('keywordsFound', (payLoad)=> {
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.keywordsInSearch(getFilters(filters), query).then(keywords => {
196
- EventBus.$emit("keywordsFound", keywords)
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