diff --git a/src/app/cdk/side-bar/modals/modal-email/modal-email.component.ts b/src/app/cdk/side-bar/modals/modal-email/modal-email.component.ts index 8787085711..c9a81542cb 100644 --- a/src/app/cdk/side-bar/modals/modal-email/modal-email.component.ts +++ b/src/app/cdk/side-bar/modals/modal-email/modal-email.component.ts @@ -655,6 +655,9 @@ export class ModalEmailComponent implements OnInit, OnDestroy { private getMostPermissiveVisibility( visibilities: VisibilityStrings[] ): VisibilityStrings { + if (!visibilities.length) { + return null + } return visibilities.reduce((most, current) => VisibilityWeightMap[current] > VisibilityWeightMap[most] ? current : most ) @@ -663,6 +666,9 @@ export class ModalEmailComponent implements OnInit, OnDestroy { private getLeastPermissiveVisibility( visibilities: VisibilityStrings[] ): VisibilityStrings { + if (!visibilities.length) { + return null + } return visibilities.reduce((least, current) => VisibilityWeightMap[current] < VisibilityWeightMap[least] ? current diff --git a/src/app/core/record-affiliations-affiliations-grouping/record-affiliations-grouping.service.ts b/src/app/core/record-affiliations-affiliations-grouping/record-affiliations-grouping.service.ts index bef0a1a138..89f519d09c 100644 --- a/src/app/core/record-affiliations-affiliations-grouping/record-affiliations-grouping.service.ts +++ b/src/app/core/record-affiliations-affiliations-grouping/record-affiliations-grouping.service.ts @@ -86,12 +86,14 @@ export class RecordAffiliationsGroupingService { .map((key) => value.affiliationGroups[key]) }) // Reduce all elements with different AffiliationGroupsTypeName on the same expectedUiOrderGroup - .reduce((accumulator, currentValue) => - accumulator.concat(currentValue) + .reduce( + (accumulator, currentValue) => accumulator.concat(currentValue), + [] ) // Concatenates affiliations lists - .reduce((accumulator, currentValue) => - accumulator.concat(currentValue) + .reduce( + (accumulator, currentValue) => accumulator.concat(currentValue), + [] ), } } diff --git a/src/assets/print-view/fetch-orcid.js b/src/assets/print-view/fetch-orcid.js index f0612f3dad..179de3daab 100644 --- a/src/assets/print-view/fetch-orcid.js +++ b/src/assets/print-view/fetch-orcid.js @@ -59,6 +59,10 @@ const STRINGS = { relFundedBy: $localize`:@@printView.relFundedBy:Funded by`, } +function peerReviewHeadingText(reviewsCount, publicationsCount) { + return $localize`:@@printView.peerReviewSummary:Peer review (${reviewsCount}:reviewCount: reviews for ${publicationsCount}:publicationCount: publications/grants)` +} + // Localized country names keyed by ISO 3166-1 alpha-2 code. // Mirrors `getCountryCodes` in // src/app/core/record-countries/record-countries.service.ts so the print view @@ -1113,7 +1117,10 @@ function renderPeerReviews(activities, section) { const block = document.createElement('div') block.className = 'activity-group' const heading = document.createElement('h3') - heading.textContent = `Peer review (${reviews} reviews for ${sortedPublications.size} publications/grants)` + heading.textContent = peerReviewHeadingText( + reviews, + sortedPublications.size + ) block.appendChild(heading) const list = document.createElement('ul') for (publication of sortedPublications || []) { diff --git a/src/assets/print-view/fetch-orcid.spec.ts b/src/assets/print-view/fetch-orcid.spec.ts index 15528ae6c6..b95ed36e16 100644 --- a/src/assets/print-view/fetch-orcid.spec.ts +++ b/src/assets/print-view/fetch-orcid.spec.ts @@ -15,6 +15,10 @@ declare function jsonText(value: any): string declare function jsonList(list: any): any[] declare function jsonDate(parts: any): string declare function jsonOrcidUri(orcidIdentifier: any): string +declare function peerReviewHeadingText( + reviewsCount: number, + publicationsCount: number +): string declare function renderOrcidPrompt(message?: string): void declare function makeSection(title: string): HTMLElement declare function textLineNode( @@ -219,6 +223,16 @@ describe('fetch-orcid.js', () => { }) }) + // ── peerReviewHeadingText ─────────────────────────────────────────────────── + + describe('peerReviewHeadingText', () => { + it('builds heading text including review and publication counts', () => { + expect(peerReviewHeadingText(7, 3)).toBe( + 'Peer review (7 reviews for 3 publications/grants)' + ) + }) + }) + // ── makeSection ─────────────────────────────────────────────────────────────── describe('makeSection', () => {