Skip to content

Commit ae8848d

Browse files
committed
feature: Add new source sorting option for affiliations, funding and works
1 parent dfb64e2 commit ae8848d

File tree

10 files changed

+48
-8
lines changed

10 files changed

+48
-8
lines changed

src/app/cdk/panel/sort-label.pipe.ts

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ export class SortLabelPipe implements PipeTransform {
1212
date: $localize`:@@share.sortDate:Date`,
1313
type: $localize`:@@share.sortType:Type`,
1414
order: $localize`:@@share.sortOrderv2:Publication/Grant title`,
15+
source: $localize`:@@share.source:Source`,
1516
}
1617
transform(value: SortOrderType): string {
1718
return this.SortOrderTypeLabel[value]

src/app/cdk/top-bar-verification-email/top-bar-verification-email.component.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
22
import { first, takeUntil } from 'rxjs/operators'
33
import { Subject } from 'rxjs'
4-
import { MatDialog } from '@angular/material/dialog'
54
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service'
65
import { RecordService } from 'src/app/core/record/record.service'
76
import { PlatformInfoService } from '../platform-info'

src/app/core/record-affiliations-sort/record-affiliations-sort.service.ts

+17-3
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import {
44
AffiliationUIGroup,
55
AffiliationGroup,
66
AffiliationType,
7-
AffiliationTypeValue,
87
} from 'src/app/types/record-affiliation.endpoint'
98
import { UserRecordOptions } from 'src/app/types/record.local'
109

@@ -21,15 +20,17 @@ export class AffiliationsSortService {
2120
value,
2221
userRecordContext?.sortAsc,
2322
userRecordContext?.sort,
24-
type
23+
type,
24+
userRecordContext?.publicRecordId || userRecordContext?.privateRecordId
2525
)
2626
}
2727

2828
sort(
2929
affiliationGroups: AffiliationUIGroup[],
3030
ascending = false,
3131
by = 'end',
32-
type = null
32+
type = null,
33+
orcid: string
3334
): AffiliationUIGroup[] {
3435
if (type === 'PROFESSIONAL_ACTIVITIES' && by === 'type') {
3536
const affiliations = affiliationGroups.filter(
@@ -85,6 +86,15 @@ export class AffiliationsSortService {
8586
affiliationGroup.reverse()
8687
}
8788
}
89+
90+
if (by === 'source') {
91+
affiliationGroup.sort((a, b) => {
92+
return Number(AffiliationsSortService.isSelfAsserted(a, orcid)) - Number(AffiliationsSortService.isSelfAsserted(b, orcid))
93+
})
94+
if (!ascending) {
95+
affiliationGroup.reverse()
96+
}
97+
}
8898
}
8999
})
90100
return affiliationGroups
@@ -192,4 +202,8 @@ export class AffiliationsSortService {
192202
return this.sortByDate(a, b, false, 'end')
193203
})
194204
}
205+
206+
private static isSelfAsserted(affiliationGroup: AffiliationGroup, orcid: string): boolean {
207+
return affiliationGroup.defaultAffiliation.source === orcid
208+
}
195209
}

src/app/record/components/affiliation-stacks-groups/affiliation-stacks-groups.component.html

+3-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
[(expandedContent)]="expandedContent['EMPLOYMENT']"
2222
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
2323
[isPublicRecord]="isPublicRecord"
24+
[sortTypes]="['title', 'start', 'end', 'source']"
2425
[sortType]="'end'"
2526
(sort)="sortEvent($event, 'EMPLOYMENT')"
2627
id="cy-affiliation-employment"
@@ -85,6 +86,7 @@
8586
[(expandedContent)]="expandedContent['EDUCATION_AND_QUALIFICATION']"
8687
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
8788
[isPublicRecord]="isPublicRecord"
89+
[sortTypes]="['title', 'start', 'end', 'source']"
8890
[sortType]="'end'"
8991
(sort)="sortEvent($event, 'EDUCATION_AND_QUALIFICATION')"
9092
id="cy-affiliation-education-and-qualification"
@@ -287,7 +289,7 @@
287289
[(expandedContent)]="expandedContent['PROFESSIONAL_ACTIVITIES']"
288290
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
289291
[isPublicRecord]="isPublicRecord"
290-
[sortTypes]="['title', 'type', 'start', 'end']"
292+
[sortTypes]="['title', 'type', 'start', 'end', 'source']"
291293
(sort)="sortEvent($event, 'PROFESSIONAL_ACTIVITIES')"
292294
[professionalActivitiesTogglz]="professionalActivitiesTogglz"
293295
id="cy-affiliation-professional-activities"

