Skip to content

Commit

Permalink
person: implement documents on detail view
Browse files Browse the repository at this point in the history
Co-Authored-by: Bertrand Zuchuat <bertrand.zuchuat@rero.ch>
  • Loading branch information
Garfield-fr committed Jan 31, 2020
1 parent 8ca169a commit 00cd64e
Show file tree
Hide file tree
Showing 2 changed files with 175 additions and 121 deletions.
Original file line number Diff line number Diff line change
@@ -1,127 +1,155 @@
<!--
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/>.
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-0">{{ record.metadata | mefTitle }}</h1>
<small>{{ 'MEF ID' | translate }}: {{ record.metadata.pid }}</small>
<h1 class="mb-0">{{ record.metadata | mefTitle }}</h1>
<small>{{ 'MEF ID' | translate }}: {{ record.metadata.pid }}</small>

<article class="card m-2" *ngFor="let source of record.metadata.sources">
<a class="card-link" data-toggle="collapse" data-target="#collapse-rero" aria-expanded="true">
<header class="card-header">
<b class="card-title mb-0">
{{ source | translate | uppercase }}
</b>
</header>
</a>
<article id="collapse-rero" class="card-body collapse show">
<!-- DATE OF BIRTH -->
<dl class="row mb-0" *ngIf="record.metadata[source].date_of_birth">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Birth date' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].date_of_birth }}
</dd>
</dl>
<!-- DATE OF DEATH -->
<dl class="row mb-0" *ngIf="record.metadata[source].date_of_death">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Death date' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].date_of_death }}
</dd>
</dl>
<!-- LANGUAGE OF PERSON -->
<dl class="row mb-0" *ngIf="record.metadata[source].language_of_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Language of person' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled mb-0">
<li *ngFor="let language of record.metadata[source].language_of_person">
{{ language | translate }}
</li>
</ul>
</dd>
</dl>
<!-- GENDER -->
<dl class="row mb-0" *ngIf="record.metadata[source].Gender">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Gender' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].Gender }}
</dd>
</dl>
<!-- BIBLIOGRAPHICAL INFORMATION -->
<dl class="row mb-0" *ngIf="record.metadata[source].biographical_information">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Biographical information' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled mb-0">
<li *ngFor="let bio of record.metadata[source].biographical_information">
{{ bio }}
</li>
</ul>
</dd>
</dl>
<!-- PERMALINK -->
<dl class="row mb-0" *ngIf="record.metadata[source].identifier_for_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Id' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<a href="{{ record.metadata[source].identifier_for_person }}">
{{ record.metadata[source].pid }}
</a>
</dd>
</dl>
<!-- NAME -->
<dl class="row mb-0" *ngIf="record.metadata[source].name">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Name' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].name }}
</dd>
</dl>
<!-- VARIANTE NAME -->
<dl class="row mb-0" *ngIf="record.metadata[source].variant_name_for_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Variant name' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled mb-0">
<li *ngFor="let variant_name of record.metadata[source].variant_name_for_person">
{{ variant_name }}
</li>
</ul>
</dd>
</dl>
<!-- AUTHORIZED ACCESS POINT -->
<dl class="row mb-0" *ngIf="record.metadata[source].authorized_access_point_representing_a_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Authorized access point' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].authorized_access_point_representing_a_person }}
</dd>
</dl>
</article>
</article>

<article class="card m-2" *ngFor="let source of record.metadata.sources">
<a class="card-link" data-toggle="collapse" data-target="#collapse-rero" aria-expanded="true">
<ng-container *ngIf="documents$ | async as documents">
<article class="card m-2 mt-4">
<header class="card-header">
<b class="card-title mb-0">
{{ source | translate | uppercase }}
<ng-container *ngIf="documents.length <= 1; else plurial">
{{ 'Document' | translate }}
</ng-container>
<ng-template #plurial>
{{ 'Documents' | translate }}
</ng-template>
({{ documents.length }})
</b>

