Skip to content

Commit

Permalink
make sure that we can filter by platform in the left menu.
Browse files Browse the repository at this point in the history
  • Loading branch information
AnalogJ committed Aug 23, 2023
1 parent dd50faa commit dbc2f49
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,17 @@
<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>
</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>
</nav>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ export class MedicalSourcesFilterComponent implements OnInit {
console.log("SELECTED CATEGORY", category)
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 {
return aggregationData?.buckets?.find(bucket => bucket.key === key)?.doc_count
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
// if(!this.globalLimits.categories.some((category) => { return category.id === bucketData.key})){
Expand Down
3 changes: 1 addition & 2 deletions frontend/src/app/services/medical-sources-filter.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,8 @@ export class MedicalSourcesFilterService {

//ensure that checkbox list values exist before trying to "patch" them in.
if(updateData.platformTypes){
var currentFileTypes = this.filterForm.get('platformTypes').value;
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))
}
})
Expand Down

0 comments on commit dbc2f49

Please sign in to comment.