From 0d536324157278ab1f78fd6c9ff031b55b3ead25 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Johnny=20Marie=CC=81thoz?= Date: Thu, 5 Dec 2024 16:54:56 +0100 Subject: [PATCH] primeng: admin patrons MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-Authored-by: Johnny MarieĢthoz Co-Authored-by: Bertrand Zuchuat --- .../patrons-brief-view.component.html | 53 ++-- .../patrons-brief-view.component.scss | 52 ---- .../patrons-brief-view.component.ts | 11 +- .../patron-detail-view.component.html | 292 +++++++++--------- .../patron-detail-view.component.scss | 51 --- .../patron-detail-view.component.ts | 23 +- .../patron-permission.component.html | 16 +- .../patron-permission.component.ts | 2 - .../patron-permissions.component.html | 23 +- .../operation-logs.component.html | 4 +- projects/admin/src/app/utils/roles.ts | 26 +- 11 files changed, 228 insertions(+), 325 deletions(-) delete mode 100644 projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.scss delete mode 100644 projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.scss diff --git a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.html b/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.html index 1b338109a..cd91b4a43 100644 --- a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.html +++ b/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.html @@ -16,38 +16,37 @@ along with this program. If not, see . --> @if (record) { -
-
- - {{ record.metadata.last_name }} - @if (record.metadata.first_name) { - {{ record.metadata.first_name }} - } - +
-
-

+

+ +
@for (role of record.metadata.roles; track role) { - + {{ role | translate }} - + } -

-

{{ record.metadata.birth_date | dateTranslate:'mediumDate' }} — {{ record.metadata.city }}

+ + + {{ record.metadata.birth_date | dateTranslate:'mediumDate' }} — {{ record.metadata.city }} +
} diff --git a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.scss b/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.scss deleted file mode 100644 index ef45a42e3..000000000 --- a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.scss +++ /dev/null @@ -1,52 +0,0 @@ -/* You can add global styles to this file, and also import other style files */ -/* - * RERO ILS UI - * Copyright (C) 2021-2024 RERO - * Copyright (C) 2021 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/bootstrap'; -@import 'bootstrap/scss/functions'; -@import 'bootstrap/scss/variables'; -@import '../../../scss/variables'; - -$badge-size: 10px; - -.patron-brief { - - .card-title, p { - margin-bottom: 0; - } - .card-title { - display: flex; - align-items: center; - - small.badge { - font-size: $badge-size; - } - - .action-buttons{ - margin-left: auto; - @extend .mr-n5; - @extend .mb-2; - } - } - - .card-text { - label { - font-weight: bolder; - } - } -} diff --git a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.ts b/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.ts index 25eb31ce6..6efd6dcbc 100644 --- a/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.ts +++ b/projects/admin/src/app/record/brief-view/patrons-brief-view/patrons-brief-view.component.ts @@ -15,15 +15,14 @@ * along with this program. If not, see . */ -import { Component, inject, Input } from '@angular/core'; +import { Component, inject, Input, OnInit } from '@angular/core'; import { ResultItem } from '@rero/ng-core'; import { PERMISSIONS, PermissionsService } from '@rero/shared'; -import { roleBadgeColor } from '../../../utils/roles'; +import { roleTagSeverity } from '../../../utils/roles'; @Component({ selector: 'admin-patrons-brief-view', - templateUrl: './patrons-brief-view.component.html', - styleUrls: ['./patrons-brief-view.component.scss'] + templateUrl: './patrons-brief-view.component.html' }) export class PatronsBriefViewComponent implements ResultItem { @@ -49,7 +48,7 @@ export class PatronsBriefViewComponent implements ResultItem { * @param role: the role to check. * @return the bootstrap badge class to use for this role. */ - getRoleBadgeColor(role: string): string { - return roleBadgeColor(role); + getRoleTagSeverity(role: string): string { + return roleTagSeverity(role); } } diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html index 39cac4780..b23837aca 100644 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html @@ -16,55 +16,61 @@ --> @if (patron) { +
@if (patron.patron && patron.patron.blocked) { - + } -
+
-
-
-
+
+
-
-
+

{{ patron.last_name }} {{ patron.first_name }} @if (patron.patron) { - +   {{ 'Circulation' | translate }} }

-
-
-
Date of birth
-
{{ patron.birth_date | dateTranslate:'mediumDate' }}
+
- - @if (patron.notes && patron.notes.length > 0) { -
- - {{ patron.notes.length | i18nPlural: {'=1': 'Note', 'other': 'Notes'} | translate }} - @if (sectionCollapsed.notes) { - {{ patron.notes.length }} - } -
-
- @for (note of patron.notes; track note) { -
-
{{ note.type | translate }}
-
-
- } -
- } - -
- - {{ 'User informations' | translate }} -
-
-
-
Username
-
{{ patron.username }}
-
-
Keep history
-
- -
-
{{ patron.roles | i18nPlural: {'=1': 'Role', 'other': 'Roles'} }}
-
- @for (role of patron.roles; track role) { - - {{ role | translate }} - + +
+ + + @if (patron.notes && patron.notes.length > 0) { + + +
+ {{ patron.notes.length | i18nPlural: {'=1': 'Note', 'other': 'Notes'} | translate }} +
+
+ @for (note of patron.notes; track note) { + + } +
} -
-
Creation date
-
{{ record.created | dateTranslate: 'mediumDate' }}
-
+ + + +

User informations

+
+ + +
+ @if (patron.patron) { -
- - {{ 'Patron Information' | translate }} -
-
-
-
Barcode
-
+ + +

Patron information

+
+ - } +
+ } + @if (patron.libraries?.length > 0) { -
- - {{ 'Librarian Information' | translate }} -
-
-
-
{{ patron.libraries.length | i18nPlural: {'=1': 'Library', 'other': 'Libraries'} }}
-
    - @for (library of patron.libraries; track library) { -
  • - {{ library.pid | getRecord: 'libraries' : 'field' : 'name' | async }} -
  • - } -
-
+ + +

Librarian information

+
+ +
} @if (canAccessDisplayPermissions) { -
- - {{ 'Permissions' | translate }} -
-
- -
+ + +

Permissions

+
+ +
} + +
- - - @if (isEnabledOperationLog) { - - } +
} diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.scss b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.scss deleted file mode 100644 index 3ee68f58a..000000000 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.scss +++ /dev/null @@ -1,51 +0,0 @@ -/* - * RERO ILS UI - * Copyright (C) 2021 RERO - * Copyright (C) 2021 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'; -@import 'projects/admin/src/app/scss/variables'; - -#contact-profile { - .profile-image { - width: $resource-logo-width; - height: $resource-logo-height; - border-radius: $resource-logo-radius; - background-color: $secondary; - text-align: center; - vertical-align: middle; - display: table-cell; - } - - .metadata { - text-transform: lowercase; - font-size: $small-font-size; - font-weight: $font-weight-bold; - color: $secondary; - &:before { - content: '('; - } - &:after { - content: ')'; - padding-right: map-get($spacers, 2); - } - } - - .btn-show-more { - border-color: $card-border-color; - } -} diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts index 008d5f31b..0a386b5ed 100644 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts @@ -19,8 +19,7 @@ import { Component, inject, OnDestroy, OnInit } from '@angular/core'; import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; import { IPermissions, PERMISSIONS, PermissionsService } from '@rero/shared'; import { Observable, Subscription } from 'rxjs'; -import { OperationLogsService } from '../../../service/operation-logs.service'; -import { roleBadgeColor } from '../../../utils/roles'; +import { roleTagSeverity } from '../../../utils/roles'; interface PatronPhone { value: string; @@ -30,12 +29,10 @@ interface PatronPhone { @Component({ selector: 'admin-patron-detail-view', - templateUrl: './patron-detail-view.component.html', - styleUrls: ['./patron-detail-view.component.scss'], + templateUrl: './patron-detail-view.component.html' }) export class PatronDetailViewComponent implements OnInit, DetailRecord, OnDestroy { - private operationLogsService: OperationLogsService = inject(OperationLogsService); private permissionsService: PermissionsService = inject(PermissionsService); // COMPONENT ATTRIBUTES ===================================================== @@ -63,12 +60,6 @@ export class PatronDetailViewComponent implements OnInit, DetailRecord, OnDestro /** Subscription to (un)follow the record$ Observable */ private subscription$ = new Subscription(); - // GETTER AND SETTER ======================================================== - /** Is operation log enabled */ - get isEnabledOperationLog(): boolean { - return this.operationLogsService.isLogVisible('patrons'); - } - permissions: IPermissions = PERMISSIONS; get canAccessDisplayPermissions(): boolean { @@ -96,8 +87,8 @@ export class PatronDetailViewComponent implements OnInit, DetailRecord, OnDestro * @param role: the role to check. * @return the bootstrap badge class to use for this role. */ - getRoleBadgeColor(role: string): string { - return roleBadgeColor(role); + getroleTagSeverity(role: string): string { + return roleTagSeverity(role); } /** Get the badge color to use for a note type @@ -105,9 +96,9 @@ export class PatronDetailViewComponent implements OnInit, DetailRecord, OnDestro */ getNoteBadgeColor(noteType: string): string { switch (noteType) { - case 'public_note': return 'badge-info'; - case 'staff_note': return 'badge-warning'; - default: return 'badge-secondary'; + case 'public_note': return 'info'; + case 'staff_note': return 'warning'; + default: return 'secondary'; } } diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.html b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.html index d8e83d62b..a9e52f6b9 100644 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.html +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.html @@ -15,7 +15,7 @@ You should have received a copy of the GNU Affero General Public License along with this program. If not, see . --> -
+
- +
-
-
    + @if(!isCollapsed) { +
    +
      @for (role of permission.reasons | keyvalue; track role) {
    • -
      +
      {{ role.key | translate }}
      @@ -44,4 +45,5 @@ }
    +}
diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.ts b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.ts index 367d68241..c731e3a0c 100644 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.ts +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permission/patron-permission.component.ts @@ -27,8 +27,6 @@ export class PatronPermissionComponent { // COMPONENT ATTRIBUTES ===================================================== /** User permission */ @Input() permission: IPatronPermission; - /** Index of permission */ - @Input() index: number; /** Hide reasons */ isCollapsed: boolean = true; } diff --git a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permissions.component.html b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permissions.component.html index af35a9a93..ddef21529 100644 --- a/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permissions.component.html +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-permissions/patron-permissions.component.html @@ -16,18 +16,23 @@ along with this program. If not, see . --> @defer (when permissions.length > 0) { -
+
- - Enter a part of the permission name to filter the list. + + Enter a part of the permission name to filter the list.
-
-
Permission
-
Access
+
+
Permission
+
Access
-
- @for (permission of filteredPermissions; track permission; let index = $index) { - +
+ @for (permission of filteredPermissions; track permission) { + }
} @placeholder { diff --git a/projects/admin/src/app/record/operation-logs/operation-logs.component.html b/projects/admin/src/app/record/operation-logs/operation-logs.component.html index c2c8578e8..b71211063 100644 --- a/projects/admin/src/app/record/operation-logs/operation-logs.component.html +++ b/projects/admin/src/app/record/operation-logs/operation-logs.component.html @@ -30,9 +30,9 @@ } @if (isLinkShowMore) { - + @if (isLinkShowMore) { ({{ hiddenOperationLogs }}) } diff --git a/projects/admin/src/app/utils/roles.ts b/projects/admin/src/app/utils/roles.ts index 3f4c4d957..66925b462 100644 --- a/projects/admin/src/app/utils/roles.ts +++ b/projects/admin/src/app/utils/roles.ts @@ -16,19 +16,19 @@ * along with this program. If not, see . */ -export enum ROLES_BAGDE_COLOR { - patron = 'badge-primary', - pro_full_permissions = 'badge-danger', - pro_read_only = 'badge-secondary', - pro_catalog_manager = 'badge-success', - pro_circulation_manager = 'badge-warning', - pro_user_manager = 'badge-info', - pro_acquisition_manager = 'badge-light', - pro_library_administrator = 'badge-dark' +export enum ROLES_TAG_SEVERITY { + patron = 'primary', + pro_full_permissions = 'danger', + pro_read_only = 'help', + pro_catalog_manager = 'success', + pro_circulation_manager = 'warning', + pro_user_manager = 'info', + pro_acquisition_manager = 'secondary', + pro_library_administrator = 'contrast' } -export function roleBadgeColor(role: string): string { - return (role in ROLES_BAGDE_COLOR) - ? ROLES_BAGDE_COLOR[role] - : 'badge-light'; +export function roleTagSeverity(role: string): string { + return (role in ROLES_TAG_SEVERITY) + ? ROLES_TAG_SEVERITY[role] + : 'secondary'; }