From 1238ec9b0cd5600c866a7468953fca27df293eac Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Wed, 23 Apr 2025 13:25:18 -0700 Subject: [PATCH 1/3] Fix feature filtering. This is not an ideal fix, it should be looking at id instead --- src/app/domain/projectFilterValues.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/domain/projectFilterValues.ts b/src/app/domain/projectFilterValues.ts index 72ed147a29d..060f495bdd9 100644 --- a/src/app/domain/projectFilterValues.ts +++ b/src/app/domain/projectFilterValues.ts @@ -91,7 +91,7 @@ export class ProjectFilterValues { private matchesFeature(project: LibraryProject): boolean { return ( this.featureValue.length > 0 && - project.metadata.features?.some((feature) => this.featureValue.includes(feature.id)) + project.metadata.features?.some((feature) => this.featureValue.includes(feature.name)) ); } From ac24354d802f28f513ab7c50f7630d24d92d9ae2 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Wed, 23 Apr 2025 14:45:21 -0700 Subject: [PATCH 2/3] Changes all the filter categories from OR to AND --- src/app/domain/projectFilterValues.ts | 44 ++++++++++++++------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/src/app/domain/projectFilterValues.ts b/src/app/domain/projectFilterValues.ts index 060f495bdd9..65ba0ee129c 100644 --- a/src/app/domain/projectFilterValues.ts +++ b/src/app/domain/projectFilterValues.ts @@ -11,7 +11,15 @@ export class ProjectFilterValues { unitTypeValue: string[] = []; matches(project: LibraryProject): boolean { - return this.matchesSearch(project) && (!this.hasFilters() || this.matchesFilter(project)); + return ( + this.matchesSearch(project) && + this.matchesPublicUnitType(project) && + this.matchesStandard(project) && + this.matchesDiscipline(project) && + this.matchesUnitType(project) && + this.matchesFeature(project) && + this.matchesGradeLevel(project) + ); } private matchesSearch(project: LibraryProject): boolean { @@ -36,16 +44,6 @@ export class ProjectFilterValues { }) ); } - private matchesFilter(project: LibraryProject): boolean { - return ( - this.matchesPublicUnitType(project) || - this.matchesStandard(project) || - this.matchesDiscipline(project) || - this.matchesUnitType(project) || - this.matchesFeature(project) || - this.matchesGradeLevel(project) - ); - } hasFilters(): boolean { return ( @@ -53,8 +51,7 @@ export class ProjectFilterValues { this.disciplineValue.length + this.unitTypeValue.length + this.gradeLevelValue.length + - this.featureValue.length + - (this.publicUnitTypeValue?.length ?? 0) > + this.featureValue.length > 0 ); } @@ -65,17 +62,19 @@ export class ProjectFilterValues { this.unitTypeValue = []; this.gradeLevelValue = []; this.featureValue = []; - this.publicUnitTypeValue = []; } private matchesUnitType(project: LibraryProject): boolean { const unitTypeValue = project.metadata.unitType === 'Platform' ? 'WISE Platform' : 'Other Platform'; - return this.unitTypeValue?.includes(unitTypeValue); + return this.unitTypeValue.length === 0 || this.unitTypeValue?.includes(unitTypeValue); } private matchesPublicUnitType(project: LibraryProject): boolean { - return this.publicUnitTypeValue?.includes(project.metadata.publicUnitType); + return ( + this.publicUnitTypeValue?.length === 0 || + this.publicUnitTypeValue?.includes(project.metadata.publicUnitType) + ); } private matchesStandard(project: LibraryProject): boolean { @@ -83,21 +82,24 @@ export class ProjectFilterValues { const commonCore = standards?.commonCore ?? []; const ngss = standards?.ngss ?? []; const learningForJustice = standards?.learningForJustice ?? []; - return [...commonCore, ...ngss, ...learningForJustice].some((val) => - this.standardValue.includes(val.id) + return ( + this.standardValue.length === 0 || + [...commonCore, ...ngss, ...learningForJustice].some((val) => + this.standardValue.includes(val.id) + ) ); } private matchesFeature(project: LibraryProject): boolean { return ( - this.featureValue.length > 0 && + this.featureValue.length === 0 || project.metadata.features?.some((feature) => this.featureValue.includes(feature.name)) ); } private matchesDiscipline(project: LibraryProject): boolean { return ( - this.disciplineValue.length > 0 && + this.disciplineValue.length === 0 || project.metadata.disciplines?.some((discipline) => this.disciplineValue.includes(discipline.id) ) @@ -106,7 +108,7 @@ export class ProjectFilterValues { private matchesGradeLevel(project: LibraryProject): boolean { return ( - this.gradeLevelValue.length > 0 && + this.gradeLevelValue.length === 0 || project.metadata.grades?.some((gradeLevel) => this.gradeLevelValue.includes(Number(gradeLevel)) ) From 0fd39b986c207282cf97e01ee9758919c8a7e4f3 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Wed, 23 Apr 2025 14:49:18 -0700 Subject: [PATCH 3/3] Fixes issue where filterValues get overriden when you change either LibraryFilters or the public unit type. --- .../library/public-library/public-library.component.html | 2 +- .../library/public-library/public-library.component.ts | 9 +++++++++ .../public-unit-type-selector.component.ts | 5 +++-- 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/app/modules/library/public-library/public-library.component.html b/src/app/modules/library/public-library/public-library.component.html index c8d4a377d8d..6b794aee694 100644 --- a/src/app/modules/library/public-library/public-library.component.html +++ b/src/app/modules/library/public-library/public-library.component.html @@ -2,7 +2,7 @@
= new EventEmitter(); + @Output() publicUnitTypeUpdatedEvent: EventEmitter = + new EventEmitter(); protected wiseTested: boolean; constructor(private dialog: MatDialog) {} @@ -41,7 +42,7 @@ export class PublicUnitTypeSelectorComponent { if (this.communityBuilt) { this.filterValues.publicUnitTypeValue.push('communityBuilt'); } - this.publicUnitTypeUpdatedEvent.emit(); + this.publicUnitTypeUpdatedEvent.emit(this.filterValues); } protected showInfo(type: 'community' | 'official'): void {