@@ -11,7 +11,15 @@ export class ProjectFilterValues {
1111 unitTypeValue : string [ ] = [ ] ;
1212
1313 matches ( project : LibraryProject ) : boolean {
14- return this . matchesSearch ( project ) && ( ! this . hasFilters ( ) || this . matchesFilter ( project ) ) ;
14+ return (
15+ this . matchesSearch ( project ) &&
16+ this . matchesPublicUnitType ( project ) &&
17+ this . matchesStandard ( project ) &&
18+ this . matchesDiscipline ( project ) &&
19+ this . matchesUnitType ( project ) &&
20+ this . matchesFeature ( project ) &&
21+ this . matchesGradeLevel ( project )
22+ ) ;
1523 }
1624
1725 private matchesSearch ( project : LibraryProject ) : boolean {
@@ -36,25 +44,14 @@ export class ProjectFilterValues {
3644 } )
3745 ) ;
3846 }
39- private matchesFilter ( project : LibraryProject ) : boolean {
40- return (
41- this . matchesPublicUnitType ( project ) ||
42- this . matchesStandard ( project ) ||
43- this . matchesDiscipline ( project ) ||
44- this . matchesUnitType ( project ) ||
45- this . matchesFeature ( project ) ||
46- this . matchesGradeLevel ( project )
47- ) ;
48- }
4947
5048 hasFilters ( ) : boolean {
5149 return (
5250 this . standardValue . length +
5351 this . disciplineValue . length +
5452 this . unitTypeValue . length +
5553 this . gradeLevelValue . length +
56- this . featureValue . length +
57- ( this . publicUnitTypeValue ?. length ?? 0 ) >
54+ this . featureValue . length >
5855 0
5956 ) ;
6057 }
@@ -65,39 +62,44 @@ export class ProjectFilterValues {
6562 this . unitTypeValue = [ ] ;
6663 this . gradeLevelValue = [ ] ;
6764 this . featureValue = [ ] ;
68- this . publicUnitTypeValue = [ ] ;
6965 }
7066
7167 private matchesUnitType ( project : LibraryProject ) : boolean {
7268 const unitTypeValue =
7369 project . metadata . unitType === 'Platform' ? 'WISE Platform' : 'Other Platform' ;
74- return this . unitTypeValue ?. includes ( unitTypeValue ) ;
70+ return this . unitTypeValue . length === 0 || this . unitTypeValue ?. includes ( unitTypeValue ) ;
7571 }
7672
7773 private matchesPublicUnitType ( project : LibraryProject ) : boolean {
78- return this . publicUnitTypeValue ?. includes ( project . metadata . publicUnitType ) ;
74+ return (
75+ this . publicUnitTypeValue ?. length === 0 ||
76+ this . publicUnitTypeValue ?. includes ( project . metadata . publicUnitType )
77+ ) ;
7978 }
8079
8180 private matchesStandard ( project : LibraryProject ) : boolean {
8281 const standards = project . metadata . standards ;
8382 const commonCore = standards ?. commonCore ?? [ ] ;
8483 const ngss = standards ?. ngss ?? [ ] ;
8584 const learningForJustice = standards ?. learningForJustice ?? [ ] ;
86- return [ ...commonCore , ...ngss , ...learningForJustice ] . some ( ( val ) =>
87- this . standardValue . includes ( val . id )
85+ return (
86+ this . standardValue . length === 0 ||
87+ [ ...commonCore , ...ngss , ...learningForJustice ] . some ( ( val ) =>
88+ this . standardValue . includes ( val . id )
89+ )
8890 ) ;
8991 }
9092
9193 private matchesFeature ( project : LibraryProject ) : boolean {
9294 return (
93- this . featureValue . length > 0 &&
94- project . metadata . features ?. some ( ( feature ) => this . featureValue . includes ( feature . id ) )
95+ this . featureValue . length === 0 ||
96+ project . metadata . features ?. some ( ( feature ) => this . featureValue . includes ( feature . name ) )
9597 ) ;
9698 }
9799
98100 private matchesDiscipline ( project : LibraryProject ) : boolean {
99101 return (
100- this . disciplineValue . length > 0 &&
102+ this . disciplineValue . length === 0 ||
101103 project . metadata . disciplines ?. some ( ( discipline ) =>
102104 this . disciplineValue . includes ( discipline . id )
103105 )
@@ -106,7 +108,7 @@ export class ProjectFilterValues {
106108
107109 private matchesGradeLevel ( project : LibraryProject ) : boolean {
108110 return (
109- this . gradeLevelValue . length > 0 &&
111+ this . gradeLevelValue . length === 0 ||
110112 project . metadata . grades ?. some ( ( gradeLevel ) =>
111113 this . gradeLevelValue . includes ( Number ( gradeLevel ) )
112114 )
0 commit comments