From 396ce60d6542f2ff3e7b825bba489a72ff4b4b01 Mon Sep 17 00:00:00 2001 From: Lauren-D Date: Thu, 12 Oct 2023 12:40:31 +0200 Subject: [PATCH] acquisition: displaying more document information * Adds document brief view component. * Adds new formly field type to display document informations. Co-Authored-by: Lauren-D --- .../src/app/acquisition/acquisition.module.ts | 7 ++- .../src/app/acquisition/acquisition.scss | 21 ++++++- .../order-line/order-line.component.html | 19 +++---- .../receipt-detail-view.component.html | 30 +++++----- .../receipt-detail-view.component.scss | 15 +---- .../receipt-detail-view.component.ts | 2 +- .../receipt-form/order-receipt-form.ts | 9 +-- .../receipt-summary.component.html | 13 +++-- .../type/field-document-brief-view.type.ts | 49 ++++++++++++++++ .../document-brief-view.component.html | 51 +++++++++++++++++ .../document-brief-view.component.scss | 26 +++++++++ .../document-brief-view.component.spec.ts | 41 +++++++++++++ .../document-brief-view.component.ts | 57 +++++++++++++++++++ .../lib/pipe/identifiedby-label.pipe.spec.ts | 26 +++++++++ .../src/lib/pipe/identifiedby-label.pipe.ts | 34 +++++++++++ projects/shared/src/lib/shared.module.ts | 5 ++ projects/shared/src/public-api.ts | 2 + 17 files changed, 354 insertions(+), 53 deletions(-) create mode 100644 projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts create mode 100644 projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.html create mode 100644 projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.scss create mode 100644 projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.spec.ts create mode 100644 projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.ts create mode 100644 projects/shared/src/lib/pipe/identifiedby-label.pipe.spec.ts create mode 100644 projects/shared/src/lib/pipe/identifiedby-label.pipe.ts diff --git a/projects/admin/src/app/acquisition/acquisition.module.ts b/projects/admin/src/app/acquisition/acquisition.module.ts index dfe994b47..36baf91a3 100644 --- a/projects/admin/src/app/acquisition/acquisition.module.ts +++ b/projects/admin/src/app/acquisition/acquisition.module.ts @@ -1,7 +1,7 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO - * Copyright (C) 2021 UCLouvain + * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2023 UCLouvain * * 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 @@ -46,6 +46,7 @@ import { OrderReceiptViewComponent } from './components/receipt/receipt-form/ord import { OrderSummaryComponent } from './components/order/order-summary/order-summary.component'; import { ReceiptListComponent } from './components/receipt/receipt-list/receipt-list.component'; import { registerFormlyExtension } from './formly/extension'; +import { FieldDocumentBriefViewTypeComponent } from './formly/type/field-document-brief-view.type'; import { FieldRefTypeComponent } from './formly/type/field-ref.type'; import { RepeatTypeComponent } from './formly/type/repeat-section.type'; import { SelectAccountComponent } from './formly/type/select-account/select-account.component'; @@ -70,6 +71,7 @@ import { PreviewEmailModule } from '../shared/preview-email/preview-email.module AccountDetailViewComponent, BudgetsBriefViewComponent, BudgetDetailViewComponent, + FieldDocumentBriefViewTypeComponent, FieldRefTypeComponent, InputNoLabelWrapperComponent, NegativeAmountPipe, @@ -103,6 +105,7 @@ import { PreviewEmailModule } from '../shared/preview-email/preview-email.module FormlyModule.forChild({ types: [ { name: 'repeat', component: RepeatTypeComponent }, + { name: 'field-document-brief-view', component: FieldDocumentBriefViewTypeComponent }, { name: 'field-ref', component: FieldRefTypeComponent }, { name: 'select-account', component: SelectAccountComponent } ], diff --git a/projects/admin/src/app/acquisition/acquisition.scss b/projects/admin/src/app/acquisition/acquisition.scss index 201d3923a..f763d9579 100644 --- a/projects/admin/src/app/acquisition/acquisition.scss +++ b/projects/admin/src/app/acquisition/acquisition.scss @@ -1,7 +1,7 @@ /* * RERO ILS UI - * Copyright (C) 2021 RERO - * Copyright (C) 2021 UCLouvain + * Copyright (C) 2021-2023 RERO + * Copyright (C) 2021-2023 UCLouvain * * 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 @@ -48,6 +48,23 @@ } } +// receipt =================================================================== +// Use these classes to manage receipt resources +// =========================================================================== +.receipt { + .account-number { + font-size: $small-font-size; + color: $secondary; + font-weight: bold; + &:before { + content: '['; + } + &:after { + content: ']'; + } + } +} + // REMOVE GUTTER ============================================================== // Some DOM element has gutter to to bootstrap grid system. Using the // following classes we can remove this gutters. diff --git a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html index 9bfda939f..cc88950c9 100644 --- a/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html +++ b/projects/admin/src/app/acquisition/components/order/order-detail-view/order-line/order-line.component.html @@ -1,7 +1,7 @@ -
+
{{ line.quantity }}x - - {{ line.document.title | truncateText }} - +
+ + + + + + +
diff --git a/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts b/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts new file mode 100644 index 000000000..aec2624ff --- /dev/null +++ b/projects/admin/src/app/acquisition/formly/type/field-document-brief-view.type.ts @@ -0,0 +1,49 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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, OnInit } from '@angular/core'; +import { FieldType } from '@ngx-formly/core'; +import { RecordService } from '@rero/ng-core'; + +@Component({ + selector: 'admin-formly-field-type', + template: ` + + + + ` +}) +export class FieldDocumentBriefViewTypeComponent extends FieldType implements OnInit { + + /** record */ + record: any; + + /** + * Constructor + * @param _recordService - RecordService + */ + constructor(private _recordService: RecordService) { + super(); + } + + /** OnInit hook */ + ngOnInit(): void { + this._recordService.getRecord('documents', this.model['document']) + .subscribe((data: any) => this.record = data.metadata); + } +} diff --git a/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.html b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.html new file mode 100644 index 000000000..bbea4e170 --- /dev/null +++ b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.html @@ -0,0 +1,51 @@ + + + + {{ title }} + + + +
+ +
+
+ + +
+ {{ provisionActivityPublications | join }} +
+
+ + + +
+ ISBN: {{ identifiedBy | truncateText: 3 }} +
+
+ + +
+ ISSN: {{ identifiedBy | truncateText: 3 }} +
+
diff --git a/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.scss b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.scss new file mode 100644 index 000000000..02b6649b9 --- /dev/null +++ b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.scss @@ -0,0 +1,26 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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 'bootstrap/scss/functions'; +@import 'bootstrap/scss/variables'; + +.small-content{ + font-size: small; + color: $secondary; + font-weight: bold; +} diff --git a/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.spec.ts b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.spec.ts new file mode 100644 index 000000000..1d131c879 --- /dev/null +++ b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.spec.ts @@ -0,0 +1,41 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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 { DocumentBriefViewComponent } from './document-brief-view.component'; + +describe('DocumentBriefViewComponent', () => { + let component: DocumentBriefViewComponent; + let fixture: ComponentFixture; + + beforeEach(async () => { + await TestBed.configureTestingModule({ + declarations: [ DocumentBriefViewComponent ] + }) + .compileComponents(); + + fixture = TestBed.createComponent(DocumentBriefViewComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.ts b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.ts new file mode 100644 index 000000000..e77741b83 --- /dev/null +++ b/projects/shared/src/lib/component/documents/document-brief-view/document-brief-view.component.ts @@ -0,0 +1,57 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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'; + +@Component({ + selector: 'shared-document-brief-view', + templateUrl: './document-brief-view.component.html', + styleUrls: ['./document-brief-view.component.scss'] +}) +export class DocumentBriefViewComponent { + + /** Record */ + @Input() set record(record) { + this._record = record; + this.processProvisionActivityPublications(); + } + + /** Provision activities */ + provisionActivityPublications: any[] = []; + + /** Record */ + private _record: any; + + /** Get current record */ + get record(): any { + return this._record; + } + + /** process provision activity publications */ + private processProvisionActivityPublications() { + const { provisionActivity } = this.record; + if (undefined === provisionActivity) { + return; + } + provisionActivity.map((provision: any) => { + if (provision.type === 'bf:Publication' && '_text' in provision) { + provision._text.map((text: any) => this.provisionActivityPublications.push(text.value)); + } + }); + } +} diff --git a/projects/shared/src/lib/pipe/identifiedby-label.pipe.spec.ts b/projects/shared/src/lib/pipe/identifiedby-label.pipe.spec.ts new file mode 100644 index 000000000..0b9f13348 --- /dev/null +++ b/projects/shared/src/lib/pipe/identifiedby-label.pipe.spec.ts @@ -0,0 +1,26 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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 { IdentifiedByLabelPipe } from './identifiedby-label.pipe'; + +describe('IdentifierLabelPipe', () => { + it('create an instance', () => { + const pipe = new IdentifiedByLabelPipe(); + expect(pipe).toBeTruthy(); + }); +}); diff --git a/projects/shared/src/lib/pipe/identifiedby-label.pipe.ts b/projects/shared/src/lib/pipe/identifiedby-label.pipe.ts new file mode 100644 index 000000000..1e6c0dd39 --- /dev/null +++ b/projects/shared/src/lib/pipe/identifiedby-label.pipe.ts @@ -0,0 +1,34 @@ +/* + * RERO ILS UI + * Copyright (C) 2023 RERO + * Copyright (C) 2023 UCLouvain + * + * 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 { Pipe, PipeTransform } from '@angular/core'; + +@Pipe({ + name: 'identifiedByLabel' +}) +export class IdentifiedByLabelPipe implements PipeTransform { + + transform(identifiedBy: any[], types: string[]): string | null { + const identifiers: Array = types ? identifiedBy + .filter(identifier => types.includes(identifier.type)) : identifiedBy; + return identifiers ? identifiers.map(data => + data.value + ).join(', ') : null + } + +} diff --git a/projects/shared/src/lib/shared.module.ts b/projects/shared/src/lib/shared.module.ts index 71bf56ae6..5315e3593 100644 --- a/projects/shared/src/lib/shared.module.ts +++ b/projects/shared/src/lib/shared.module.ts @@ -52,6 +52,8 @@ import { PartOfComponent } from './view/brief/part-of/part-of.component'; import { InheritedCallNumberComponent } from './view/inherited-call-number/inherited-call-number.component'; import { ThumbnailComponent } from './view/thumbnail/thumbnail.component'; import { AvailabilityComponent } from './view/availability/availability.component'; +import { DocumentBriefViewComponent } from './component/documents/document-brief-view/document-brief-view.component'; +import { IdentifiedByLabelPipe } from './pipe/identifiedby-label.pipe'; @NgModule({ declarations: [ @@ -85,6 +87,8 @@ import { AvailabilityComponent } from './view/availability/availability.componen ContributionComponent, NoContentDirective, AvailabilityComponent, + DocumentBriefViewComponent, + IdentifiedByLabelPipe ], exports: [ CommonModule, @@ -114,6 +118,7 @@ import { AvailabilityComponent } from './view/availability/availability.componen ContributionComponent, NoContentDirective, AvailabilityComponent, + DocumentBriefViewComponent, ], imports: [ CommonModule, diff --git a/projects/shared/src/public-api.ts b/projects/shared/src/public-api.ts index 372015be7..1368114b6 100644 --- a/projects/shared/src/public-api.ts +++ b/projects/shared/src/public-api.ts @@ -29,6 +29,7 @@ export * from './lib/class/user'; export * from './lib/component/action-button/action-button.component'; export * from './lib/component/core/brief-view/brief-view.component'; +export * from './lib/component/documents/document-brief-view/document-brief-view.component'; export * from './lib/component/entities/entity-brief-view/entity-brief-view.component'; export * from './lib/view/contribution/contribution.component'; @@ -47,6 +48,7 @@ export * from './lib/pipe/entity-label.pipe'; export * from './lib/pipe/extract-source-field.pipe'; export * from './lib/pipe/get-translated-label.pipe'; export * from './lib/pipe/id-attribute.pipe'; +export * from './lib/pipe/identifiedby-label.pipe'; export * from './lib/pipe/is-array.pipe'; export * from './lib/pipe/item-holdings-call-number.pipe'; export * from './lib/pipe/join.pipe';