-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Adds detail view. * Adds link on brief view to patron name. * Adds patron service. * Adds translations. * Fixes facet roles is open by default Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
- Loading branch information
1 parent
f8fe3c7
commit 24702bd
Showing
13 changed files
with
286 additions
and
93 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
98 changes: 98 additions & 0 deletions
98
...cts/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,98 @@ | ||
<!-- | ||
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 <http://www.gnu.org/licenses/>. | ||
--> | ||
<ng-container *ngIf="record$ | async as record"> | ||
<h1 class="mb-3">{{ record.metadata.last_name }} {{ record.metadata.first_name }}</h1> | ||
<article> | ||
<section class="m-2 p-2"> | ||
<!-- BARCODE --> | ||
<dl class="row mb-0" *ngIf="record.metadata.barcode"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Barcode' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
<a [routerLink]="['/circulation', 'checkinout']" [queryParams]="{ patron: record.metadata.barcode }">{{ record.metadata.barcode }}</a> | ||
</dd> | ||
</dl> | ||
<!-- TYPE --> | ||
<dl class="row mb-0" *ngIf="isPatron"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Type' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.patron_type.pid | getRecord: 'patron_types' : 'field' : 'name' | async }} | ||
</dd> | ||
</dl> | ||
<!-- TYPE --> | ||
<dl class="row mb-0" *ngIf="isLibrarian"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Library' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.library.pid | getRecord: 'libraries' : 'field' : 'name' | async }} | ||
</dd> | ||
</dl> | ||
<!-- PHONE --> | ||
<dl class="row mb-0" *ngIf="record.metadata.phone"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Phone' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.phone }} | ||
</dd> | ||
</dl> | ||
<!-- EMAIL --> | ||
<dl class="row mb-0"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Email' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.email }} | ||
</dd> | ||
</dl> | ||
<!-- STREET --> | ||
<dl class="row mb-0"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'Street' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.street }} | ||
</dd> | ||
</dl> | ||
<!-- CITY --> | ||
<dl class="row mb-0"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
{{ 'City' | translate }}: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
{{ record.metadata.postal_code }} {{ record.metadata.city }} | ||
</dd> | ||
</dl> | ||
<!-- ROLES --> | ||
<dl class="row mb-0"> | ||
<dt class="col-sm-3 offset-sm-2 offset-md-0"> | ||
<ng-container *ngIf="record.metadata.roles.length === 1; else roles" translate>Role</ng-container> | ||
<ng-template #roles translate>Roles</ng-template>: | ||
</dt> | ||
<dd class="col-sm-7 col-md-8 mb-0"> | ||
<ng-container *ngFor="let role of record.metadata.roles; let last=last"> | ||
{{ role | translate }}{{ last ? '' : ', ' }} | ||
</ng-container> | ||
</dd> | ||
</dl> | ||
</section> | ||
</article> | ||
</ng-container> |
50 changes: 50 additions & 0 deletions
50
projects/admin/src/app/record/detail-view/patron-detail-view/patron-detail-view.component.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
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<any>; | ||
|
||
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'); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
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(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 <http://www.gnu.org/licenses/>. | ||
*/ | ||
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; | ||
} | ||
} |
Oops, something went wrong.