make sure that we can filter by platform in the left menu.

This commit is contained in:
Jason Kulatunga 2023-08-22 18:11:41 -07:00
parent dd50faab57
commit dbc2f49d86
No known key found for this signature in database
4 changed files with 22 additions and 2 deletions

View File

@ -14,7 +14,17 @@
<span class="switch-button"></span><span class="category-label truncate pl-1 pr-1">{{category.key | medicalSourcesCategoryLookup}}</span> <span class="switch-button"></span><span class="category-label truncate pl-1 pr-1">{{category.key | medicalSourcesCategoryLookup}}</span>
<span *ngIf="!filterService.filterForm.get('categories').get(category.key).value" class="badge badge-primary mr-1">{{bucketDocCount(categories, category.key)}}</span> <span *ngIf="!filterService.filterForm.get('categories').get(category.key).value" class="badge badge-primary mr-1">{{bucketDocCount(categories, category.key)}}</span>
</label> </label>
</div>
</nav>
<label>Platform</label>
<nav formGroupName="platformTypes" class="nav flex-column">
<div *ngFor="let platformType of filterService.filterForm.get('platformTypes').value | keyvalue " class="switch-container">
<label class="switch text-nowrap">
<input type="checkbox" [formControlName]="platformType.key" [value]="platformType.value">
<span class="switch-button"></span><span class="category-label truncate pl-1 pr-1">{{platformType.key}}</span>
<span *ngIf="!filterService.filterForm.get('platformTypes').get(platformType.key).value" class="badge badge-primary mr-1">{{bucketDocCount(platformTypes, platformType.key)}}</span>
</label>
</div> </div>
</nav> </nav>

View File

@ -26,6 +26,10 @@ export class MedicalSourcesFilterComponent implements OnInit {
console.log("SELECTED CATEGORY", category) console.log("SELECTED CATEGORY", category)
this.filterService.filterForm.patchValue({'categories': {[category]: true}}) this.filterService.filterForm.patchValue({'categories': {[category]: true}})
} }
platformTypeSelected(platformType: string){
console.log("SELECTED PLATFORMTYPE", platformType)
this.filterService.filterForm.patchValue({'platformTypes': {[platformType]: true}})
}
bucketDocCount(aggregationData: LighthouseSourceSearchAggregation, key): number { bucketDocCount(aggregationData: LighthouseSourceSearchAggregation, key): number {
return aggregationData?.buckets?.find(bucket => bucket.key === key)?.doc_count return aggregationData?.buckets?.find(bucket => bucket.key === key)?.doc_count

View File

@ -183,6 +183,13 @@ export class MedicalSourcesComponent implements OnInit {
} }
}) })
var currentPlatformTypes = this.filterForm.get('platformTypes').value;
this.resultLimits.platformTypesBuckets.buckets.forEach((bucketData) => {
if(!currentPlatformTypes.hasOwnProperty(bucketData.key)){
(this.filterForm.get('platformTypes') as FormGroup).addControl(bucketData.key, new FormControl(false))
}
})
// //
// this.resultLimits.categoryBuckets.forEach((bucketData) => { // this.resultLimits.categoryBuckets.forEach((bucketData) => {
// if(!this.globalLimits.categories.some((category) => { return category.id === bucketData.key})){ // if(!this.globalLimits.categories.some((category) => { return category.id === bucketData.key})){

View File

@ -160,9 +160,8 @@ export class MedicalSourcesFilterService {
//ensure that checkbox list values exist before trying to "patch" them in. //ensure that checkbox list values exist before trying to "patch" them in.
if(updateData.platformTypes){ if(updateData.platformTypes){
var currentFileTypes = this.filterForm.get('platformTypes').value;
Object.keys(updateData.platformTypes).forEach((bucketKey) => { Object.keys(updateData.platformTypes).forEach((bucketKey) => {
if(!currentFileTypes.hasOwnProperty(bucketKey)){ if(!this.filterForm.get('platformTypes').get(bucketKey)){
(this.filterForm.get('platformTypes') as FormGroup).addControl(bucketKey, new FormControl(false)) (this.filterForm.get('platformTypes') as FormGroup).addControl(bucketKey, new FormControl(false))
} }
}) })