diff --git a/projects/admin/src/app/app.module.ts b/projects/admin/src/app/app.module.ts index 92761d3a3..d5cc21964 100644 --- a/projects/admin/src/app/app.module.ts +++ b/projects/admin/src/app/app.module.ts @@ -66,6 +66,7 @@ import { ItemDetailViewComponent } from './record/detail-view/item-detail-view/i import { ItemAvailabilityComponent } from './record/item-availability/item-availability.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 { PatronDetailViewComponent } from './record/detail-view/patron-detail-view/patron-detail-view.component'; @NgModule({ declarations: [ @@ -114,7 +115,8 @@ import { ItemTransactionsComponent } from './record/detail-view/item-detail-view ItemDetailViewComponent, ItemAvailabilityComponent, ItemTransactionComponent, - ItemTransactionsComponent + ItemTransactionsComponent, + PatronDetailViewComponent ], imports: [ Bootstrap4FrameworkModule, @@ -176,7 +178,8 @@ import { ItemTransactionsComponent } from './record/detail-view/item-detail-view CollapseListComponent, LibraryComponent, LocationDetailViewComponent, - ItemDetailViewComponent + ItemDetailViewComponent, + PatronDetailViewComponent ], bootstrap: [AppComponent] }) diff --git a/projects/admin/src/app/record/brief-view/patrons-brief-view.component.ts b/projects/admin/src/app/record/brief-view/patrons-brief-view.component.ts index a7626106b..ba0bf0736 100644 --- a/projects/admin/src/app/record/brief-view/patrons-brief-view.component.ts +++ b/projects/admin/src/app/record/brief-view/patrons-brief-view.component.ts @@ -15,60 +15,38 @@ * along with this program. If not, see . */ -import { Component, Input } from '@angular/core'; -import { ResultItem, RecordService } from '@rero/ng-core'; +import { Component, Input, OnInit } from '@angular/core'; +import { ResultItem } from '@rero/ng-core'; +import { PatronService } from '../../service/patron.service'; @Component({ selector: 'admin-patrons-brief-view', template: ` -
{{ record.metadata.last_name }}, {{ record.metadata.first_name }} - +
+ + {{ record.metadata.last_name }}, {{ record.metadata.first_name }} + + - - Circulation + + Circulation

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

-

- - - - {{ role | translate }}{{isLast ? '' : ', '}} - - -

-
    -
  • - Barcode: {{ record.metadata.barcode }} -
  • -
  • - Library: {{ record.metadata.library.name }} -
  • -
  • - Type: {{ record.metadata.patron_type.name }} -
  • -
  • - Phone: {{ record.metadata.phone }} -
  • -
  • - Email: {{ record.metadata.email }} -
  • -
  • - Street: {{ record.metadata.street }} -
  • -
  • - City: {{ record.metadata.postal_code }} {{ record.metadata.city }} -
  • -
+ + Role + Roles: + + + {{ role | translate }}{{isLast ? '' : ', '}} +
`, styles: [] }) -export class PatronsBriefViewComponent implements ResultItem { +export class PatronsBriefViewComponent implements OnInit, ResultItem { @Input() record: any; @@ -79,50 +57,13 @@ export class PatronsBriefViewComponent implements ResultItem { @Input() detailUrl: { link: string, external: boolean }; - isCollapsed = true; - - constructor( - private recordService: RecordService - ) { - } - - isPatron() { - if (this.record && this.record.metadata.roles) { - return this.record.metadata.roles.some(role => role === 'patron'); - } - return false; - } + constructor(private patronService: PatronService) { } - isLibrarian() { - if (this.record && this.record.metadata.roles) { - return this.record.metadata.roles.some(role => role === 'librarian'); - } - return false; + ngOnInit() { + this.patronService.setRecord(this.record); } - toggleCollapse() { - const isCollapsed = this.isCollapsed; - if (isCollapsed) { - if (this.isPatron()) { - const patronTypePid = this.record.metadata.patron_type.pid; - this.recordService - .getRecord('patron_types', patronTypePid, 1) - .subscribe(data => { - this.record.metadata.patron_type = data.metadata; - this.isCollapsed = !isCollapsed; - }); - } - if (this.isLibrarian()) { - const libraryPid = this.record.metadata.library.pid; - this.recordService - .getRecord('libraries', libraryPid, 1) - .subscribe(data => { - this.record.metadata.library = data.metadata; - this.isCollapsed = !isCollapsed; - }); - } - } else { - this.isCollapsed = !isCollapsed; - } + get isPatron() { + return this.patronService.hasRole('patron'); } } 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 new file mode 100644 index 000000000..97af6badc --- /dev/null +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html @@ -0,0 +1,98 @@ + + +

{{ record.metadata.last_name }} {{ record.metadata.first_name }}

+
+
+ +
+
+ {{ 'Barcode' | translate }}: +
+
+ {{ record.metadata.barcode }} +
+
+ +
+
+ {{ 'Type' | translate }}: +
+
+ {{ record.metadata.patron_type.pid | getRecord: 'patron_types' : 'field' : 'name' | async }} +
+
+ +
+
+ {{ 'Library' | translate }}: +
+
+ {{ record.metadata.library.pid | getRecord: 'libraries' : 'field' : 'name' | async }} +
+
+ +
+
+ {{ 'Phone' | translate }}: +
+
+ {{ record.metadata.phone }} +
+
+ +
+
+ {{ 'Email' | translate }}: +
+
+ {{ record.metadata.email }} +
+
+ +
+
+ {{ 'Street' | translate }}: +
+
+ {{ record.metadata.street }} +
+
+ +
+
+ {{ 'City' | translate }}: +
+
+ {{ record.metadata.postal_code }} {{ record.metadata.city }} +
+
+ +
+
+ Role + Roles: +
+
+ + {{ role | translate }}{{ last ? '' : ', ' }} + +
+
+
+
+
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 new file mode 100644 index 000000000..edb062865 --- /dev/null +++ b/projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts @@ -0,0 +1,50 @@ +/* + * RERO ILS UI + * Copyright (C) 2019 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 . + */ +import { Component, OnInit } from '@angular/core'; +import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record'; +import { Observable } from 'rxjs'; +import { PatronService } from '../../../service/patron.service'; + +@Component({ + selector: 'admin-patron-detail-view', + templateUrl: './patron-detail-view.component.html' +}) +export class PatronDetailViewComponent implements OnInit, DetailRecord { + + record$: Observable; + + record: any; + + type: string; + + constructor(private patronService: PatronService) { } + + ngOnInit() { + this.record$.subscribe(record => { + this.record = record; + this.patronService.setRecord(record); + }); + } + + get isPatron() { + return this.patronService.hasRole('patron'); + } + + get isLibrarian() { + return this.patronService.hasRole('librarian'); + } +} diff --git a/projects/admin/src/app/service/patron.service.spec.ts b/projects/admin/src/app/service/patron.service.spec.ts new file mode 100644 index 000000000..fadecb3fb --- /dev/null +++ b/projects/admin/src/app/service/patron.service.spec.ts @@ -0,0 +1,28 @@ +/* + * RERO ILS UI + * Copyright (C) 2019 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 . + */ +import { TestBed } from '@angular/core/testing'; + +import { PatronService } from './patron.service'; + +describe('PatronService', () => { + beforeEach(() => TestBed.configureTestingModule({})); + + it('should be created', () => { + const service: PatronService = TestBed.get(PatronService); + expect(service).toBeTruthy(); + }); +}); diff --git a/projects/admin/src/app/service/patron.service.ts b/projects/admin/src/app/service/patron.service.ts new file mode 100644 index 000000000..066129169 --- /dev/null +++ b/projects/admin/src/app/service/patron.service.ts @@ -0,0 +1,40 @@ +/* + * RERO ILS UI + * Copyright (C) 2019 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 . + */ +import { Injectable } from '@angular/core'; + +@Injectable({ + providedIn: 'root' +}) +export class PatronService { + + private _patron: any; + + /** + * Set Patron record + * @param patron - patron record + */ + setRecord(patron: any) { + this._patron = patron.metadata; + } + + hasRole(patronRole: string) { + if (this._patron && this._patron.roles) { + return this._patron.roles.some((role: string) => role === patronRole); + } + return false; + } +} diff --git a/projects/admin/src/app/service/record-routing.service.ts b/projects/admin/src/app/service/record-routing.service.ts index f4b237b23..f5d615f24 100644 --- a/projects/admin/src/app/service/record-routing.service.ts +++ b/projects/admin/src/app/service/record-routing.service.ts @@ -42,6 +42,7 @@ import { CircPolicyDetailViewComponent } from '../record/detail-view/circ-policy import { LocationDetailViewComponent } from '../record/detail-view/location-detail-view/location-detail-view.component'; import { ItemDetailViewComponent } from '../record/detail-view/item-detail-view/item-detail-view.component'; import { UserService } from './user.service'; +import { PatronDetailViewComponent } from '../record/detail-view/patron-detail-view/patron-detail-view.component'; @Injectable({ providedIn: 'root' @@ -134,8 +135,10 @@ export class RecordRoutingService { key: 'patrons', label: 'Patrons', component: PatronsBriefViewComponent, + detailComponent: PatronDetailViewComponent, canUpdate: (record: any) => this.canUpdate(record), - canDelete: (record: any) => this.canDelete(record) + canDelete: (record: any) => this.canDelete(record), + aggregationsExpand: ['roles'] } ] } diff --git a/projects/admin/src/app/translate/i18n/de.json b/projects/admin/src/app/translate/i18n/de.json index 5a9dbb9bb..64fc077f1 100644 --- a/projects/admin/src/app/translate/i18n/de.json +++ b/projects/admin/src/app/translate/i18n/de.json @@ -115,7 +115,7 @@ "Patron": "Benutzer", "Period": "Zeitraum", "Permission required": "Permission required", - "Phone": "Telefon", + "Phone": "Telefonnummer", "Physical description": "Physikalische Beschreibung", "Pick-up Location": "Abholort", "Pickup location name": "Abholortname", @@ -142,6 +142,8 @@ "Requested by": "Bestellt von", "Requests": "Bestellungen", "Reservation date": "Bestellungsdatum", + "Role": "Roll", + "Roles": "Rollen", "Series": "Reihe", "Source": "Herkunft", "Start time format is not correct.": "Das Startzeitformat ist nicht korrekt.", @@ -218,6 +220,7 @@ "items": "Exemplare", "journal": "Zeitschrift", "language": "Sprache", + "librarian": "Bibliothekar", "libraries": "Bibliotheken", "library": "Bibliothek", "locations": "Standorte", @@ -232,6 +235,7 @@ "on_shelf": "im Regal", "organisation": "Organisation", "other": "anderes", + "patron": "Benutzer", "patron not found!": "Leser nicht gefunden!", "period": "Zeitraum", "renewals": "Verlängerungen", @@ -244,6 +248,7 @@ "status": "Status", "subject": "Schlagwort", "sunday": "Sonntag", + "system_librarian": "Systembibliothekar", "the item has been returned from missing": "das fehlende Exemplar ist jetzt wieder verfügbar", "thursday": "Donnerstag", "tuesday": "Dienstag", diff --git a/projects/admin/src/app/translate/i18n/en.json b/projects/admin/src/app/translate/i18n/en.json index 22cdbf308..a58f5a3e2 100644 --- a/projects/admin/src/app/translate/i18n/en.json +++ b/projects/admin/src/app/translate/i18n/en.json @@ -142,6 +142,8 @@ "Requested by": "Requested by", "Requests": "Requests", "Reservation date": "Reservation date", + "Role": "Role", + "Roles": "Roles", "Series": "Series", "Source": "Source", "Start time format is not correct.": "Start date format is incorrect.", @@ -218,6 +220,7 @@ "items": "items", "journal": "journal", "language": "language", + "librarian": "Librarian", "libraries": "libraries", "library": "library", "locations": "locations", @@ -232,6 +235,7 @@ "on_shelf": "on shelf", "organisation": "organisation", "other": "other", + "patron": "Patron", "patron not found!": "patron not found!", "period": "period", "renewals": "renewals", @@ -244,6 +248,7 @@ "status": "status", "subject": "subject", "sunday": "Sunday", + "system_librarian": "System librarian", "the item has been returned from missing": "the item has been returned from missing", "thursday": "Thursday", "tuesday": "Tuesday", @@ -254,4 +259,4 @@ "wednesday": "Wednesday", "week": "week", "year": "year" -} +} \ No newline at end of file diff --git a/projects/admin/src/app/translate/i18n/en_US.json b/projects/admin/src/app/translate/i18n/en_US.json index d332e9cdc..74d5b736d 100644 --- a/projects/admin/src/app/translate/i18n/en_US.json +++ b/projects/admin/src/app/translate/i18n/en_US.json @@ -142,6 +142,8 @@ "Requested by": "Requested by", "Requests": "Requests", "Reservation date": "Reservation date", + "Role": "Role", + "Roles": "Roles", "Series": "Series", "Source": "Source", "Start time format is not correct.": "Start time format is not correct.", @@ -218,6 +220,7 @@ "items": "items", "journal": "journal", "language": "language", + "librarian": "librarian", "libraries": "libraries", "library": "library", "locations": "locations", @@ -232,6 +235,7 @@ "on_shelf": "on_shelf", "organisation": "organisation", "other": "other", + "patron": "patron", "patron not found!": "patron not found!", "period": "period", "renewals": "renewals", @@ -244,6 +248,7 @@ "status": "status", "subject": "subject", "sunday": "sunday", + "system_librarian": "system_librarian", "the item has been returned from missing": "the item has been returned from missing", "thursday": "thursday", "tuesday": "tuesday", diff --git a/projects/admin/src/app/translate/i18n/fr.json b/projects/admin/src/app/translate/i18n/fr.json index e532367ec..eea077ac5 100644 --- a/projects/admin/src/app/translate/i18n/fr.json +++ b/projects/admin/src/app/translate/i18n/fr.json @@ -114,7 +114,7 @@ "Overdue amount must be great than 0.": "Overdue amount must be great than 0.", "Patron": "Lecteur", "Period": "Période", - "Permission required": "Permission required", + "Permission required": "Permission requise", "Phone": "Téléphone", "Physical description": "Description matérielle", "Pick-up Location": "Lieu de retrait", @@ -126,8 +126,8 @@ "Please insert a name": "Veuillez introduire un nom", "Please insert a title": "Veuillez introduire un titre", "RERO ILS administration": "RERO ILS administration", - "Record Updated!": "Record Updated!", - "Record created!": "Record created!", + "Record Updated!": "Enregistrement mis à jour!", + "Record created!": "Enregistrement créé!", "Record deleted": "Enregistrement supprimé", "Reminder fee amount": "Reminder fee amount", "Renewal": "Prolongation", @@ -142,12 +142,14 @@ "Requested by": "Demandé par", "Requests": "Demandes", "Reservation date": "Date de la réservation", + "Role": "Role", + "Roles": "Roles", "Series": "Collection", "Source": "Source", "Start time format is not correct.": "Le format de la date de début est incorrect.", "Start time is required.": "La date de début est obligatoire.", "Start-End Date": "Date de début et de fin", - "Status": "Status", + "Status": "Statut", "Street": "Rue", "Subjects": "Sujets", "Submit": "Enregistrer", @@ -218,6 +220,7 @@ "items": "exemplaires", "journal": "journal", "language": "langue", + "librarian": "bibliothécaire", "libraries": "libraries", "library": "bibliothèque", "locations": "dépôt", @@ -232,6 +235,7 @@ "on_shelf": "en rayon", "organisation": "organisation", "other": "autre", + "patron": "lecteur", "patron not found!": "aucun lecteur trouvé !", "period": "Période", "renewals": "renewals", @@ -244,6 +248,7 @@ "status": "statut", "subject": "Sujets", "sunday": "dimanche", + "system_librarian": "bibliothécaire système", "the item has been returned from missing": "l'exemplaire manquant est à nouveau disponible", "thursday": "jeudi", "tuesday": "mardi", diff --git a/projects/admin/src/app/translate/i18n/it.json b/projects/admin/src/app/translate/i18n/it.json index c5382836f..109ca5764 100644 --- a/projects/admin/src/app/translate/i18n/it.json +++ b/projects/admin/src/app/translate/i18n/it.json @@ -115,7 +115,7 @@ "Patron": "Lettore", "Period": "Periodo", "Permission required": "Permission required", - "Phone": "Telephono", + "Phone": "Telefono", "Physical description": "Descrizione fisica", "Pick-up Location": "Luogo di ritiro", "Pickup location name": "Nome del punto di ritiro", @@ -142,6 +142,8 @@ "Requested by": "Richiesto da", "Requests": "Richieste", "Reservation date": "Data di prenotazione", + "Role": "Role", + "Roles": "Ruoli", "Series": "Collezione", "Source": "Fonte", "Start time format is not correct.": "Il formato dell'ora di inizio non è corretto.", @@ -218,6 +220,7 @@ "items": "esemplari", "journal": "giornale", "language": "lingua", + "librarian": "bibliotecario", "libraries": "biblioteche", "library": "biblioteca", "locations": "localizzazioni", @@ -232,6 +235,7 @@ "on_shelf": "su scaffale", "organisation": "Ente", "other": "altro", + "patron": "Lettore", "patron not found!": "lettore non trovato!", "period": "periodo", "renewals": "renewals", @@ -244,6 +248,7 @@ "status": "Stato", "subject": "Oggetti", "sunday": "domenica", + "system_librarian": "bibliotecario del sistema", "the item has been returned from missing": "l'esemplare mancante è di nuovo disponibile", "thursday": "giovedì", "tuesday": "martedì", @@ -254,4 +259,4 @@ "wednesday": "mercoledì", "week": "settimana", "year": "anno" -} \ No newline at end of file +} diff --git a/projects/admin/src/manual_translations.ts b/projects/admin/src/manual_translations.ts index b624b1832..8662cba69 100644 --- a/projects/admin/src/manual_translations.ts +++ b/projects/admin/src/manual_translations.ts @@ -63,3 +63,8 @@ _('bf:Publication'); _('bf:Manufacture'); _('bf:Distribution'); _('bf:Production'); + +// Roles +_('librarian'); +_('patron'); +_('system_librarian');