@abi-software/map-side-bar 1.5.4-beta.hierarchy.1 → 1.5.4-beta.hierarchy.2
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 +164 -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 +164 -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.json +1 -1
- package/src/App.vue +1 -1
- package/src/components/SearchFilters.vue +43 -19
- package/src/components/SidebarContent.vue +1 -1
package/package.json
CHANGED
package/src/App.vue
CHANGED
|
@@ -116,7 +116,7 @@ export default {
|
|
|
116
116
|
this.$refs.sideBar.addFilter({facet: 'Cardiovascular system', facet2:"Heart", term:'Anatomical structure', facetPropPath: 'anatomy.organ.category.name', AND: true})
|
|
117
117
|
},
|
|
118
118
|
addStomach: function(){
|
|
119
|
-
this.$refs.sideBar.addFilter({facet: 'Stomach', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND:
|
|
119
|
+
this.$refs.sideBar.addFilter({facet: 'Stomach', term:'Anatomical structure', facetPropPath: 'anatomy.organ.category.name', AND: true})
|
|
120
120
|
},
|
|
121
121
|
addInvalidTerm: function(){
|
|
122
122
|
this.$refs.sideBar.addFilter({facet: 'Invalid', term:'Anatomical structure', facetPropPath: 'anatomy.organ.name', AND: true})
|
|
@@ -406,9 +406,11 @@ export default {
|
|
|
406
406
|
addFilter: function (filter) {
|
|
407
407
|
//Do not set the value unless it is ready
|
|
408
408
|
if (this.cascaderIsReady && filter) {
|
|
409
|
-
|
|
409
|
+
filter = this.validateAndConvertFilterToHierarchical(filter)
|
|
410
|
+
console.log('we got:', filter)
|
|
411
|
+
if (filter) {
|
|
410
412
|
this.cascadeSelected.filter(f=>f.term != filter.term)
|
|
411
|
-
this.cascadeSelected.push([filter.facetPropPath,this.createCascaderItemValue(filter.term, filter.facet), this.createCascaderItemValue(filter.term, filter.facet, filter.facet2)
|
|
413
|
+
this.cascadeSelected.push([filter.facetPropPath,this.createCascaderItemValue(filter.term, filter.facet), this.createCascaderItemValue(filter.term, filter.facet, filter.facet2)])
|
|
412
414
|
this.cascadeSelectedWithBoolean.push([filter.facetPropPath,this.createCascaderItemValue(filter.term, filter.facet), this.createCascaderItemValue(filter.term, filter.facet, filter.facet2), filter.AND])
|
|
413
415
|
// The 'AND' her is to set the boolean value when we search on the filters. It can be undefined without breaking anything
|
|
414
416
|
return true;
|
|
@@ -449,31 +451,52 @@ export default {
|
|
|
449
451
|
});
|
|
450
452
|
});
|
|
451
453
|
},
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
454
|
+
|
|
455
|
+
/*
|
|
456
|
+
* Given a filter, the function below returns the filter in the format of the cascader, returns false if facet is not found
|
|
457
|
+
*/
|
|
458
|
+
validateAndConvertFilterToHierarchical: function (filter) {
|
|
459
|
+
console.log('validateAndConvertFilterToHierarchical:', filter)
|
|
456
460
|
if (filter && filter.facet && filter.term) {
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
const
|
|
461
|
-
|
|
462
|
-
|
|
461
|
+
if (filter.facet2) {
|
|
462
|
+
return filter // if it has a second term we will assume it is hierarchical and return it as is
|
|
463
|
+
} else {
|
|
464
|
+
for (const firstLayer of this.options){
|
|
465
|
+
if (firstLayer.value === filter.facetPropPath) {
|
|
466
|
+
for (const secondLayer of firstLayer.children) {
|
|
467
|
+
if (secondLayer.label === filter.facet) {
|
|
468
|
+
// if we find a match on the second level, the filter will already be correct
|
|
469
|
+
return filter
|
|
470
|
+
} else {
|
|
471
|
+
if (secondLayer.children && secondLayer.children.length > 0) {
|
|
472
|
+
for (const thirdLayer of secondLayer.children) {
|
|
473
|
+
if (thirdLayer.label === filter.facet) {
|
|
474
|
+
// If we find a match on the third level, we need to switch facet1 to facet2
|
|
475
|
+
// and populate facet1 with its parents label.
|
|
476
|
+
filter.facet2 = thirdLayer.label
|
|
477
|
+
filter.facet = secondLayer.label
|
|
478
|
+
console.log('found it! returning:', filter)
|
|
479
|
+
return filter
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
}
|
|
484
|
+
}
|
|
485
|
+
}
|
|
486
|
+
}
|
|
463
487
|
}
|
|
464
488
|
}
|
|
465
|
-
return false
|
|
489
|
+
return false
|
|
466
490
|
},
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
*/
|
|
470
|
-
getValidatedFilters: function (filters) {
|
|
491
|
+
|
|
492
|
+
getHierarchicalValidatedFilters: function (filters) {
|
|
471
493
|
if (filters) {
|
|
472
494
|
if (this.cascaderIsReady) {
|
|
473
495
|
const result = [];
|
|
474
496
|
filters.forEach(filter => {
|
|
475
|
-
|
|
476
|
-
|
|
497
|
+
const validatedFilter = this.validateAndConvertFilterToHierarchical(filter)
|
|
498
|
+
if (validatedFilter) {
|
|
499
|
+
result.push(validatedFilter);
|
|
477
500
|
}
|
|
478
501
|
});
|
|
479
502
|
return result;
|
|
@@ -481,6 +504,7 @@ export default {
|
|
|
481
504
|
}
|
|
482
505
|
return [];
|
|
483
506
|
},
|
|
507
|
+
|
|
484
508
|
},
|
|
485
509
|
mounted: function () {
|
|
486
510
|
this.algoliaClient = new AlgoliaClient(this.envVars.ALGOLIA_ID, this.envVars.ALGOLIA_KEY, this.envVars.PENNSIEVE_API_LOCATION);
|
|
@@ -159,7 +159,7 @@ export default {
|
|
|
159
159
|
this.resetPageNavigation();
|
|
160
160
|
//Proceed normally if cascader is ready
|
|
161
161
|
if (this.cascaderIsReady) {
|
|
162
|
-
this.filter = this.$refs.filtersRef.
|
|
162
|
+
this.filter = this.$refs.filtersRef.getHierarchicalValidatedFilters(filter)
|
|
163
163
|
//Facets provided but cannot find at least one valid
|
|
164
164
|
//facet. Tell the users the search is invalid and reset
|
|
165
165
|
//facets check boxes.
|