Skip to content

Commit

Permalink
feat: detail views enhancements
Browse files Browse the repository at this point in the history
* Closes rero/rero-ils#3618.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Mar 13, 2024
1 parent 43f0fca commit 69423cc
Show file tree
Hide file tree
Showing 28 changed files with 671 additions and 292 deletions.
12 changes: 10 additions & 2 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2023 RERO
* Copyright (C) 2019-2024 RERO
* Copyright (C) 2019-2023 UCLouvain
*
* This program is free software: you can redistribute it and/or modify
Expand Down Expand Up @@ -159,10 +159,12 @@ import { ReceivedIssueComponent } from './record/detail-view/holding-detail-view
import {
SerialHoldingDetailViewComponent
} from './record/detail-view/holding-detail-view/serial-holding-detail-view/serial-holding-detail-view.component';
import { HoldingPageDetailComponent } from './record/detail-view/holding-detail-view/holding-page-detail/holding-page-detail.component';
import { IllRequestDetailViewComponent } from './record/detail-view/ill-request-detail-view/ill-request-detail-view.component';
import { ItemDetailViewComponent } from './record/detail-view/item-detail-view/item-detail-view.component';
import { ItemTransactionComponent } from './record/detail-view/item-detail-view/item-transaction/item-transaction.component';
import { ItemTransactionsComponent } from './record/detail-view/item-detail-view/item-transactions/item-transactions.component';
import { ItemPageDetailComponent } from './record/detail-view/item-detail-view/item-page-detail/item-page-detail.component';
import { ItemTypeDetailViewComponent } from './record/detail-view/item-type-detail-view/item-type-detail-view.component';
import { DayOpeningHoursComponent } from './record/detail-view/library-detail-view/day-opening-hours/day-opening-hours.component';
import { ExceptionDateComponent } from './record/detail-view/library-detail-view/exception-date/exception-date.component';
Expand Down Expand Up @@ -210,6 +212,8 @@ import { PreviewEmailModule } from './shared/preview-email/preview-email.module'
import { CurrentLibraryPermissionValidator } from './utils/permissions';
import { CustomShortcutHelpComponent } from './widgets/custom-shortcut-help/custom-shortcut-help.component';
import { FrontpageComponent } from './widgets/frontpage/frontpage.component';
import { LocalPageDetailComponent } from './record/detail-view/entities-detail-view/local/local-page-detail/local-page-detail.component';
import { RemotePageDetailComponent } from './record/detail-view/entities-detail-view/remote/remote-page-detail/remote-page-detail.component';

