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 <laurent.dubois@itld-solutions.be>
  • Loading branch information
lauren-d committed Oct 12, 2023
1 parent 85806fc commit 396ce60
Show file tree
Hide file tree
Showing 17 changed files with 354 additions and 53 deletions.
7 changes: 5 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 @@ -70,6 +71,7 @@ import { PreviewEmailModule } from '../shared/preview-email/preview-email.module
AccountDetailViewComponent,
BudgetsBriefViewComponent,
BudgetDetailViewComponent,
FieldDocumentBriefViewTypeComponent,
FieldRefTypeComponent,
InputNoLabelWrapperComponent,
NegativeAmountPipe,
Expand Down Expand Up @@ -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 }
],
Expand Down
21 changes: 19 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,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.
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 @@ -23,8 +23,8 @@
(click)="isCollapsed = !isCollapsed"
[attr.aria-expanded]="!isCollapsed" aria-controls="collapse">
</button>
<div class="d-flex align-items-start flex-column">
<div class="d-flex">
<div class="d-flex align-items-start flex-column w-100">
<div class="d-flex w-100">
<i class="fa status"
title="{{ orderLine.status | translate }}"
[ngClass]="{
Expand All @@ -36,12 +36,11 @@
'text-warning': orderLine.status === orderLineStatus.PARTIALLY_RECEIVED,
'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>
</ng-container>
<div class="d-flex flex-grow-1 mb-1">
<ng-container *ngIf="orderLine.document.pid | getRecord: 'documents' | async as document">
<shared-document-brief-view [record]="document.metadata"></shared-document-brief-view>
</ng-container>
</div>
<span class="bullet-notes" *ngIf="orderLine.notes.length > 0 && isCollapsed">
<ng-container *ngFor="let note of orderLine.notes">
<i class="fa fa-circle fa-bullet bullet-{{ note | noteBadgeColor }}" aria-hidden="true" title="{{ note.type | translate }}"></i>
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 @@ -29,16 +29,20 @@ <h1 class="mb-3">{{ receipt.reference }}</h1>
<div class="card-body row">
<div class="container row line no-gutters" *ngFor="let line of receiptLines">
<ng-container *ngIf="line && permissions; else loading">
<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>
<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 class="col-9 d-flex">
<span class="quantity fixed-width">{{ line.quantity }}</span>
<div class="d-flex align-items-start flex-column w-100">
<div class="d-flex w-100">
<div class="d-flex flex-grow-1 mb-1 mr-1">
<ng-container *ngIf="line.document.pid | getRecord: 'documents' | async as document">
<shared-document-brief-view [record]="document.metadata"></shared-document-brief-view>
</ng-container>
</div>
<span class="ml-auto mr-2 reception_date">{{ line.receipt_date | dateTranslate: 'shortDate' }}</span>
</div>
<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 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>
Expand Down Expand Up @@ -83,7 +87,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,51 @@
<!--
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="ml-2 small" name="document-contribution">
<shared-contribution
[contributions]="entities"
[limitRecord]="3"
[activateLink]="false"
></shared-contribution>
</div>
</ng-container>
<!-- provision activity publications -->
<ng-container *ngIf="provisionActivityPublications.length > 0">
<div class="ml-2 small" name="document-provision-activity">
{{ provisionActivityPublications | join }}
</div>
</ng-container>

<!-- ISBN -->
<ng-container *ngIf="record.identifiedBy | identifiedByLabel: ['bf:Isbn', 'bf:Ean'] as identifiedBy">
<div class="ml-2 small-content" name="document-identified-by">
ISBN: {{ identifiedBy | truncateText: 3 }}
</div>
</ng-container>
<!-- ISSN -->
<ng-container *ngIf="record.identifiedBy | identifiedByLabel: ['bf:Issn'] as identifiedBy">
<div class="ml-2 small-content" name="document-identified-by">
ISSN: {{ identifiedBy | truncateText: 3 }}
</div>
</ng-container>
Original file line number Diff line number Diff line change
@@ -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 <http://www.gnu.org/licenses/>.
*/

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

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

0 comments on commit 396ce60

Please sign in to comment.