From 6db3a66af82302473e51a087dfc441d41ee55654 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Wed, 7 May 2025 09:51:38 -0700 Subject: [PATCH 1/2] refactor(LibraryService): Move ProjectFilterValues out of class. Use Provider instead --- src/app/curriculum/curriculum.component.ts | 3 ++- src/app/domain/projectFilterValues.ts | 8 +++++--- .../home-page-project-library.component.ts | 3 +-- .../library-filters.component.html | 16 ++++++++-------- .../library-filters.component.spec.ts | 8 ++++---- .../library-filters.component.ts | 19 ++++++++----------- .../library/library/library.component.ts | 13 ++++++------- .../official-library.component.spec.ts | 3 +-- .../official-library.component.ts | 5 ----- .../personal-library.component.spec.ts | 2 ++ .../personal-library.component.ts | 4 +++- .../public-library.component.spec.ts | 8 ++++---- ...ublic-unit-type-selector.component.spec.ts | 10 ++-------- .../public-unit-type-selector.component.ts | 8 +------- src/app/services/library.service.ts | 6 ------ 15 files changed, 47 insertions(+), 69 deletions(-) diff --git a/src/app/curriculum/curriculum.component.ts b/src/app/curriculum/curriculum.component.ts index 03f41e9f68f..341e9684b4d 100644 --- a/src/app/curriculum/curriculum.component.ts +++ b/src/app/curriculum/curriculum.component.ts @@ -11,6 +11,7 @@ import { Subscription } from 'rxjs'; import { UserService } from '../services/user.service'; import { MatButtonModule } from '@angular/material/button'; import { Router, RouterModule } from '@angular/router'; +import { ProjectFilterValues } from '../domain/projectFilterValues'; @Component({ imports: [ @@ -23,6 +24,7 @@ import { Router, RouterModule } from '@angular/router'; PublicLibraryComponent, RouterModule ], + providers: [ProjectFilterValues], styleUrl: './curriculum.component.scss', templateUrl: './curriculum.component.html' }) @@ -41,7 +43,6 @@ export class CurriculumComponent { ngOnInit(): void { this.showMyUnits = this.userService.isTeacher(); - this.libraryService.initFilterValues(); this.getLibraryProjects(); this.subscribeNumUnitsVisible(); } diff --git a/src/app/domain/projectFilterValues.ts b/src/app/domain/projectFilterValues.ts index 65ba0ee129c..6d0c258ae43 100644 --- a/src/app/domain/projectFilterValues.ts +++ b/src/app/domain/projectFilterValues.ts @@ -57,11 +57,13 @@ export class ProjectFilterValues { } clear(): void { - this.standardValue = []; this.disciplineValue = []; - this.unitTypeValue = []; - this.gradeLevelValue = []; this.featureValue = []; + this.gradeLevelValue = []; + this.publicUnitTypeValue = []; + this.searchValue = ''; + this.standardValue = []; + this.unitTypeValue = []; } private matchesUnitType(project: LibraryProject): boolean { diff --git a/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts b/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts index 6545594a939..b9384d0c715 100644 --- a/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts +++ b/src/app/modules/library/home-page-project-library/home-page-project-library.component.ts @@ -3,14 +3,13 @@ import { LibraryService } from '../../../services/library.service'; import { ProjectFilterValues } from '../../../domain/projectFilterValues'; @Component({ + providers: [ProjectFilterValues], selector: 'app-home-page-project-library', styleUrls: ['./home-page-project-library.component.scss', '../library/library.component.scss'], templateUrl: './home-page-project-library.component.html', standalone: false }) export class HomePageProjectLibraryComponent { - protected filterValues: ProjectFilterValues = new ProjectFilterValues(); - constructor(private libraryService: LibraryService) { libraryService.getOfficialLibraryProjects(); } diff --git a/src/app/modules/library/library-filters/library-filters.component.html b/src/app/modules/library/library-filters/library-filters.component.html index 33c73c71c17..79e797d46d4 100644 --- a/src/app/modules/library/library-filters/library-filters.component.html +++ b/src/app/modules/library/library-filters/library-filters.component.html @@ -1,7 +1,7 @@
- +