From b4506e19b4759f44ad142eca4f010d8fb9fc782f Mon Sep 17 00:00:00 2001 From: Bertrand Zuchuat Date: Thu, 22 Sep 2022 14:12:29 +0200 Subject: [PATCH] document: improve check for document import Previously the control was done on a fixed list of types. Now all identifiers are searched. * Closes rero/rero-ils#3031. Co-Authored-by: Bertrand Zuchuat --- .../document-detail-view.component.ts | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/projects/admin/src/app/record/detail-view/document-detail-view/document-detail-view.component.ts b/projects/admin/src/app/record/detail-view/document-detail-view/document-detail-view.component.ts index 90b14710a..ce80237e2 100644 --- a/projects/admin/src/app/record/detail-view/document-detail-view/document-detail-view.component.ts +++ b/projects/admin/src/app/record/detail-view/document-detail-view/document-detail-view.component.ts @@ -112,21 +112,20 @@ export class DocumentDetailViewComponent implements DetailRecord, OnInit, OnDest const keysTypes = Object.keys(this.mappingtypes); const rec = record.metadata; const route = ['/records', 'documents', 'new']; - if (rec.identifiedBy) { - const queryParams = []; - rec.identifiedBy.forEach((identifier: any) => { - if (['bf:Isbn', 'bf:Issn', 'bf:Doi', 'bf:Lccn', 'bf:IssnL', 'bf:Ean'].includes(identifier.type)) { - queryParams.push(this._extractAndFormatQueryParams(identifier)); - if (keysTypes.indexOf(identifier.type) > -1) { - const cidentifier = cloneDeep(identifier); - cidentifier.type = this.mappingtypes[cidentifier.type]; - queryParams.push(this._extractAndFormatQueryParams(cidentifier)); - } + let query = null; + const queryParams = []; + rec.identifiedBy.forEach((identifier: any) => { + queryParams.push(this._extractAndFormatQueryParams(identifier)); + if (keysTypes.indexOf(identifier.type) > -1) { + const cidentifier = cloneDeep(identifier); + cidentifier.type = this.mappingtypes[cidentifier.type]; + queryParams.push(this._extractAndFormatQueryParams(cidentifier)); } - }); - const query = queryParams.join(' OR '); + }); + if (queryParams.length > 0) { + query = queryParams.join(' OR '); this._recordService.getRecords( - 'documents', query, 1, undefined, undefined, undefined, { accept: 'application/rero+json' } + 'documents', query, 1, undefined, undefined, { simple: 0 }, { accept: 'application/rero+json' } ).subscribe((response: Record) => { if (this._recordService.totalHits(response.hits.total) === 0) { this._router.navigate(route, { queryParams: data });