Skip to content

Commit

Permalink
acquisition: displaying more document information
Browse files Browse the repository at this point in the history
* Adds document brief view component.
* Adds new formly field type to display document informations.

Co-Authored-by: Lauren-D <[email protected]>
  • Loading branch information
lauren-d committed Oct 12, 2023
1 parent 85806fc commit 9da3259
Show file tree
Hide file tree
Showing 17 changed files with 363 additions and 45 deletions.
8 changes: 6 additions & 2 deletions projects/admin/src/app/acquisition/acquisition.module.ts
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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';
Expand All @@ -62,6 +63,7 @@ import { PermissionsService, SharedModule } from '@rero/shared';
import { OrderEmailFormComponent } from './components/order/order-email-form/order-email-form.component';
import { PreviewEmailModule } from '../shared/preview-email/preview-email.module';


@NgModule({
declarations: [
AccountListComponent,
Expand All @@ -70,6 +72,7 @@ import { PreviewEmailModule } from '../shared/preview-email/preview-email.module
AccountDetailViewComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
FieldDocumentBriefViewTypeComponent,
FieldRefTypeComponent,
InputNoLabelWrapperComponent,
NegativeAmountPipe,
Expand Down Expand Up @@ -104,6 +107,7 @@ import { PreviewEmailModule } from '../shared/preview-email/preview-email.module
types: [
{ name: 'repeat', component: RepeatTypeComponent },
{ name: 'field-ref', component: FieldRefTypeComponent },
{ name: 'field-document-brief-view', component: FieldDocumentBriefViewTypeComponent },
{ name: 'select-account', component: SelectAccountComponent }
],
wrappers: [
Expand Down
23 changes: 21 additions & 2 deletions projects/admin/src/app/acquisition/acquisition.scss
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -48,6 +48,25 @@
}
}

// 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.
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -37,10 +37,7 @@
'fa-window-close-o text-danger': orderLine.status === orderLineStatus.CANCELLED
}"></i>
<ng-container *ngIf="orderLine.document.pid | getRecord: 'documents' | async as document">
<a *ngIf="document.metadata.title | mainTitle as title"
[routerLink]="['/records', 'documents', 'detail', document.metadata.pid]">
{{ title | truncateText }}
</a>
<shared-document-brief-view [record]="document.metadata"></shared-document-brief-view>
</ng-container>
<span class="bullet-notes" *ngIf="orderLine.notes.length > 0 && isCollapsed">
<ng-container *ngFor="let note of orderLine.notes">
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -15,6 +15,7 @@
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->

<div *ngIf="receipt && receipt.pid && permissions" class="container">
<h1 class="mb-3">{{ receipt.reference }}</h1>
<blockquote class="receipt-note row" *ngFor="let note of receipt.notes">
Expand All @@ -32,14 +33,16 @@ <h1 class="mb-3">{{ receipt.reference }}</h1>
<div class="col-9">
<div class="d-flex">
<span class="quantity fixed-width">{{ line.quantity }}</span>
<a [routerLink]="['/records', 'documents', 'detail', line.document.pid]" target="acq-detail">
{{ line.document.title_text }}
</a>
<div>
<ng-container *ngIf="line.document.pid | getRecord: 'documents' | async as document">
<shared-document-brief-view [record]="document.metadata"></shared-document-brief-view>
</ng-container>
<ng-container *ngIf="line.acq_account.pid | getRecord: 'acq_accounts' | async as account">
<div class="account-number">{{ account.metadata.number }}</div>
</ng-container>
</div>
<span class="ml-auto mr-2 reception_date">{{ line.receipt_date | dateTranslate: 'shortDate' }}</span>
</div>
<div class="metadata left-offset" *ngIf="line.document.identifiers">
ISBN: {{ line.document.identifiers.join(', ') }}
</div>
<div class="left-offset row" *ngFor="let note of line.notes">
<span class="col-3 p-0"><span class="badge badge-{{ note | noteBadgeColor }}">{{ note.type | translate }}</span></span>
<span class="note-content col p-0 pl-2" [innerHTML]="note.content | nl2br"></span>
Expand Down Expand Up @@ -83,7 +86,7 @@ <h1 class="mb-3">{{ receipt.reference }}</h1>
<div class="col-9 d-flex">
<i class="fa fa-long-arrow-right fixed-width"></i>
<label>{{ adjustment.label }}</label>
<span class="ml-auto metadata pr-2">
<span class="ml-auto account-number pr-2">
{{ adjustment.acq_account.pid | getRecord: 'acq_accounts': 'field': 'number' | async }}
</span>
</div>
Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -73,17 +73,6 @@ $line-shift: map-get($spacers, 5);
.left-offset {
margin-left: $line-shift;
}
.metadata {
font-weight: bold;
color: $secondary;
font-size: $small-font-size;
&::before {
content:'[';
}
&::after {
content: ']';
}
}
.note-content {
border-left: 2px solid $border-color;
margin-top: map-get($spacers, 1);;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ import { IAcqReceipt, IAcqReceiptLine } from '../../../classes/receipt';
@Component({
selector: 'admin-receipt-detail-view',
templateUrl: './receipt-detail-view.component.html',
styleUrls: ['./receipt-detail-view.component.scss']
styleUrls: ['../../../acquisition.scss', './receipt-detail-view.component.scss']
})
export class ReceiptDetailViewComponent implements OnInit, OnDestroy, DetailRecord {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -232,19 +232,12 @@ export class OrderReceiptForm {
},
{
key: 'document',
type: 'field-ref',
type: 'field-document-brief-view',
className: 'col-5',
wrappers: ['input-no-label'],
templateOptions: {
headerClassName: 'col-5 font-weight-bold mb-2',
label: 'Document',
resource: 'documents',
recourceKey: 'document',
resourceField: 'title.0._text',
resourceSelect: {
field: 'type',
value: 'bf:Title'
}
}
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,16 @@
<ng-container *ngIf="!isCollapsed">
<!-- RECEPTION LINES ROWS :: One line for each reception line -->
<ng-container *ngFor="let line of receipt.receipt_lines; let first = first;">
<div class="col-9 detail label d-inline-block" [class.separator]="first">
<div class="col-9 detail label d-inline-flex" [class.separator]="first">
<strong>{{ line.quantity }}</strong><span class="mx-2">x</span>
<a [routerLink]="['/records', 'documents', 'detail', line.document.pid]" target="acq-detail">
{{ line.document.title | truncateText }}
</a>
<div>
<ng-container *ngIf="line.document.pid | getRecord: 'documents' | async as document">
<shared-document-brief-view [record]="document.metadata"></shared-document-brief-view>
</ng-container>
<ng-container *ngIf="line.acq_account.pid | getRecord: 'acq_accounts' | async as account">
<span class="account-number">{{ account.metadata.number }}</span>
</ng-container>
</div>
</div>
<div class="col-3 detail amount d-flex" [class.separator]="first">
<div class="computation">
Expand Down
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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: `
<ng-container *ngIf="record">
<shared-document-brief-view [record]="record"></shared-document-brief-view>
</ng-container>
`
})
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);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
<!--
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 <http://www.gnu.org/licenses/>.
-->
<!-- title -->
<a *ngIf="record.title | mainTitle as title"
[routerLink]="['/records', 'documents', 'detail', record.pid]" target="_blank">
{{ title }}
</a>
<!-- contribution -->
<ng-container *ngIf="record?.contribution as entities">
<div class="small">
<shared-contribution
[contributions]="entities"
[limitRecord]="3"
[activateLink]="false"
></shared-contribution>
</div>
</ng-container>
<!-- provision activity publications -->
<ng-container *ngIf="provisionActivityPublications.length > 0">
<div name="document-provisioin)activity" class="small">
{{ provisionActivityPublications | join }}
</div>
</ng-container>

<!-- ISBN -->
<ng-container *ngIf="record.identifiedBy | identifiedByLabel: ['bf:Isbn', 'bf:Ean'] as identifiedBy">
<div name="document-identified-by" class="small-content">
ISBN: {{ identifiedBy | truncateText: 3 }}
</div>
</ng-container>
<!-- ISSN -->
<ng-container *ngIf="record.identifiedBy | identifiedByLabel: ['bf:Issn'] as identifiedBy">
<div name="document-identified-by" class="small-content">
ISSN: {{ identifiedBy | truncateText: 3 }}
</div>
</ng-container>


Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* 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 <http://www.gnu.org/licenses/>.
*/

@import 'bootstrap/scss/functions';
@import 'bootstrap/scss/variables';

.small-content{
font-size: small;
color: $secondary;
font-weight: bold;
}

.truncate {
width: 250px;
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
Loading

0 comments on commit 9da3259

Please sign in to comment.