Skip to content

Commit f2b0bac

Browse files
fix(Unit Library): Redesign 2025 Part 2 (#2153)
Co-authored-by: Jonathan Lim-Breitbart <[email protected]>
1 parent ceb0006 commit f2b0bac

File tree

9 files changed

+93
-68
lines changed

9 files changed

+93
-68
lines changed

src/app/modules/library/library-project-details/library-project-details.component.html

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,16 @@
6868
>
6969
</p>
7070
}
71+
@if (project.metadata.resources?.length > 0) {
72+
<p>
73+
<strong i18n>Resources:</strong>
74+
{{ first ? ' ' : '' }}
75+
@for (resource of project.metadata.resources; track resource.name; let last = $last) {
76+
<a href="{{ resource.url }}" target="_blank">{{ resource.name }}</a
77+
>{{ last ? '' : ' • ' }}
78+
}
79+
</p>
80+
}
7181
@if (project.metadata.summary) {
7282
<div [innerHTML]="project.metadata.summary"></div>
7383
}
@@ -128,16 +138,6 @@
128138
}
129139
</p>
130140
}
131-
@if (project.metadata.resources?.length > 0) {
132-
<p>
133-
<strong i18n>Resources:</strong>
134-
{{ first ? ' ' : '' }}
135-
@for (resource of project.metadata.resources; track resource.name; let last = $last) {
136-
<a href="{{ resource.url }}" target="_blank">{{ resource.name }}</a
137-
>{{ last ? '' : ' • ' }}
138-
}
139-
</p>
140-
}
141141
@if (project.tags) {
142142
<unit-tags [tags]="project.tags" />
143143
}
@@ -208,7 +208,7 @@
208208
>
209209
</button>
210210
}
211-
@if (project.metadata.unitType === 'Platform') {
211+
@if (canPreview) {
212212
<button mat-flat-button color="primary" (click)="previewProject()">
213213
<mat-icon>preview</mat-icon>&nbsp;<ng-container i18n>Preview</ng-container>
214214
</button>

src/app/modules/library/library-project-details/library-project-details.component.spec.ts

Lines changed: 23 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -13,22 +13,17 @@ let component: LibraryProjectDetailsComponent;
1313
let fixture: ComponentFixture<LibraryProjectDetailsComponent>;
1414
describe('LibraryProjectDetailsComponent', () => {
1515
beforeEach(() => {
16-
TestBed.configureTestingModule({
17-
declarations: [MockComponent(LibraryProjectMenuComponent)],
18-
imports: [LibraryProjectDetailsComponent],
19-
providers: [
20-
MockProviders(ConfigService, MatDialog, MatDialogRef, UserService),
21-
{ provide: MAT_DIALOG_DATA, useValue: {} }
22-
]
23-
});
24-
fixture = TestBed.createComponent(LibraryProjectDetailsComponent);
25-
component = fixture.componentInstance;
2616
const project: Project = new Project();
2717
project.id = 1;
2818
project.name = 'Photosynthesis & Cellular Respiration';
2919
project.projectThumb = 'photo.png';
3020
project.metadata = {
3121
grades: ['7'],
22+
standards: {
23+
ngss: [{ id: 'MS-LS1-6', name: 'MS-LS1-6', url: 'http://ngss.com' }],
24+
commonCore: [],
25+
learningForJustice: []
26+
},
3227
title: 'Photosynthesis & Cellular Respiration',
3328
summary: 'A really great unit.',
3429
unitType: 'Platform',
@@ -39,14 +34,18 @@ describe('LibraryProjectDetailsComponent', () => {
3934
],
4035
resources: [{ name: 'Resource 1', uri: 'http://example.com/resource1' }]
4136
};
42-
component['standards'] = {
43-
ngss: [{ id: 'MS-LS1-6', name: 'MS-LS1-6', url: 'http://ngss.com' }],
44-
commonCore: [],
45-
learningForJustice: []
46-
};
47-
component['project'] = new Project(project);
37+
TestBed.configureTestingModule({
38+
declarations: [MockComponent(LibraryProjectMenuComponent)],
39+
imports: [LibraryProjectDetailsComponent],
40+
providers: [
41+
MockProviders(ConfigService, MatDialog, MatDialogRef, UserService),
42+
{ provide: MAT_DIALOG_DATA, useValue: { project: project } }
43+
]
44+
});
45+
46+
fixture = TestBed.createComponent(LibraryProjectDetailsComponent);
47+
component = fixture.componentInstance;
4848
component['parentProject'] = new ParentProject();
49-
component['setLicenseInfo']();
5049
fixture.detectChanges();
5150
});
5251

@@ -106,8 +105,14 @@ function isResourceUnitType_HideButtons() {
106105
fixture.detectChanges();
107106
});
108107

109-
it('should hide buttons when unit type is Resource', () => {
108+
it('should hide Use with Class button when unit type is Resource', () => {
109+
expect(getButtonWithText('Use with Class')).toBeFalsy();
110+
});
111+
112+
it('should hide Preview button when unit type is Resource and it has no resources', () => {
110113
expect(getButtonWithText('Use with Class')).toBeFalsy();
114+
component['canPreview'] = false;
115+
fixture.detectChanges();
111116
expect(getButtonWithText('Preview')).toBeFalsy();
112117
});
113118
});

src/app/modules/library/library-project-details/library-project-details.component.ts

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ import { FlexLayoutModule } from '@angular/flex-layout';
3737
})
3838
export class LibraryProjectDetailsComponent implements OnInit {
3939
protected authorsString: string = '';
40+
protected canPreview: boolean;
4041
protected isCopy: boolean;
4142
protected isTeacher: boolean;
4243
protected isRunProject: false;
@@ -73,6 +74,9 @@ export class LibraryProjectDetailsComponent implements OnInit {
7374
}
7475
this.standards = this.project.metadata.standards;
7576
this.setLicenseInfo();
77+
this.canPreview = !(
78+
this.project.metadata.unitType === 'Other' && this.project.metadata.resources.length === 0
79+
);
7680
}
7781
}
7882

@@ -104,11 +108,21 @@ export class LibraryProjectDetailsComponent implements OnInit {
104108
}
105109

106110
protected previewProject(): void {
107-
window.open(
108-
this.project.wiseVersion === 4
109-
? `${this.configService.getWISE4Hostname()}` +
110-
`/previewproject.html?projectId=${this.project.id}`
111-
: `/preview/unit/${this.project.id}`
112-
);
111+
if (this.project.wiseVersion === 4) {
112+
window.open(
113+
`${this.configService.getWISE4Hostname()}` +
114+
`/previewproject.html?projectId=${this.project.id}`
115+
);
116+
} else {
117+
this.previewProjectV5();
118+
}
119+
}
120+
121+
private previewProjectV5(): void {
122+
if (this.project.metadata.unitType === 'Platform') {
123+
window.open(`/preview/unit/${this.project.id}`);
124+
} else {
125+
window.open(this.project.metadata.resources[0].url);
126+
}
113127
}
114128
}

