diff --git a/src/app/domain/projectFilterValues.ts b/src/app/domain/projectFilterValues.ts index 72ed147a29d..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 && - project.metadata.features?.some((feature) => this.featureValue.includes(feature.id)) + 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)) ) 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 @@