Skip to content

Commit

Permalink
entities: some improve navigation and links
Browse files Browse the repository at this point in the history
* Adds a new tab for related entities on document detail view.
* Updates contribution, subject and genreForm to relaunch a search.
* Updates search documents on entities detail view to target
  certain fields only.
* rero/rero-ils#3513.

Co-Authored-by: Bertrand Zuchuat <[email protected]>
  • Loading branch information
Garfield-fr committed Dec 6, 2023
1 parent 9e6a79c commit 55f4239
Show file tree
Hide file tree
Showing 20 changed files with 473 additions and 193 deletions.
2 changes: 2 additions & 0 deletions projects/admin/src/app/app.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ import {
OtherEditionComponent
} from './record/detail-view/document-detail-view/document-description/other-edition/other-edition.component';
import { DocumentDetailViewComponent } from './record/detail-view/document-detail-view/document-detail-view.component';
import { EntitiesRelatedComponent } from './record/detail-view/document-detail-view/entities-related/entities-related.component';
import { HoldingDetailComponent } from './record/detail-view/document-detail-view/holding-detail/holding-detail.component';
import {
HoldingOrganisationComponent
Expand Down Expand Up @@ -332,6 +333,7 @@ export function appInitFactory(appInitializerService: AppInitializerService): ()
StatisticsCfgDetailViewComponent,
ReportDataComponent,
ReportsListComponent,
EntitiesRelatedComponent
],
imports: [
AppRoutingModule,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,22 +53,6 @@ export class DocumentsBriefViewComponent implements ResultItem {
*/
constructor(public documentApiService: DocumentApiService) {}

/**
* Contribution type parameter
* @param contribution - object
* @return string - type of agent
*/
contributionTypeParam(contribution: any) {
switch (contribution.type) {
case 'bf:Person':
return 'persons';
case 'bf:Organisation':
return 'corporate-bodies';
default:
return 'missing-contribution-type';
}
}

/** process provision activity publications */
private processProvisionActivityPublications() {
const { provisionActivity } = this.record.metadata;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,7 @@ <h3 id="{{ 'doc-altgr-title-' + i }}">{{ altgr_title }}</h3>
<!-- CONTRIBUTION -->
<shared-contribution [contributions]="record.metadata?.contribution"
[withRoles]="true"
[activateLink]="activateLink"
[withEntityLink]="true">
[activateLink]="activateLink">
</shared-contribution>

<!-- PUBLICATION ACTIVITY: PUBLICATION -->
Expand Down Expand Up @@ -180,15 +179,24 @@ <h3 id="{{ 'doc-altgr-title-' + i }}">{{ altgr_title }}</h3>
<span *ngFor="let subject of subjects"
class="badge badge-secondary mr-1"
title="{{ subject.entity.type | translate }}">
<ng-container [ngTemplateOutlet]="entityLink" [ngTemplateOutletContext]="{ entity: subject, class: 'text-light' }"></ng-container>
<i class="fa fa-tag mr-1"></i>
<shared-entity-link
resourceName="subjects"
[entity]="subject.entity"
className="text-light"
></shared-entity-link>
</span>
</div>
</div>

<!-- GENRE, FORM -->
<div class="mt-1" *ngIf="record.metadata.genreForm">
<span class="mr-1" *ngFor="let genre of record.metadata.genreForm">
<ng-container [ngTemplateOutlet]="entityLink" [ngTemplateOutletContext]="{ entity: genre, class: 'text-secondary' }"></ng-container>
<i class="fa fa-tag mr-1"></i>
<shared-entity-link
resourceName="genreForm"
[entity]="genre.entity"
></shared-entity-link>
</span>
</div>

Expand Down Expand Up @@ -234,6 +242,16 @@ <h3 id="{{ 'doc-altgr-title-' + i }}">{{ altgr_title }}</h3>
</div>
</tab>
<!-- END OF DESCRIPTION TAB -->
<!-- ENTITIES RELATED -->
<tab id="documents-entities-tab" tabOrder="3" [active]="!record.metadata.pid">
<ng-template tabHeading>
<i class="fa fa-cubes mr-1"></i> {{ 'Related Entities' | translate }}
</ng-template>
<div class="mt-2">
<admin-entities-related [record]="record"></admin-entities-related>
</div>
</tab>
<!-- END ENTITIES RELATED -->
<!-- LOCAL FIELDS TAB -->
<tab
*ngIf="!record.metadata.harvested && record.metadata.pid && showhideLocalFieldsTab"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,22 +295,6 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit, OnDest
}
}

/**
* Translate the type of the contribution for url
* @param contribution - document contribution
* @returns string, the translated type
*/
contributionTypeParam(contribution: any): string {
switch (contribution.type) {
case 'bf:Person':
return 'persons';
case 'bf:Organisation':
return 'corporate-bodies';
default:
return 'missing-contribution-type';
}
}

/**
* Extract and format query params
* @param identifier - IdentifiedBy object
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
<!--
RERO ILS UI
Copyright (C) 2019-2023 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="container">
<div [class]="i%2 === 0 ? 'bg-light':''" class="row" *ngFor="let field of entities | keyvalue; let i = index">
<div class="font-weight-bold col-3 py-1">
{{ field.key | translate |ucfirst }}
</div>
<div class="col-9 py-1">
<ul class="list-unstyled mb-0">
<li *ngFor="let entity of field.value">
<i title="{{ entity.type | translate }}" class="fa {{ entity.icon }} mr-2"></i>
<a [routerLink]="['/records', entity.resource_type + '_entities', 'detail', entity.pid]">{{ entity.authorized_access_point }}</a>
</li>
</ul>
</div>
</div>
</div>
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2023 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, Input, OnInit } from '@angular/core';
import { TranslateService } from '@ngx-translate/core';
import { Entity } from '@rero/shared';
import { IEntityRelated } from './entities-related.interface';

@Component({
selector: 'admin-entities-related',
templateUrl: './entities-related.component.html'
})
export class EntitiesRelatedComponent implements OnInit {

/** Record metadata */
@Input() record: any;

/** Entities processed */
entities: {[key: string]: IEntityRelated[]} = {};

/**
* Constructor
* @param translateService - TranslateService
*/
constructor(private translateService: TranslateService) {}

/** OnInit hook */
ngOnInit(): void {
const language = this.translateService.currentLang;
const { metadata } = this.record;
Entity.FIELDS_WITH_REF.forEach((field: string) => {
if (field in metadata && metadata[field].length > 0) {
metadata[field].forEach((entity: any) => {
if (entity.entity.resource_type) {
if (!Object.keys(this.entities).includes(field)) {
this.entities[field] = [];
}
this.entities[field].push({
authorized_access_point: entity.entity[`authorized_access_point_${language}`],
pid: entity.entity.pid,
resource_type: entity.entity.resource_type,
type: entity.entity.type,
icon: Entity.getIcon(entity.entity.type)
});
}
});
}
});
}
}
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/*
* RERO ILS UI
* Copyright (C) 2019-2023 RERO
* Copyright (C) 2019-2023 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
Expand All @@ -15,17 +14,10 @@
* 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 { Tools } from "./tools";

describe('Tools', () => {

it('should return a query', () => {
const query = [
'contribution.entity.pids.foo:x11',
'subjects.entity.pids.foo:x11',
'genreForm.entity.pids.foo:x11'
].join(' OR ');
expect(Tools.generateEntitySearchQuery('foo', 'x11')).toEqual(query);
});

});
export interface IEntityRelated {
authorized_access_point: string;
pid: string;
resource_type: string;
type: string;
icon: string;
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@
import { Component, OnInit } from '@angular/core';
import { Router } from '@angular/router';
import { OperationLogsService } from '@app/admin/service/operation-logs.service';
import { Tools } from '@app/admin/utils/tools';
import { TranslateService } from '@ngx-translate/core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { EntityType, EntityTypeIcon } from '@rero/shared';
import { Entity, EntityType, EntityTypeIcon } from '@rero/shared';

@Component({
selector: 'admin-entities-local-detail-view',
Expand Down Expand Up @@ -90,7 +89,7 @@ export class EntitiesLocalDetailViewComponent implements OnInit, DetailRecord {
this._router.navigate(
['/records', 'documents'],
{
queryParams: { q: Tools.generateEntitySearchQuery('local', metadata.pid), simple: '0'},
queryParams: { q: Entity.generateSearchQuery(metadata.type, 'local', metadata.pid), simple: '0' },
skipLocationChange: true
},
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,9 @@

import { Component } from '@angular/core';
import { Router } from '@angular/router';
import { Tools } from '@app/admin/utils/tools';
import { TranslateService } from '@ngx-translate/core';
import { DetailRecord } from '@rero/ng-core/lib/record/detail/view/detail-record';
import { AppSettingsService, EntityType, EntityTypeIcon } from '@rero/shared';
import { AppSettingsService, Entity, EntityType, EntityTypeIcon } from '@rero/shared';

@Component({
selector: 'admin-remote-entities-remote-detail-view',
Expand Down Expand Up @@ -109,7 +108,7 @@ export class RemoteEntitiesDetailViewComponent implements DetailRecord {
this._router.navigate(
['/records', 'documents'],
{
queryParams: { q: Tools.generateEntitySearchQuery(catalogKey, catalogPid), simple: '0' },
queryParams: { q: Entity.generateSearchQuery(metadata.type, catalogKey, catalogPid), simple: '0' },
skipLocationChange: true
}
);
Expand Down
34 changes: 0 additions & 34 deletions projects/admin/src/app/utils/tools.ts

This file was deleted.

57 changes: 0 additions & 57 deletions projects/shared/src/lib/class/entities.ts

This file was deleted.

Loading

0 comments on commit 55f4239

Please sign in to comment.