src/app/modules/library/library-project-disciplines/library-project-disciplines.component.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@ export class LibraryProjectDisciplinesComponent implements OnInit {
2020
ESS: '#2E7D32',
2121
ETS: '#1565C0',
2222
LS: '#D81B60',
23-
PS: '#8E24AA'
23+
Math: '#444444',
24+
PS: '#8E24AA',
25+
SJ: '#F57C00'
2426
};
2527
this.disciplines.forEach((discipline) => {
2628
discipline.color = colors[discipline.id] ?? '#000000';

src/app/modules/library/library/library.component.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ export abstract class LibraryComponent implements OnInit {
7373
return project;
7474
})
7575
.filter((project) => project.visible)
76-
.sort((a, b) => a.metadata.title.localeCompare(b.metadata.title));
76+
.sort((a, b) => b.id - a.id);
7777
this.emitNumberOfProjectsVisible(this.countVisibleProjects(this.filteredProjects));
7878
this.pageIndex = 0;
7979
this.setPagination();

src/app/modules/library/personal-library/personal-library.component.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ function showArchivedProjects() {
142142
describe('archived units view', () => {
143143
it('only shows archived units', async () => {
144144
await harness.showArchivedView();
145-
expect(await harness.getProjectIdsInView()).toEqual([projectId1, projectId2]);
145+
expect(await harness.getProjectIdsInView()).toEqual([projectId2, projectId1]);
146146
});
147147
});
148148
}

src/app/modules/shared/select-menu/select-menu.component.html

Lines changed: 13 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -6,16 +6,20 @@
66
[(value)]="value"
77
[multiple]="multiple"
88
>
9-
<mat-select-trigger *ngIf="multiple">
10-
{{ selectField.value ? selectField.value[0] : '' }}
11-
@if (selectField.value?.length > 1) {
12-
<span> (+{{ selectField.value.length - 1 }} <ng-container i18n>more</ng-container>) </span>
13-
}
14-
</mat-select-trigger>
9+
@if (multiple) {
10+
<mat-select-trigger>
11+
{{ selectField.value ? selectField.value[0] : '' }}
12+
@if (selectField.value?.length > 1) {
13+
<span>
14+
(+{{ selectField.value.length - 1 }} <ng-container i18n>more</ng-container>)
15+
</span>
16+
}
17+
</mat-select-trigger>
18+
}
1519
@for (option of options; track option.id) {
16-
<mat-option [value]="option[valueProp]">
17-
{{ option[viewValueProp] }}
18-
</mat-option>
20+
<mat-option [value]="option[valueProp]">
21+
{{ option[viewValueProp] }}
22+
</mat-option>
1923
}
2024
</mat-select>
2125
</mat-form-field>

src/app/modules/shared/select-menu/select-menu.component.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,11 +12,11 @@ import { FormControl, FormsModule, ReactiveFormsModule } from '@angular/forms';
1212
import { MatSelectModule } from '@angular/material/select';
1313

1414
@Component({
15-
encapsulation: ViewEncapsulation.None,
16-
imports: [CommonModule, FormsModule, MatSelectModule, ReactiveFormsModule],
17-
selector: 'app-select-menu',
18-
styleUrl: './select-menu.component.scss',
19-
templateUrl: './select-menu.component.html'
15+
encapsulation: ViewEncapsulation.None,
16+
imports: [CommonModule, FormsModule, MatSelectModule, ReactiveFormsModule],
17+
selector: 'app-select-menu',
18+
styleUrl: './select-menu.component.scss',
19+
templateUrl: './select-menu.component.html'
2020
})
2121
export class SelectMenuComponent implements OnInit {
2222
@Output('update') change: EventEmitter<string> = new EventEmitter<string>();

src/messages.xlf

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5834,7 +5834,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
58345834
</context-group>
58355835
<context-group purpose="location">
58365836
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.ts</context>
5837-
<context context-type="linenumber">51</context>
5837+
<context context-type="linenumber">52</context>
58385838
</context-group>
58395839
</trans-unit>
58405840
<trans-unit id="3785094524839933600" datatype="html">
@@ -5845,7 +5845,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
58455845
</context-group>
58465846
<context-group purpose="location">
58475847
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.ts</context>
5848-
<context context-type="linenumber">49</context>
5848+
<context context-type="linenumber">50</context>
58495849
</context-group>
58505850
</trans-unit>
58515851
<trans-unit id="9120263586696781927" datatype="html">
@@ -5856,7 +5856,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
58565856
</context-group>
58575857
<context-group purpose="location">
58585858
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.ts</context>
5859-
<context context-type="linenumber">50</context>
5859+
<context context-type="linenumber">51</context>
58605860
</context-group>
58615861
</trans-unit>
58625862
<trans-unit id="2247270192251966992" datatype="html">
@@ -5909,32 +5909,32 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
59095909
<context context-type="linenumber">38,40</context>
59105910
</context-group>
59115911
</trans-unit>
5912+
<trans-unit id="4849120309760741886" datatype="html">
5913+
<source>Resources:</source>
5914+
<context-group purpose="location">
5915+
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5916+
<context context-type="linenumber">73,75</context>
5917+
</context-group>
5918+
</trans-unit>
59125919
<trans-unit id="5615583660036576020" datatype="html">
59135920
<source>Discipline:</source>
59145921
<context-group purpose="location">
59155922
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5916-
<context context-type="linenumber">76,78</context>
5923+
<context context-type="linenumber">86,88</context>
59175924
</context-group>
59185925
</trans-unit>
59195926
<trans-unit id="3217999400450328473" datatype="html">
59205927
<source>Features:</source>
59215928
<context-group purpose="location">
59225929
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5923-
<context context-type="linenumber">88,89</context>
5930+
<context context-type="linenumber">98,99</context>
59245931
</context-group>
59255932
</trans-unit>
59265933
<trans-unit id="1135894126071086314" datatype="html">
59275934
<source>Standards Addressed:</source>
59285935
<context-group purpose="location">
59295936
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5930-
<context context-type="linenumber">101,103</context>
5931-
</context-group>
5932-
</trans-unit>
5933-
<trans-unit id="4849120309760741886" datatype="html">
5934-
<source>Resources:</source>
5935-
<context-group purpose="location">
5936-
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5937-
<context context-type="linenumber">133,135</context>
5937+
<context context-type="linenumber">111,113</context>
59385938
</context-group>
59395939
</trans-unit>
59405940
<trans-unit id="8316240444829030702" datatype="html">
@@ -5983,7 +5983,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
59835983
<source>Use with Class</source>
59845984
<context-group purpose="location">
59855985
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.html</context>
5986-
<context context-type="linenumber">207,211</context>
5986+
<context context-type="linenumber">207,212</context>
59875987
</context-group>
59885988
<context-group purpose="location">
59895989
<context context-type="sourcefile">src/app/teacher/create-run-dialog/create-run-dialog.component.html</context>
@@ -6029,7 +6029,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
60296029
<source>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.</source>
60306030
<context-group purpose="location">
60316031
<context context-type="sourcefile">src/app/modules/library/library-project-details/library-project-details.component.ts</context>
6032-
<context context-type="linenumber">43</context>
6032+
<context context-type="linenumber">44</context>
60336033
</context-group>
60346034
</trans-unit>
60356035
<trans-unit id="3538004306368214541" datatype="html">
@@ -6625,7 +6625,7 @@ Click &quot;Cancel&quot; to keep the invalid JSON open so you can fix it.</sourc
66256625
<source>more</source>
66266626
<context-group purpose="location">
66276627
<context context-type="sourcefile">src/app/modules/shared/select-menu/select-menu.component.html</context>
6628-
<context context-type="linenumber">12,15</context>
6628+
<context context-type="linenumber">14,18</context>
66296629
</context-group>
66306630
<context-group purpose="location">
66316631
<context context-type="sourcefile">src/app/modules/shared/standards-select-menu/standards-select-menu.component.html</context>

0 commit comments

Comments
 (0)