From 2f573277fce9fe9ae24b5afbb7cac41eb956d430 Mon Sep 17 00:00:00 2001 From: Renaud Michotte Date: Wed, 25 Nov 2020 14:12:08 +0100 Subject: [PATCH] items: display item notes Replaces the sticky icon by the note content into the document detailed view. Closes rero/rero-ils#1501 Co-Authored-by: Renaud Michotte --- projects/admin/src/app/app.module.ts | 4 +- .../default-holding-item.component.html | 98 +++++++++---------- .../default-holding-item.component.ts | 39 ++++---- .../holding-item-in-collection.component.html | 22 +++-- .../holding-item-in-collection.component.ts | 13 +-- .../holding-item-note.component.spec.ts | 42 ++++++++ .../holding-item-note.component.ts | 32 ++++++ .../holding/holding.component.html | 2 - .../serial-holding-item.component.html | 97 +++++++++--------- 9 files changed, 209 insertions(+), 140 deletions(-) create mode 100644 projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.spec.ts create mode 100644 projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.ts diff --git a/projects/admin/src/app/app.module.ts b/projects/admin/src/app/app.module.ts index c9a1d7b3e..1967a50ca 100644 --- a/projects/admin/src/app/app.module.ts +++ b/projects/admin/src/app/app.module.ts @@ -135,6 +135,7 @@ import { UiRemoteTypeaheadService } from './service/ui-remote-typeahead.service' import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component'; import { FrontpageBoardComponent } from './widgets/frontpage/frontpage-board/frontpage-board.component'; import { FrontpageComponent } from './widgets/frontpage/frontpage.component'; +import { HoldingItemNoteComponent } from './record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component'; /** Init application factory */ export function appInitFactory(appInitService: AppInitService) { @@ -219,7 +220,8 @@ export function appInitFactory(appInitService: AppInitService) { CustomShortcutHelpComponent, ContributionDetailViewComponent, PersonDetailViewComponent, - CorporateBodiesDetailViewComponent + CorporateBodiesDetailViewComponent, + HoldingItemNoteComponent ], imports: [ AppRoutingModule, diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.html b/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.html index 44b1bcbd8..44ac5a35e 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.html +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.html @@ -14,65 +14,59 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - -
- - {{ item.metadata.notes.length }} - - - {{ item.metadata.barcode }} - -
-
- {{ item.metadata.status | translate }} -
-
- {{ item.metadata.enumerationAndChronology }} -
-
- {{ callNumber }} -
-
- - - -
-
- - - - +
+
+ + -
- + + +
+
+
- -
+ + + diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.ts b/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.ts index 5301fddab..a2889a645 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.ts +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/default-holding-item/default-holding-item.component.ts @@ -31,18 +31,29 @@ import { ItemRequestComponent } from '../../item-request/item-request.component' }) export class DefaultHoldingItemComponent implements OnInit { + // COMPONENT ATTRIBUTES ============================================================ /** Holding record */ @Input() holding: any; - /** Item Record */ @Input() item: any; - /** Event for delete Item */ @Output() deleteItem = new EventEmitter(); /** Item permissions */ permissions: any; + // GETTER & SETTER ================================================================= + /** + * Get formatted item call numbers + * @return formatted string + */ + get callNumbers(): string { + return [this.item.metadata.call_number, this.item.metadata.second_call_number || null] + .filter(element => element !== null) + .join(' | '); + } + + // CONSTRUCTOR & HOOKS ============================================================== /** * Constructor * @param _recordUiService - RecordUiService @@ -59,13 +70,15 @@ export class DefaultHoldingItemComponent implements OnInit { protected _itemService: ItemsService ) { } - /** Init */ + /** OnInit hook */ ngOnInit() { - this.getPermissions(); + this._getPermissions(); } + + // COMPONENT FUNCTIONS ================================================================ /** Get permissions */ - getPermissions() { + private _getPermissions() { const permissionObs = this._recordPermissionService.getPermission('items', this.item.metadata.pid); const canRequestObs = this._itemService.canRequest(this.item.metadata.pid); forkJoin([permissionObs, canRequestObs]).subscribe( @@ -75,18 +88,6 @@ export class DefaultHoldingItemComponent implements OnInit { }); } - /** - * Get formatted call number - * - * Join call number and second call number separate by ` - ` - * @returns - formatted string - */ - get callNumber(): string { - if (this.item.metadata.second_call_number) { - return this.item.metadata.call_number + ' | ' + this.item.metadata.second_call_number; - } - return this.item.metadata.call_number; - } /** * Add request on item and refresh permissions @@ -96,9 +97,7 @@ export class DefaultHoldingItemComponent implements OnInit { const modalRef = this._modalService.show(ItemRequestComponent, { initialState: { itemPid } }); - modalRef.content.onSubmit.pipe(first()).subscribe(value => { - this.getPermissions(); - }); + modalRef.content.onSubmit.pipe(first()).subscribe(_ => this._getPermissions()); } /** diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.html b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.html index d92da40cb..7b5019096 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.html +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.html @@ -14,14 +14,18 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> - -
- - Temporary location - - - {{ collection.metadata.title }} - {{ last ? '' : '; ' }} - + +
+
+ + Temporary location +
+
+ + + {{ collection.metadata.title }} + {{ last ? '' : '; ' }} + +
diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.ts b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.ts index ca5bdce2a..91fc25495 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.ts +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-in-collection/holding-item-in-collection.component.ts @@ -28,7 +28,6 @@ export class HoldingItemInCollectionComponent implements OnInit { /** Item pid */ @Input() itemPid: string; - /** CSS Class for div element */ @Input() class: string; @@ -39,9 +38,11 @@ export class HoldingItemInCollectionComponent implements OnInit { * Constructor * @param _recordService - RecordService */ - constructor(private _recordService: RecordService) { } + constructor( + private _recordService: RecordService + ) { } - /** Init */ + /** OnInit hook */ ngOnInit() { this.isItemInCollection(this.itemPid); } @@ -62,9 +63,9 @@ export class HoldingItemInCollectionComponent implements OnInit { 'title' ).pipe( map((result: any) => { - return this._recordService.totalHits(result.hits.total) === 0 - ? [] - : result.hits.hits; + return (this._recordService.totalHits(result.hits.total) === 0) + ? [] + : result.hits.hits; }) ).subscribe(collections => this.collections = collections); } diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.spec.ts b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.spec.ts new file mode 100644 index 000000000..e631b803a --- /dev/null +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.spec.ts @@ -0,0 +1,42 @@ +/* + * RERO ILS UI + * Copyright (C) 2020 RERO + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ + +import { ComponentFixture, TestBed } from '@angular/core/testing'; + +import { HoldingItemNoteComponent } from './holding-item-note.component'; + +describe('HoldingItemNoteComponent', () => { + let component: HoldingItemNoteComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ HoldingItemNoteComponent ] + }) + .compileComponents(); + }); + + beforeEach(() => { + fixture = TestBed.createComponent(HoldingItemNoteComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.ts b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.ts new file mode 100644 index 000000000..52fa83b67 --- /dev/null +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding-item-note/holding-item-note.component.ts @@ -0,0 +1,32 @@ +/* + * RERO ILS UI + * Copyright (C) 2020 RERO + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, version 3 of the License. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +import { Component, Input } from '@angular/core'; +import { ItemNote } from 'projects/admin/src/app/class/items'; + +@Component({ + selector: 'admin-holding-item-note', + template: ` +
+
{{ note.type.toString() | translate}}
+
+
+ ` +}) +export class HoldingItemNoteComponent { + /** the item note */ + @Input() note: ItemNote; +} diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding.component.html b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding.component.html index 05da73cbe..65a524115 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding.component.html +++ b/projects/admin/src/app/record/detail-view/document-detail-view/holding/holding.component.html @@ -74,7 +74,6 @@
. --> - - -
- {{ item.metadata.status }} -
-
- {{ item.metadata.enumerationAndChronology }} -
-
- {{ callNumber }} -
-
- - - -
-
- - - - +
+
+ + -
- + + +
+
+
- -
+ + +