/** Init application factory */
export function appInitFactory(appInitializerService: AppInitializerService): () => Promise<any> {
Expand Down Expand Up @@ -351,7 +355,11 @@ export function appInitFactory(appInitializerService: AppInitializerService): ()
RepeatTypeComponent,
FieldCustomInputTypeComponent,
DocumentAdvancedSearchComponent,
DocumentDetailComponent
DocumentDetailComponent,
HoldingPageDetailComponent,
ItemPageDetailComponent,
LocalPageDetailComponent,
RemotePageDetailComponent
],
imports: [
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,18 @@ import { CirculationLogsComponent } from './circulation-logs.component';
@Component({
selector: 'admin-circulation-logs-dialog',
template: `
<button
id="item-circulation-history"
class="btn btn-sm btn-light my-2 ml-2"
[permissions]="[permissions.CIRC_ADMIN, permissions.OPLG_SEARCH]"
[operator] = permissionOperator.AND
(click)="openDialog()"
translate
>Circulation history</button>
<div class="w-100 text-right">
<button
id="item-circulation-history"
class="btn btn-sm btn-outline-secondary my-1"
[permissions]="[permissions.CIRC_ADMIN, permissions.OPLG_SEARCH]"
[operator] = permissionOperator.AND
(click)="openDialog()"
>
<i class="fa fa-history"></i>
{{ 'Circulation history' | translate }}
</button>
</div>
`
})
export class CirculationLogsDialogComponent {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,10 +308,6 @@ <h3 id="{{ 'doc-altgr-title-' + i }}">{{ altgr_title }}</h3>
<!-- END OF MARC TAB -->
</tabset>
</div>
<!-- END OF TABS -->
@if (isEnabledOperationLog && record.metadata.pid) {
<admin-operation-logs-dialog resourceType="documents" [resourcePid]="record.metadata.pid"></admin-operation-logs-dialog>
}
}

<ng-template #entityLink let-entity="entity" let-class="class">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import { IPermissions, PERMISSIONS, PermissionsService } from '@rero/shared';
import { Observable, of, Subscription } from 'rxjs';
import { switchMap } from 'rxjs/operators';
import { DocumentApiService } from '../../../api/document-api.service';
import { OperationLogsService } from '../../../service/operation-logs.service';

@Component({
selector: 'admin-document-detail-view',
Expand Down Expand Up @@ -59,14 +58,6 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit, OnDest
/** Enables or disables links */
activateLink: boolean = true;

/**
* Is operation log enabled
* @return boolean
*/
get isEnabledOperationLog(): boolean {
return this.operationLogsService.isLogVisible('documents');
}

/** External identifier for imported record. */
get pid(): string | null {
if (this.activatedRouter.snapshot && this.activatedRouter.snapshot.params && this.activatedRouter.snapshot.params.pid !== null) {
Expand Down Expand Up @@ -99,15 +90,13 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit, OnDest
* @param translateService - TranslateService to translate some strings.
* @param activatedRouter - ActivatedRoute to get url parameters.
* @param recordService - RecordService to the MARC version for the record.
* @param operationLogsService - OperationLogsService
* @param documentApiService - DocumentApiService
* @param permissionsService - PermissionsService
*/
constructor(
private translateService: TranslateService,
private activatedRouter: ActivatedRoute,
private recordService: RecordService,
private operationLogsService: OperationLogsService,
private documentApiService: DocumentApiService,
private permissionsService: PermissionsService
) { }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,20 +28,29 @@
>
<ng-container beforeButton>
@if (record) {
@if (isEnabledOperationLog && record.metadata.pid) {
<admin-operation-logs-dialog resourceType="documents" [resourcePid]="record.metadata.pid"></admin-operation-logs-dialog>
}
@if (!record.metadata.pid && source) {
<button
class="btn btn-sm btn-outline-primary ml-1"
[permissions]="permissions.DOC_CREATE"
(click)="importDocument($event, record, { source: source, pid: pid })"
translate>Import</button>
>
<i class="fa fa-cloud-download"></i>
{{ 'Import' | translate }}
</button>
}
@if (record.metadata.pid) {
<button
class="btn btn-sm btn-outline-primary ml-1"
[permissions]="permissions.DOC_CREATE"
[routerLink]="['/records', 'documents', 'duplicate']"
[queryParams]="{type: 'documents', pid: record.metadata.pid}"
translate>Duplicate</button>
>
<i class="fa fa-files-o"></i>
{{ 'Duplicate' | translate }}
</button>
}
}
</ng-container>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@

/*
* RERO ILS UI
* Copyright (C) 2019-2023 RERO
* Copyright (C) 2019-2024 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
Expand All @@ -19,6 +19,7 @@ import { Location } from '@angular/common';
import { Component, ComponentFactoryResolver } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { IdentifierTypes } from '@app/admin/classes/identifiers';
import { OperationLogsService } from '@app/admin/service/operation-logs.service';
import { TranslateService } from '@ngx-translate/core';
import { DetailComponent, Record, RecordService, RecordUiService } from '@rero/ng-core';
import { IPermissions, PERMISSIONS } from '@rero/shared';
Expand Down Expand Up @@ -71,6 +72,14 @@ export class DocumentDetailComponent extends DetailComponent {
return null;
}

/**
* Is operation log enabled
* @return boolean
*/
get isEnabledOperationLog(): boolean {
return this.operationLogsService.isLogVisible('documents');
}

/**
* Constructor
* @param route - ActivatedRoute
Expand All @@ -83,6 +92,7 @@ export class DocumentDetailComponent extends DetailComponent {
* @param translate - TranslateService
* @param spinner - NgxSpinnerService
* @param bsModalService - BsModalService
* @param operationLogsService - OperationLogsService
*/
constructor(
protected route: ActivatedRoute,
Expand All @@ -94,7 +104,8 @@ export class DocumentDetailComponent extends DetailComponent {
protected toastrService: ToastrService,
protected translate: TranslateService,
protected spinner: NgxSpinnerService,
protected bsModalService: BsModalService
protected bsModalService: BsModalService,
private operationLogsService: OperationLogsService,
) {
super(route, router, location, componentFactoryResolver, recordService, recordUiService, toastrService, translate, spinner);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
@if (record$ | async; as record) {
<div class="float-right mt-2 mb-4">
<a (click)="search($any(record).metadata)" class="btn btn-sm btn-primary mr-n4">
<i class="fa fa-search" aria-hidden="true"></i>
{{ 'Search documents' | translate }}
</a>
</div>
<h1 class="mb-0" *ngVar="icon($any(record).metadata.type) as icon">
<i class="fa {{ icon.class }}" title="{{ icon.title }}" aria-hidden="true"></i>
{{ $any(record).metadata.authorized_access_point }}</h1>
Expand Down Expand Up @@ -60,10 +54,5 @@ <h1 class="mb-0" *ngVar="icon($any(record).metadata.type) as icon">
}
</article>
</article>

<!-- OPERATION LOGS-->
@if (isEnabledOperationLog) {
<admin-operation-logs-dialog [resourceType]="'local_entities'" [resourcePid]="$any(record).metadata.pid"></admin-operation-logs-dialog>
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<!--
RERO ILS UI
Copyright (C) 2020-2024 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 <http://www.gnu.org/licenses/>.
-->
<div class="main-content">
@if (record) {
<ng-core-detail-button
[record]="record"
[type]="type"
[adminMode]="adminMode"
[useStatus]="useStatus"
[updateStatus]="updateStatus"
[deleteStatus]="deleteStatus"
(recordEvent)="recordEvent($event)"
(deleteMessageEvent)="showDeleteMessage($event)"
>
<ng-container beforeButton>
<button (click)="search(record)" class="btn btn-sm btn-outline-primary mr-1">
<i class="fa fa-search" aria-hidden="true"></i>
{{ 'Search documents' | translate }}
</button>
@if (record) {
@if (isEnabledOperationLog && record.metadata.pid) {
<admin-operation-logs-dialog resourceType="local_entities" [resourcePid]="record.metadata.pid"></admin-operation-logs-dialog>
}
}
</ng-container>
</ng-core-detail-button>
}
@if (error) {
<ng-core-error [error]="error"></ng-core-error>
}
<ng-template ngCoreRecordDetail></ng-template>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,86 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2024 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 <http://www.gnu.org/licenses/>.
*/
import { Location } from '@angular/common';
import { Component, ComponentFactoryResolver } from '@angular/core';
import { ActivatedRoute, Router } from '@angular/router';
import { OperationLogsService } from '@app/admin/service/operation-logs.service';
import { TranslateService } from '@ngx-translate/core';
import { DetailComponent, RecordService, RecordUiService } from '@rero/ng-core';
import { Entity } from '@rero/shared';
import { BsModalService } from 'ngx-bootstrap/modal';
import { NgxSpinnerService } from 'ngx-spinner';
import { ToastrService } from 'ngx-toastr';

@Component({
selector: 'admin-local-page-detail',
templateUrl: './local-page-detail.component.html'
})
export class LocalPageDetailComponent extends DetailComponent {

/**
* Is operation log enabled
* @return boolean
*/
get isEnabledOperationLog(): boolean {
return this.operationLogsService.isLogVisible('local_entities');
}

/**
* Constructor
* @param route - ActivatedRoute
* @param router - Router
* @param location - Location
* @param componentFactoryResolver - ComponentFactoryResolver
* @param recordService - RecordService
* @param recordUiService - RecordUiService
* @param toastrService - ToastrService
* @param translate - TranslateService
* @param spinner - NgxSpinnerService
* @param bsModalService - BsModalService
* @param operationLogsService - OperationLogsService
*/
constructor(
protected route: ActivatedRoute,
protected router: Router,
protected location: Location,
protected componentFactoryResolver: ComponentFactoryResolver,
protected recordService: RecordService,
protected recordUiService: RecordUiService,
protected toastrService: ToastrService,
protected translate: TranslateService,
protected spinner: NgxSpinnerService,
protected bsModalService: BsModalService,
private operationLogsService: OperationLogsService,
) {
super(route, router, location, componentFactoryResolver, recordService, recordUiService, toastrService, translate, spinner);
}

/**
* Launch an expert search on the document view.
* @param record - the record
*/
search(record: any): void
{
this.router.navigate(
['/records', 'documents'],
{
queryParams: { q: Entity.generateSearchQuery(record.metadata.type, 'local', record.metadata.pid), simple: '0' },
skipLocationChange: true
},
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,6 @@
along with this program. If not, see <http://www.gnu.org/licenses/>.
-->
@if (record$ | async; as record) {
<div class="float-right mt-2 mb-4 mr-n4">
<a (click)="search($any(record).metadata)" class="btn btn-sm btn-primary">
<i class="fa fa-search" aria-hidden="true"></i>
{{ 'Search documents' | translate }}
</a>
</div>

<h1 class="mb-0" *ngVar="icon($any(record).metadata.type) as icon">
<i class="fa {{ icon.class }}" title="{{ icon.title }}" aria-hidden="true"></i>
{{ $any(record).metadata | extractSourceField : 'authorized_access_point' }}</h1>
Expand Down
Loading

0 comments on commit 69423cc

Please sign in to comment.