From fff6dffd8871615e2bccfcda9b6ff025e79f5d80 Mon Sep 17 00:00:00 2001 From: "konstantina.galouni" Date: Mon, 20 Jun 2022 16:55:05 +0300 Subject: [PATCH] [Library | new-theme]: 1. orcid.service.ts: [Bug fix] In method "getOrcidWorks()", updated response type from to --> "bulk" object with an array inside is returned. 2. orcid-work.component.ts: [Bug fix] In method "getOrcidWorks()", parsing of bulk works fixed to not have problem when null response or error object inside bulk is returned. --- orcid/orcid-work.component.ts | 24 +++++++++++++++++------- orcid/orcid.service.ts | 2 +- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/orcid/orcid-work.component.ts b/orcid/orcid-work.component.ts index a0bf7a33..72d04821 100644 --- a/orcid/orcid-work.component.ts +++ b/orcid/orcid-work.component.ts @@ -166,8 +166,10 @@ declare var UIkit: any;
-
- +
+ + +
@@ -596,11 +598,19 @@ export class OrcidWorkComponent { } else { this.showLoading = true; this.subscriptions.push(this.orcidService.getOrcidWorks(this.putCodes).subscribe( - (response: WorkV3_0[]) => { - if(response) { - this.orcidWorks = response; - this.openWorkModal(); - } else { + (response) => { + let error: boolean = true; + if(response && response['bulk']) { + response = response['bulk'].filter(res => { + return (!res.error && res.work); + }); + if(response && response.length > 0) { + error = false; + this.orcidWorks = response; + this.openWorkModal(); + } + } + if(error) { UIkit.notification({ message: 'There was an error getting this work.
Please make sure you have not deleted it from your ORCID iD.', status: 'warning', diff --git a/orcid/orcid.service.ts b/orcid/orcid.service.ts index 8af2c49b..8a48da02 100644 --- a/orcid/orcid.service.ts +++ b/orcid/orcid.service.ts @@ -114,7 +114,7 @@ export class OrcidService { getOrcidWorks(putCodes: string[]) { let url: string = properties.orcidAPIURL + "orcid/works?put_codes="+putCodes.join(","); - return this.http.get(url, CustomOptions.registryOptions()); + return this.http.get(url, CustomOptions.registryOptions()); }