Skip to content

Commit 5e42130

Browse files
Alicia ZanggerAoNoOokami
Alicia Zangger
authored andcommitted
document: adapt display of field "notes"
* Creates a pipe to display the field "notes". * Corrects detail view accordingly. Co-Authored-by: Alicia Zangger <[email protected]>
1 parent fed49b9 commit 5e42130

File tree

4 files changed

+63
-28
lines changed

4 files changed

+63
-28
lines changed

projects/admin/src/app/app.module.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* along with this program. If not, see <http://www.gnu.org/licenses/>.
1616
*/
1717

18-
import { HTTP_INTERCEPTORS, HttpClientModule } from '@angular/common/http';
18+
import { HttpClientModule, HTTP_INTERCEPTORS } from '@angular/common/http';
1919
import { LOCALE_ID, NgModule } from '@angular/core';
2020
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
2121
import { BrowserModule } from '@angular/platform-browser';
@@ -42,6 +42,7 @@ import { MenuComponent } from './menu/menu.component';
4242
import { BioInformationsPipe } from './pipe/bio-informations.pipe';
4343
import { BirthDatePipe } from './pipe/birth-date.pipe';
4444
import { MefTitlePipe } from './pipe/mef-title.pipe';
45+
import { NotesFormatPipe } from './pipe/notes-format.pipe';
4546
import { AcquisitionOrderBriefViewComponent } from './record/brief-view/acquisition-order-brief-view.component';
4647
import { BudgetsBriefViewComponent } from './record/brief-view/budgets-brief-view.component';
4748
import { CircPoliciesBriefViewComponent } from './record/brief-view/circ-policies-brief-view.component';
@@ -184,7 +185,8 @@ import { SharedPipesModule } from './shared/shared-pipes.module';
184185
SerialHoldingItemComponent,
185186
SerialHoldingDetailViewComponent,
186187
HoldingDetailViewComponent,
187-
DefaultHoldingItemComponent
188+
DefaultHoldingItemComponent,
189+
NotesFormatPipe
188190
],
189191
imports: [
190192
AppRoutingModule,
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
import { NotesFormatPipe } from './notes-format.pipe';
2+
3+
describe('NotesFormatPipe', () => {
4+
it('create an instance', () => {
5+
const pipe = new NotesFormatPipe();
6+
expect(pipe).toBeTruthy();
7+
});
8+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { Pipe, PipeTransform } from '@angular/core';
2+
3+
@Pipe({
4+
name: 'notesFormat'
5+
})
6+
export class NotesFormatPipe implements PipeTransform {
7+
8+
transform(notes: any): any {
9+
if (notes) {
10+
const notesText = {};
11+
for (const note of notes) {
12+
if (!(note.noteType in notesText)) {
13+
notesText[note.noteType] = [note.label];
14+
} else {
15+
notesText[note.noteType].push(note.label);
16+
}
17+
}
18+
return notesText;
19+
}
20+
return null;
21+
22+
}
23+
}

projects/admin/src/app/record/detail-view/document-detail-view/document-detail-view.component.html

+28-26
Original file line numberDiff line numberDiff line change
@@ -201,41 +201,43 @@ <h3>{{ altgr_title }}</h3>
201201
</ng-container>
202202

203203
<!-- NOTES -->
204-
<ng-container *ngIf="record.metadata.notes_text && record.metadata.notes_text.general">
204+
<ng-container *ngIf="record.metadata.note && record.metadata.note.length > 0 && record.metadata.note | notesFormat as notes">
205+
<ng-container *ngIf="notes.general">
205206
<dt class="col-sm-4 offset-sm-2 offset-md-0" translate>
206207
Note
207208
</dt>
208209
<dd [ngClass]="ddCssClass">
209210
<ul class="list-unstyled mb-0">
210211
<li
211-
*ngFor="let note of record.metadata.notes_text.general"
212+
*ngFor="let note of notes.general"
212213
>{{ note }}</li>
213214
</ul>
214215
</dd>
215-
</ng-container>
216-
<ng-container *ngIf="record.metadata.notes_text && record.metadata.notes_text.otherPhysicalDetails">
217-
<dt class="col-sm-4 offset-sm-2 offset-md-0" translate>
218-
Physical details
219-
</dt>
220-
<dd [ngClass]="ddCssClass">
221-
<ul class="list-unstyled mb-0">
222-
<li
223-
*ngFor="let note of record.metadata.notes_text.otherPhysicalDetails"
224-
>{{ note }}</li>
225-
</ul>
226-
</dd>
227-
</ng-container>
228-
<ng-container *ngIf="record.metadata.notes_text && record.metadata.notes_text.accompanyingMaterial">
229-
<dt class="col-sm-4 offset-sm-2 offset-md-0" translate>
230-
Accompanying material
231-
</dt>
232-
<dd [ngClass]="ddCssClass">
233-
<ul class="list-unstyled mb-0">
234-
<li
235-
*ngFor="let note of record.metadata.notes_text.accompanyingMaterial"
236-
>{{ note }}</li>
237-
</ul>
238-
</dd>
216+
</ng-container>
217+
<ng-container *ngIf="notes.otherPhysicalDetails">
218+
<dt class="col-sm-4 offset-sm-2 offset-md-0" translate>
219+
Physical details
220+
</dt>
221+
<dd [ngClass]="ddCssClass">
222+
<ul class="list-unstyled mb-0">
223+
<li
224+
*ngFor="let note of notes.otherPhysicalDetails"
225+
>{{ note }}</li>
226+
</ul>
227+
</dd>
228+
</ng-container>
229+
<ng-container *ngIf="notes.accompanyingMaterial">
230+
<dt class="col-sm-4 offset-sm-2 offset-md-0" translate>
231+
Accompanying material
232+
</dt>
233+
<dd [ngClass]="ddCssClass">
234+
<ul class="list-unstyled mb-0">
235+
<li
236+
*ngFor="let note of notes.accompanyingMaterial"
237+
>{{ note }}</li>
238+
</ul>
239+
</dd>
240+
</ng-container>
239241
</ng-container>
240242

241243
<!-- SERIES -->

0 commit comments

Comments
 (0)