Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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),
[]
),
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/assets/print-view/fetch-orcid.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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 || []) {
Expand Down
14 changes: 14 additions & 0 deletions src/assets/print-view/fetch-orcid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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', () => {
Expand Down
Loading