</header>
</a>
<article id="collapse-rero" class="card-body collapse show">
<!-- DATE OF BIRTH -->
<dl class="row mb-0" *ngIf="record.metadata[source].date_of_birth">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Birth date' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].date_of_birth }}
</dd>
</dl>
<!-- DATE OF DEATH -->
<dl class="row mb-0" *ngIf="record.metadata[source].date_of_death">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Death date' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].date_of_death }}
</dd>
</dl>
<!-- LANGUAGE OF PERSON -->
<dl class="row mb-0" *ngIf="record.metadata[source].language_of_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Language of person' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled">
<li *ngFor="let language of record.metadata[source].language_of_person">
{{ language }}
</li>
</ul>
</dd>
</dl>
<!-- GENDER -->
<dl class="row mb-0" *ngIf="record.metadata[source].Gender">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Gender' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].Gender }}
</dd>
</dl>
<!-- BIBLIOGRAPHICAL INFORMATION -->
<dl class="row mb-0" *ngIf="record.metadata[source].biographical_information">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Biographical information' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled">
<li *ngFor="let bio of record.metadata[source].biographical_information">
{{ bio }}
<article id="collapse-rero" class="card-body collapse show">
<ul class="list-unstyled mb-0" *ngFor="let document of documents">
<li>
<a [routerLink]="['/records', 'documents', 'detail', document.metadata.pid]">
{{ document.metadata.title }}
</a>
</li>
</ul>
</dd>
</dl>
<!-- PERMALINK -->
<dl class="row mb-0" *ngIf="record.metadata[source].identifier_for_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Id' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<a href="{{ record.metadata[source].identifier_for_person }}">
{{ record.metadata[source].pid }}
</a>
</dd>
</dl>
<!-- NAME -->
<dl class="row mb-0" *ngIf="record.metadata[source].name">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Name' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].name }}
</dd>
</dl>
<!-- VARIANTE NAME -->
<dl class="row mb-0" *ngIf="record.metadata[source].variant_name_for_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Variant name' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
<ul class="list-unstyled">
<li *ngFor="let variant_name of record.metadata[source].variant_name_for_person">
{{ variant_name }}
</li>
</ul>
</dd>
</dl>
<!-- AUTHORIZED ACCESS POINT -->
<dl class="row mb-0" *ngIf="record.metadata[source].authorized_access_point_representing_a_person">
<dt class="col-sm-3 offset-sm-2 offset-md-0">
{{ 'Authorized access point' | translate }}:
</dt>
<dd class="col-sm-7 col-md-8 mb-0">
{{ record.metadata[source].authorized_access_point_representing_a_person }}
</dd>
</dl>
</article>
</article>
</article>
</ng-container>
</ng-container>


Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,48 @@
* 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 } from '@angular/core';
import { Component, OnInit } from '@angular/core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { Observable } from 'rxjs';
import { RecordService } from '@rero/ng-core';
import { map, switchMap } from 'rxjs/operators';

@Component({
selector: 'admin-person-detail-view',
templateUrl: './person-detail-view.component.html',
styles: []
})
export class PersonDetailViewComponent implements DetailRecord {
export class PersonDetailViewComponent implements DetailRecord, OnInit {

/** Observable resolving record data */
record$: Observable<any>;
/** Observable resolving record data */
record$: Observable<any>;

/** Resource type */
type: string;
/** Resource type */
type: string;

constructor() { }
/** Documents for current person */
documents$: Observable<Array<any>>;

/**
* Constructor
* @param _recordService - RecordService
*/
constructor(
private _recordService: RecordService
) { }

/**
* Init
*/
ngOnInit() {
this.documents$ = this.record$.pipe(
switchMap(record => {
const personPid = record.metadata.pid;
const query = `authors.pid:${personPid}`;
return this._recordService.getRecords(
'documents', query, 1, RecordService.MAX_REST_RESULTS_SIZE
); }),
map(hits => hits.hits.total === 0 ? [] : hits.hits.hits)
);
}
}

0 comments on commit 00cd64e

Please sign in to comment.