diff --git a/src/app/curriculum/curriculum.component.spec.ts b/src/app/curriculum/curriculum.component.spec.ts index 6593c020dc7..4c554ff032b 100644 --- a/src/app/curriculum/curriculum.component.spec.ts +++ b/src/app/curriculum/curriculum.component.spec.ts @@ -23,7 +23,6 @@ describe('CurriculumComponent', () => { providers: [ MockProviders(ConfigService, UserService), MockProvider(LibraryService, { - filterValuesUpdated$: of(), communityLibraryProjectsSource$: of([]), numberOfPublicProjectsVisible$: of(3), numberOfPersonalProjectsVisible$: of(2) diff --git a/src/app/domain/projectFilterValues.ts b/src/app/domain/projectFilterValues.ts index 6d0c258ae43..49434eb6659 100644 --- a/src/app/domain/projectFilterValues.ts +++ b/src/app/domain/projectFilterValues.ts @@ -1,3 +1,4 @@ +import { Subject } from 'rxjs'; import { LibraryProject } from '../modules/library/libraryProject'; export class ProjectFilterValues { @@ -9,6 +10,8 @@ export class ProjectFilterValues { searchValue: string = ''; standardValue: string[] = []; unitTypeValue: string[] = []; + private updatedSource = new Subject(); + public updated$ = this.updatedSource.asObservable(); matches(project: LibraryProject): boolean { return ( @@ -116,4 +119,8 @@ export class ProjectFilterValues { ) ); } + + emitUpdated(): void { + this.updatedSource.next(); + } } diff --git a/src/app/modules/library/library-filters/library-filters.component.spec.ts b/src/app/modules/library/library-filters/library-filters.component.spec.ts index cf4412cc6d2..6301bbcc228 100644 --- a/src/app/modules/library/library-filters/library-filters.component.spec.ts +++ b/src/app/modules/library/library-filters/library-filters.component.spec.ts @@ -21,8 +21,7 @@ describe('LibraryFiltersComponent', () => { officialLibraryProjectsSource$: of([] as LibraryProject[]), communityLibraryProjectsSource$: of([] as LibraryProject[]), sharedLibraryProjectsSource$: of([] as LibraryProject[]), - personalLibraryProjectsSource$: of([] as LibraryProject[]), - filterValuesUpdated$: of() + personalLibraryProjectsSource$: of([] as LibraryProject[]) }), ProjectFilterValues ] @@ -45,15 +44,15 @@ describe('LibraryFiltersComponent', () => { expect(component['disciplineOptions'].length).toBe(2); }); - it('should call LibraryService.filterValuesUpdated when the search value changes', waitForAsync(() => { - const libraryServiceFilterValuesSpy = spyOn(TestBed.get(LibraryService), 'filterValuesUpdated'); + it('should call ProjectFilterValues.emitUpdated when the search value changes', waitForAsync(() => { + const spy = spyOn(TestBed.inject(ProjectFilterValues), 'emitUpdated'); component['searchUpdated']('photo'); - expect(libraryServiceFilterValuesSpy).toHaveBeenCalled(); + expect(spy).toHaveBeenCalled(); })); - it('should call LibraryService.filterValuesUpdated when a filter value changes', waitForAsync(() => { - const libraryServiceFilterValuesSpy = spyOn(TestBed.get(LibraryService), 'filterValuesUpdated'); + it('should call ProjectFilterValues.emitUpdated when a filter value changes', waitForAsync(() => { + const spy = spyOn(TestBed.inject(ProjectFilterValues), 'emitUpdated'); component['filterUpdated'](['Earth Sciences', 'Physical Sciences'], 'discipline'); - expect(libraryServiceFilterValuesSpy).toHaveBeenCalled(); + expect(spy).toHaveBeenCalled(); })); }); diff --git a/src/app/modules/library/library-filters/library-filters.component.ts b/src/app/modules/library/library-filters/library-filters.component.ts index 9dd7380d663..5599260ca3e 100644 --- a/src/app/modules/library/library-filters/library-filters.component.ts +++ b/src/app/modules/library/library-filters/library-filters.component.ts @@ -52,19 +52,19 @@ export class LibraryFiltersComponent { private libraryService: LibraryService, private utilService: UtilService ) { - libraryService.officialLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { + this.libraryService.officialLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { this.libraryProjects = projects; this.populateFilterOptions(); }); - libraryService.communityLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { + this.libraryService.communityLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { this.communityProjects = projects; this.populateFilterOptions(); }); - libraryService.sharedLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { + this.libraryService.sharedLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { this.sharedProjects = projects; this.populateFilterOptions(); }); - libraryService.personalLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { + this.libraryService.personalLibraryProjectsSource$.subscribe((projects: LibraryProject[]) => { this.personalProjects = projects; this.populateFilterOptions(); }); @@ -170,7 +170,7 @@ export class LibraryFiltersComponent { } private emitFilterValues(): void { - this.libraryService.filterValuesUpdated(); + this.filterValues.emitUpdated(); } protected clearFilterValues(): void { diff --git a/src/app/modules/library/library/library.component.ts b/src/app/modules/library/library/library.component.ts index dc8f6a5653d..c7ef3198240 100644 --- a/src/app/modules/library/library/library.component.ts +++ b/src/app/modules/library/library/library.component.ts @@ -24,9 +24,7 @@ export abstract class LibraryComponent implements OnInit { ) {} ngOnInit(): void { - this.subscriptions.add( - this.libraryService.filterValuesUpdated$.subscribe(() => this.filterUpdated()) - ); + this.subscriptions.add(this.filterValues.updated$.subscribe(() => this.filterUpdated())); } ngOnDestroy(): void { diff --git a/src/app/modules/library/official-library/official-library.component.spec.ts b/src/app/modules/library/official-library/official-library.component.spec.ts index c0fdd2a9b92..66c4481ee3c 100644 --- a/src/app/modules/library/official-library/official-library.component.spec.ts +++ b/src/app/modules/library/official-library/official-library.component.spec.ts @@ -11,7 +11,6 @@ import { ProjectFilterValues } from '../../../domain/projectFilterValues'; export class MockLibraryService { libraryGroupsSource$ = fakeAsyncResponse({}); officialLibraryProjectsSource$ = fakeAsyncResponse([]); - filterValuesUpdated$ = of(); implementationModelOptions: LibraryGroup[] = []; numberOfPublicProjectsVisible = new BehaviorSubject(0); getOfficialLibraryProjects() {} diff --git a/src/app/modules/library/public-library/public-library.component.spec.ts b/src/app/modules/library/public-library/public-library.component.spec.ts index 1d9a18cf6e6..06a7acafadd 100644 --- a/src/app/modules/library/public-library/public-library.component.spec.ts +++ b/src/app/modules/library/public-library/public-library.component.spec.ts @@ -15,7 +15,6 @@ describe('PublicLibraryComponent', () => { imports: [PublicLibraryComponent], providers: [ MockProvider(LibraryService, { - filterValuesUpdated$: of(), communityLibraryProjectsSource$: of([ { id: 1, name: 'P1' }, { id: 2, name: 'P2' } diff --git a/src/app/services/library.service.ts b/src/app/services/library.service.ts index 304b2fa4520..f2796bb7706 100644 --- a/src/app/services/library.service.ts +++ b/src/app/services/library.service.ts @@ -10,8 +10,6 @@ import { Router } from '@angular/router'; export class LibraryService { private libraryGroupsUrl = '/api/project/library'; private communityProjectsUrl = '/api/project/community'; - private filterValuesUpdatedSource = new Subject(); - public filterValuesUpdated$ = this.filterValuesUpdatedSource.asObservable(); private personalProjectsUrl = '/api/project/personal'; private sharedProjectsUrl = '/api/project/shared'; private copyProjectUrl = '/api/project/copy'; @@ -127,10 +125,6 @@ export class LibraryService { return this.http.post(this.copyProjectUrl, body, { headers: headers }); } - filterValuesUpdated(): void { - this.filterValuesUpdatedSource.next(); - } - addPersonalLibraryProject(project: LibraryProject) { this.newProjectSource.next(project); this.router.navigate(['/curriculum/personal'], { state: { newProjectId: project.id } }); @@ -154,6 +148,5 @@ export class LibraryService { this.communityLibraryProjectsSource.next([]); this.personalLibraryProjectsSource.next([]); this.sharedLibraryProjectsSource.next([]); - this.filterValuesUpdatedSource.next(); } } diff --git a/src/app/teacher/teacher-home/teacher-home.component.spec.ts b/src/app/teacher/teacher-home/teacher-home.component.spec.ts index efc581f6506..d25d8cb4ef0 100644 --- a/src/app/teacher/teacher-home/teacher-home.component.spec.ts +++ b/src/app/teacher/teacher-home/teacher-home.component.spec.ts @@ -6,11 +6,10 @@ import { User } from '../../domain/user'; import { Project } from '../../domain/project'; import { TeacherHomeComponent } from './teacher-home.component'; import { Run } from '../../domain/run'; -import { NO_ERRORS_SCHEMA, Component } from '@angular/core'; +import { NO_ERRORS_SCHEMA } from '@angular/core'; import { ConfigService } from '../../services/config.service'; import { Config } from '../../domain/config'; -import { LibraryService } from '../../services/library.service'; -import { RouterTestingModule } from '@angular/router/testing'; +import { provideRouter } from '@angular/router'; export function fakeAsyncResponse(data: T) { return defer(() => Promise.resolve(data)); @@ -39,7 +38,7 @@ export class MockTeacherService { run2.project = project2; runs.push(run1); runs.push(run2); - return Observable.create((observer) => { + return new Observable((observer) => { observer.next(runs); observer.complete(); }); @@ -65,8 +64,8 @@ export class MockUserService { user.roles = ['teacher']; user.username = 'DemoTeacher'; user.id = 123456; - return Observable.create((observer) => { - observer.next(user); + return new Observable((observer) => { + observer.next([user]); observer.complete(); }); } @@ -74,7 +73,7 @@ export class MockUserService { export class MockConfigService { getConfig(): Observable { - return Observable.create((observer) => { + return new Observable((observer) => { const config: Config = { contextPath: '/wise', logOutURL: '/logout', @@ -98,29 +97,22 @@ export class MockConfigService { } } -export class MockLibraryService { - clearAll(): void {} -} - describe('TeacherHomeComponent', () => { let component: TeacherHomeComponent; let fixture: ComponentFixture; - beforeEach( - waitForAsync(() => { - TestBed.configureTestingModule({ - declarations: [TeacherHomeComponent], - imports: [RouterTestingModule], - providers: [ - { provide: TeacherService, useClass: MockTeacherService }, - { provide: UserService, useClass: MockUserService }, - { provide: ConfigService, useClass: MockConfigService }, - { provide: LibraryService, useClass: MockLibraryService } - ], - schemas: [NO_ERRORS_SCHEMA] - }).compileComponents(); - }) - ); + beforeEach(waitForAsync(() => { + TestBed.configureTestingModule({ + declarations: [TeacherHomeComponent], + providers: [ + { provide: TeacherService, useClass: MockTeacherService }, + { provide: UserService, useClass: MockUserService }, + { provide: ConfigService, useClass: MockConfigService }, + provideRouter([]) + ], + schemas: [NO_ERRORS_SCHEMA] + }).compileComponents(); + })); beforeEach(() => { fixture = TestBed.createComponent(TeacherHomeComponent); diff --git a/src/app/teacher/teacher-home/teacher-home.component.ts b/src/app/teacher/teacher-home/teacher-home.component.ts index 0e91b68aec7..74b40a5be0b 100644 --- a/src/app/teacher/teacher-home/teacher-home.component.ts +++ b/src/app/teacher/teacher-home/teacher-home.component.ts @@ -3,14 +3,13 @@ import { UserService } from '../../services/user.service'; import { User } from '../../domain/user'; import { ConfigService } from '../../services/config.service'; import { MatTabGroup } from '@angular/material/tabs'; -import { LibraryService } from '../../services/library.service'; import { Router } from '@angular/router'; @Component({ - selector: 'app-teacher-home', - templateUrl: './teacher-home.component.html', - styleUrls: ['./teacher-home.component.scss'], - standalone: false + selector: 'app-teacher-home', + templateUrl: './teacher-home.component.html', + styleUrls: ['./teacher-home.component.scss'], + standalone: false }) export class TeacherHomeComponent implements OnInit { @ViewChild('tabs', { static: true }) tabs: MatTabGroup; @@ -26,7 +25,6 @@ export class TeacherHomeComponent implements OnInit { constructor( private userService: UserService, private configService: ConfigService, - private libraryService: LibraryService, private router: Router ) {} @@ -40,10 +38,6 @@ export class TeacherHomeComponent implements OnInit { }); } - ngOnDestroy() { - this.libraryService.clearAll(); - } - getUser() { this.userService.getUser().subscribe((user) => { this.user = user; diff --git a/src/assets/wise5/authoringTool/new-project-template.ts b/src/assets/wise5/authoringTool/new-project-template.ts index ca539786fc4..c035ab2e5fe 100644 --- a/src/assets/wise5/authoringTool/new-project-template.ts +++ b/src/assets/wise5/authoringTool/new-project-template.ts @@ -47,6 +47,7 @@ export const newProjectTemplate = { }, metadata: { title: '', + features: [], resources: [], unitType: 'Platform' }, diff --git a/src/messages.xlf b/src/messages.xlf index c7b9a98d7fd..192486b8aa9 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -2328,7 +2328,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/teacher/teacher-home/teacher-home.component.ts - 23 + 22 @@ -2339,7 +2339,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/teacher/teacher-home/teacher-home.component.ts - 22 + 21 src/app/teacher/teacher-run-list/teacher-run-list.component.html @@ -11494,7 +11494,7 @@ The branches will be removed but the steps will remain in the unit. src/assets/wise5/authoringTool/new-project-template.ts - 79 + 80 src/assets/wise5/classroomMonitor/classroomMonitorComponents/nodeGrading/node-grading-view/node-grading-view.component.html @@ -11777,7 +11777,7 @@ The branches will be removed but the steps will remain in the unit. Notebook src/assets/wise5/authoringTool/new-project-template.ts - 55 + 56 src/assets/wise5/services/notebookService.ts @@ -11788,11 +11788,11 @@ The branches will be removed but the steps will remain in the unit. note src/assets/wise5/authoringTool/new-project-template.ts - 67 + 68 src/assets/wise5/authoringTool/new-project-template.ts - 109 + 110 src/assets/wise5/services/notebookService.ts @@ -11803,11 +11803,11 @@ The branches will be removed but the steps will remain in the unit. notes src/assets/wise5/authoringTool/new-project-template.ts - 68 + 69 src/assets/wise5/authoringTool/new-project-template.ts - 110 + 111 src/assets/wise5/services/notebookService.ts @@ -11818,11 +11818,11 @@ The branches will be removed but the steps will remain in the unit. Notes src/assets/wise5/authoringTool/new-project-template.ts - 69 + 70 src/assets/wise5/authoringTool/new-project-template.ts - 111 + 112 src/assets/wise5/classroomMonitor/classroomMonitorComponents/notebook/notebook-workgroup-grading/notebook-workgroup-grading.component.html @@ -11841,7 +11841,7 @@ The branches will be removed but the steps will remain in the unit. report src/assets/wise5/authoringTool/new-project-template.ts - 77 + 78 src/assets/wise5/services/notebookService.ts @@ -11852,7 +11852,7 @@ The branches will be removed but the steps will remain in the unit. reports src/assets/wise5/authoringTool/new-project-template.ts - 78 + 79 src/assets/wise5/services/notebookService.ts @@ -11863,78 +11863,78 @@ The branches will be removed but the steps will remain in the unit. Final Report src/assets/wise5/authoringTool/new-project-template.ts - 86 + 87 Final summary report of what you learned in this unit src/assets/wise5/authoringTool/new-project-template.ts - 87 + 88 Use this space to write your final report using evidence from your notebook. src/assets/wise5/authoringTool/new-project-template.ts - 88 + 89 <h3>This is a heading</h3><p>This is a paragraph.</p> src/assets/wise5/authoringTool/new-project-template.ts - 89 + 90 Teacher Notebook src/assets/wise5/authoringTool/new-project-template.ts - 97 + 98 teacher notes src/assets/wise5/authoringTool/new-project-template.ts - 119 + 120 src/assets/wise5/authoringTool/new-project-template.ts - 120 + 121 Teacher Notes src/assets/wise5/authoringTool/new-project-template.ts - 121 + 122 src/assets/wise5/authoringTool/new-project-template.ts - 128 + 129 Notes for the teacher as they're running the WISE unit src/assets/wise5/authoringTool/new-project-template.ts - 129 + 130 Use this space to take notes for this unit src/assets/wise5/authoringTool/new-project-template.ts - 130 + 131 <p>Use this space to take notes for this unit</p> src/assets/wise5/authoringTool/new-project-template.ts - 131 + 132