src/app/record/components/funding-stacks-groups/funding-stacks-groups.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[isPublicRecord]="isPublicRecord"
1616
[(expandedContent)]="expandedContent['FUNDING']"
1717
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
18-
[sortTypes]="['date', 'title', 'type']"
18+
[sortTypes]="['date', 'title', 'type', 'source']"
1919
[sortType]="'date'"
2020
(sort)="sortEvent($event)"
2121
>

src/app/record/components/work-stack-group/work-stack-group.component.html

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
[isPublicRecord]="isPublicRecord"
1616
[(expandedContent)]="expandedContent['WORK']"
1717
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
18-
[sortTypes]="['date', 'title', 'type']"
18+
[sortTypes]="['date', 'title', 'type', 'source']"
1919
[sortType]="'date'"
2020
[addMenuOptions]="addMenuOptions"
2121
(sort)="sortEvent($event)"

src/app/shared/pipes/app-panels-sort-by-aria-label/app-panels-sort-by-aria-label.pipe.ts

+18
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ export class AppPanelsSortByAriaLabelPipe implements PipeTransform {
1717
return getDateLabelByType(type)
1818
case 'type':
1919
return getTypeLabelByType(type)
20+
case 'source':
21+
return getSourceLabelByType(type)
2022
case 'order':
2123
return $localize`:@@shared.peerReviewsSortOrderv2:Sort peer review by Publication/Grant title`
2224
}
@@ -104,3 +106,19 @@ const getDateLabelByType = (type: string): string => {
104106
return $localize`:@@shared.researchSortDate:Sort research resources by date`
105107
}
106108
}
109+
110+
const getSourceLabelByType = (type: string): string => {
111+
switch (type) {
112+
case 'employment':
113+
return $localize`:@@shared.employmentSortSource:Sort employment by source`
114+
case 'education':
115+
case 'qualification':
116+
return $localize`:@@shared.educationSortSource:Sort education and qualifications by source`
117+
case 'professional-activities':
118+
return $localize`:@@shared.professionalActivitiesSortSource:Sort professional activities by source`
119+
case 'funding':
120+
return $localize`:@@shared.fundingSortSource:Sort funding by source`
121+
case 'works':
122+
return $localize`:@@shared.worksSortSource:Sort works by source`
123+
}
124+
}

src/app/types/sort.ts

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ export type SortOrderType =
77
| 'date'
88
| 'type'
99
| 'order'
10+
| 'source'
1011

1112
export interface SortData {
1213
direction: SortOrderDirection

src/environments/environment.local.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ export const environment = {
88
BASE_URL: '',
99
INFO_SITE: 'https://info.orcid.org/',
1010
GOOGLE_ANALYTICS_TESTING_MODE: true,
11-
GOOGLE_TAG_MANAGER: 'GTM-0000000',
11+
GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS',
1212
GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
1313
HELP_HERO_ID: 'oYFQMrzFHA',
1414
ZENDESK: null,

src/locale/properties/shared/shared.en.properties

+5
Original file line numberDiff line numberDiff line change
@@ -628,3 +628,8 @@ shared.researchSortDate=Sort research resources by date
628628
shared.today=Today
629629
share.more=more
630630
shared.orcidHelpCenter=ORCID Help Center
631+
shared.employmentSortSource=Sort employment by source
632+
shared.educationSortSource=Sort education and qualifications by source
633+
shared.fundingSortSource=Sort works by source
634+
shared.professionalActivitiesSortSource=Sort professional activities by source
635+
shared.worksSortSource=Sort funding by source

0 commit comments

Comments
 (0)