From e13873de223f0bee611937a9989b8422f0113748 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Tue, 22 Apr 2025 13:52:53 -0700 Subject: [PATCH 1/6] use @if syntax --- .../select-menu/select-menu.component.html | 22 +++++++++++-------- .../select-menu/select-menu.component.ts | 10 ++++----- src/messages.xlf | 2 +- 3 files changed, 19 insertions(+), 15 deletions(-) diff --git a/src/app/modules/shared/select-menu/select-menu.component.html b/src/app/modules/shared/select-menu/select-menu.component.html index 1469f5955f8..2c59cf0722d 100644 --- a/src/app/modules/shared/select-menu/select-menu.component.html +++ b/src/app/modules/shared/select-menu/select-menu.component.html @@ -6,16 +6,20 @@ [(value)]="value" [multiple]="multiple" > - - {{ selectField.value ? selectField.value[0] : '' }} - @if (selectField.value?.length > 1) { - (+{{ selectField.value.length - 1 }} more) - } - + @if (multiple) { + + {{ selectField.value ? selectField.value[0] : '' }} + @if (selectField.value?.length > 1) { + + (+{{ selectField.value.length - 1 }} more) + + } + + } @for (option of options; track option.id) { - - {{ option[viewValueProp] }} - + + {{ option[viewValueProp] }} + } diff --git a/src/app/modules/shared/select-menu/select-menu.component.ts b/src/app/modules/shared/select-menu/select-menu.component.ts index 94fc59fbace..fccb4a02d21 100644 --- a/src/app/modules/shared/select-menu/select-menu.component.ts +++ b/src/app/modules/shared/select-menu/select-menu.component.ts @@ -12,11 +12,11 @@ import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms'; import { MatSelectModule } from '@angular/material/select'; @Component({ - encapsulation: ViewEncapsulation.None, - imports: [CommonModule, FormsModule, MatSelectModule, ReactiveFormsModule], - selector: 'app-select-menu', - styleUrl: './select-menu.component.scss', - templateUrl: './select-menu.component.html' + encapsulation: ViewEncapsulation.None, + imports: [CommonModule, FormsModule, MatSelectModule, ReactiveFormsModule], + selector: 'app-select-menu', + styleUrl: './select-menu.component.scss', + templateUrl: './select-menu.component.html' }) export class SelectMenuComponent implements OnInit { @Output('update') change: EventEmitter = new EventEmitter(); diff --git a/src/messages.xlf b/src/messages.xlf index ee8a09a25ce..2183ce8d735 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -6625,7 +6625,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.more src/app/modules/shared/select-menu/select-menu.component.html - 12,15 + 14,18 src/app/modules/shared/standards-select-menu/standards-select-menu.component.html From bc5a560db4cf38994ef68da7a91d22c0c1c665c9 Mon Sep 17 00:00:00 2001 From: Jonathan Lim-Breitbart Date: Tue, 22 Apr 2025 14:11:20 -0700 Subject: [PATCH 2/6] feat(Project Details): Move resources to top of unit info --- .../library-project-details.component.html | 20 +++++++++---------- src/messages.xlf | 20 +++++++++---------- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/app/modules/library/library-project-details/library-project-details.component.html b/src/app/modules/library/library-project-details/library-project-details.component.html index 5c36bc10a3e..38349ff65be 100644 --- a/src/app/modules/library/library-project-details/library-project-details.component.html +++ b/src/app/modules/library/library-project-details/library-project-details.component.html @@ -68,6 +68,16 @@ >

} + @if (project.metadata.resources?.length > 0) { +

+ Resources: + {{ first ? ' ' : '' }} + @for (resource of project.metadata.resources; track resource.name; let last = $last) { + {{ resource.name }}{{ last ? '' : ' • ' }} + } +

+ } @if (project.metadata.summary) {
} @@ -128,16 +138,6 @@ }

} - @if (project.metadata.resources?.length > 0) { -

- Resources: - {{ first ? ' ' : '' }} - @for (resource of project.metadata.resources; track resource.name; let last = $last) { - {{ resource.name }}{{ last ? '' : ' • ' }} - } -

- } @if (project.tags) { } diff --git a/src/messages.xlf b/src/messages.xlf index 2183ce8d735..890446d87b4 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -5909,32 +5909,32 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.38,40
+ + Resources: + + src/app/modules/library/library-project-details/library-project-details.component.html + 73,75 + + Discipline: src/app/modules/library/library-project-details/library-project-details.component.html - 76,78 + 86,88 Features: src/app/modules/library/library-project-details/library-project-details.component.html - 88,89 + 98,99 Standards Addressed: src/app/modules/library/library-project-details/library-project-details.component.html - 101,103 - - - - Resources: - - src/app/modules/library/library-project-details/library-project-details.component.html - 133,135 + 111,113 From 8fa7bcc3bea0fa9d5d3746adcfb055a10000725b Mon Sep 17 00:00:00 2001 From: Jonathan Lim-Breitbart Date: Tue, 22 Apr 2025 14:13:07 -0700 Subject: [PATCH 3/6] feat(Library): Add indicator colors for Math and STEM+ Social Justice (SJ) disciplines --- .../library-project-disciplines.component.ts | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/app/modules/library/library-project-disciplines/library-project-disciplines.component.ts b/src/app/modules/library/library-project-disciplines/library-project-disciplines.component.ts index 0772aff4d17..6f3f2d64401 100644 --- a/src/app/modules/library/library-project-disciplines/library-project-disciplines.component.ts +++ b/src/app/modules/library/library-project-disciplines/library-project-disciplines.component.ts @@ -20,7 +20,9 @@ export class LibraryProjectDisciplinesComponent implements OnInit { ESS: '#2E7D32', ETS: '#1565C0', LS: '#D81B60', - PS: '#8E24AA' + Math: '#444444', + PS: '#8E24AA', + SJ: '#F57C00' }; this.disciplines.forEach((discipline) => { discipline.color = colors[discipline.id] ?? '#000000'; From 52adb3cfe94eac8166713a4c787d67609a6fb3cf Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Tue, 22 Apr 2025 14:16:09 -0700 Subject: [PATCH 4/6] Hide preview only if the project is Other platform without any resources --- .../library-project-details.component.html | 2 +- .../library-project-details.component.ts | 26 ++++++++++++++----- src/messages.xlf | 10 +++---- 3 files changed, 26 insertions(+), 12 deletions(-) diff --git a/src/app/modules/library/library-project-details/library-project-details.component.html b/src/app/modules/library/library-project-details/library-project-details.component.html index 38349ff65be..445bb0c5157 100644 --- a/src/app/modules/library/library-project-details/library-project-details.component.html +++ b/src/app/modules/library/library-project-details/library-project-details.component.html @@ -208,7 +208,7 @@ > } - @if (project.metadata.unitType === 'Platform') { + @if (canPreview) { diff --git a/src/app/modules/library/library-project-details/library-project-details.component.ts b/src/app/modules/library/library-project-details/library-project-details.component.ts index 98d99f2f954..03207f3b7a0 100644 --- a/src/app/modules/library/library-project-details/library-project-details.component.ts +++ b/src/app/modules/library/library-project-details/library-project-details.component.ts @@ -37,6 +37,7 @@ import { FlexLayoutModule } from '@angular/flex-layout'; }) export class LibraryProjectDetailsComponent implements OnInit { protected authorsString: string = ''; + protected canPreview: boolean; protected isCopy: boolean; protected isTeacher: boolean; protected isRunProject: false; @@ -73,6 +74,9 @@ export class LibraryProjectDetailsComponent implements OnInit { } this.standards = this.project.metadata.standards; this.setLicenseInfo(); + this.canPreview = !( + this.project.metadata.unitType === 'Other' && this.project.metadata.resources.length === 0 + ); } } @@ -104,11 +108,21 @@ export class LibraryProjectDetailsComponent implements OnInit { } protected previewProject(): void { - window.open( - this.project.wiseVersion === 4 - ? `${this.configService.getWISE4Hostname()}` + - `/previewproject.html?projectId=${this.project.id}` - : `/preview/unit/${this.project.id}` - ); + if (this.project.wiseVersion === 4) { + window.open( + `${this.configService.getWISE4Hostname()}` + + `/previewproject.html?projectId=${this.project.id}` + ); + } else { + this.previewProjectV5(); + } + } + + private previewProjectV5(): void { + if (this.project.metadata.unitType === 'Platform') { + window.open(`/preview/unit/${this.project.id}`); + } else { + window.open(this.project.metadata.resources[0].url); + } } } diff --git a/src/messages.xlf b/src/messages.xlf index 890446d87b4..01b01a335f6 100644 --- a/src/messages.xlf +++ b/src/messages.xlf @@ -5834,7 +5834,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/modules/library/library-project-details/library-project-details.component.ts - 51 + 52 @@ -5845,7 +5845,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/modules/library/library-project-details/library-project-details.component.ts - 49 + 50 @@ -5856,7 +5856,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it. src/app/modules/library/library-project-details/library-project-details.component.ts - 50 + 51 @@ -5983,7 +5983,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.Use with Class src/app/modules/library/library-project-details/library-project-details.component.html - 207,211 + 207,212 src/app/teacher/create-run-dialog/create-run-dialog.component.html @@ -6029,7 +6029,7 @@ Click "Cancel" to keep the invalid JSON open so you can fix it.License pertains to original content created by the author(s). Authors are responsible for the usage and attribution of any third-party content linked to or included in this work. src/app/modules/library/library-project-details/library-project-details.component.ts - 43 + 44 From 14455dd19bc30dcb55426514ef4ba80e2a079212 Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Tue, 22 Apr 2025 14:19:52 -0700 Subject: [PATCH 5/6] Order units by id descending --- src/app/modules/library/library/library.component.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/modules/library/library/library.component.ts b/src/app/modules/library/library/library.component.ts index 84df4eb34c0..db91d47f839 100644 --- a/src/app/modules/library/library/library.component.ts +++ b/src/app/modules/library/library/library.component.ts @@ -73,7 +73,7 @@ export abstract class LibraryComponent implements OnInit { return project; }) .filter((project) => project.visible) - .sort((a, b) => a.metadata.title.localeCompare(b.metadata.title)); + .sort((a, b) => b.id - a.id); this.emitNumberOfProjectsVisible(this.countVisibleProjects(this.filteredProjects)); this.pageIndex = 0; this.setPagination(); From 65efb6da094b3f915a2b16ea010cf9a3f28b143c Mon Sep 17 00:00:00 2001 From: Hiroki Terashima Date: Tue, 22 Apr 2025 14:53:07 -0700 Subject: [PATCH 6/6] Update tests to match new behavior --- .../library-project-details.component.spec.ts | 41 +++++++++++-------- .../personal-library.component.spec.ts | 2 +- 2 files changed, 24 insertions(+), 19 deletions(-) diff --git a/src/app/modules/library/library-project-details/library-project-details.component.spec.ts b/src/app/modules/library/library-project-details/library-project-details.component.spec.ts index 05935aea359..60fb5d20a58 100644 --- a/src/app/modules/library/library-project-details/library-project-details.component.spec.ts +++ b/src/app/modules/library/library-project-details/library-project-details.component.spec.ts @@ -13,22 +13,17 @@ let component: LibraryProjectDetailsComponent; let fixture: ComponentFixture; describe('LibraryProjectDetailsComponent', () => { beforeEach(() => { - TestBed.configureTestingModule({ - declarations: [MockComponent(LibraryProjectMenuComponent)], - imports: [LibraryProjectDetailsComponent], - providers: [ - MockProviders(ConfigService, MatDialog, MatDialogRef, UserService), - { provide: MAT_DIALOG_DATA, useValue: {} } - ] - }); - fixture = TestBed.createComponent(LibraryProjectDetailsComponent); - component = fixture.componentInstance; const project: Project = new Project(); project.id = 1; project.name = 'Photosynthesis & Cellular Respiration'; project.projectThumb = 'photo.png'; project.metadata = { grades: ['7'], + standards: { + ngss: [{ id: 'MS-LS1-6', name: 'MS-LS1-6', url: 'http://ngss.com' }], + commonCore: [], + learningForJustice: [] + }, title: 'Photosynthesis & Cellular Respiration', summary: 'A really great unit.', unitType: 'Platform', @@ -39,14 +34,18 @@ describe('LibraryProjectDetailsComponent', () => { ], resources: [{ name: 'Resource 1', uri: 'http://example.com/resource1' }] }; - component['standards'] = { - ngss: [{ id: 'MS-LS1-6', name: 'MS-LS1-6', url: 'http://ngss.com' }], - commonCore: [], - learningForJustice: [] - }; - component['project'] = new Project(project); + TestBed.configureTestingModule({ + declarations: [MockComponent(LibraryProjectMenuComponent)], + imports: [LibraryProjectDetailsComponent], + providers: [ + MockProviders(ConfigService, MatDialog, MatDialogRef, UserService), + { provide: MAT_DIALOG_DATA, useValue: { project: project } } + ] + }); + + fixture = TestBed.createComponent(LibraryProjectDetailsComponent); + component = fixture.componentInstance; component['parentProject'] = new ParentProject(); - component['setLicenseInfo'](); fixture.detectChanges(); }); @@ -106,8 +105,14 @@ function isResourceUnitType_HideButtons() { fixture.detectChanges(); }); - it('should hide buttons when unit type is Resource', () => { + it('should hide Use with Class button when unit type is Resource', () => { + expect(getButtonWithText('Use with Class')).toBeFalsy(); + }); + + it('should hide Preview button when unit type is Resource and it has no resources', () => { expect(getButtonWithText('Use with Class')).toBeFalsy(); + component['canPreview'] = false; + fixture.detectChanges(); expect(getButtonWithText('Preview')).toBeFalsy(); }); }); diff --git a/src/app/modules/library/personal-library/personal-library.component.spec.ts b/src/app/modules/library/personal-library/personal-library.component.spec.ts index c87f5f9f17c..6d03d6c1327 100644 --- a/src/app/modules/library/personal-library/personal-library.component.spec.ts +++ b/src/app/modules/library/personal-library/personal-library.component.spec.ts @@ -142,7 +142,7 @@ function showArchivedProjects() { describe('archived units view', () => { it('only shows archived units', async () => { await harness.showArchivedView(); - expect(await harness.getProjectIdsInView()).toEqual([projectId1, projectId2]); + expect(await harness.getProjectIdsInView()).toEqual([projectId2, projectId1]); }); }); }