Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feature: Add new source sorting option for affiliations, funding and … #2064

Merged
merged 2 commits into from
Oct 2, 2023
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
1 change: 1 addition & 0 deletions src/app/cdk/panel/sort-label.pipe.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ export class SortLabelPipe implements PipeTransform {
date: $localize`:@@share.sortDate:Date`,
type: $localize`:@@share.sortType:Type`,
order: $localize`:@@share.sortOrderv2:Publication/Grant title`,
source: $localize`:@@share.source:Source`,
}
transform(value: SortOrderType): string {
return this.SortOrderTypeLabel[value]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { Component, Input, OnDestroy, OnInit } from '@angular/core'
import { first, takeUntil } from 'rxjs/operators'
import { Subject } from 'rxjs'
import { MatDialog } from '@angular/material/dialog'
import { RecordEmailsService } from 'src/app/core/record-emails/record-emails.service'
import { RecordService } from 'src/app/core/record/record.service'
import { PlatformInfoService } from '../platform-info'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import {
AffiliationUIGroup,
AffiliationGroup,
AffiliationType,
AffiliationTypeValue,
} from 'src/app/types/record-affiliation.endpoint'
import { UserRecordOptions } from 'src/app/types/record.local'

Expand All @@ -21,15 +20,17 @@ export class AffiliationsSortService {
value,
userRecordContext?.sortAsc,
userRecordContext?.sort,
type
type,
userRecordContext?.publicRecordId || userRecordContext?.privateRecordId
)
}

sort(
affiliationGroups: AffiliationUIGroup[],
ascending = false,
by = 'end',
type = null
type = null,
orcid: string
): AffiliationUIGroup[] {
if (type === 'PROFESSIONAL_ACTIVITIES' && by === 'type') {
const affiliations = affiliationGroups.filter(
Expand Down Expand Up @@ -85,6 +86,15 @@ export class AffiliationsSortService {
affiliationGroup.reverse()
}
}

if (by === 'source') {
affiliationGroup.sort((a, b) => {
return Number(AffiliationsSortService.isSelfAsserted(a, orcid)) - Number(AffiliationsSortService.isSelfAsserted(b, orcid))
})
if (!ascending) {
affiliationGroup.reverse()
}
}
}
})
return affiliationGroups
Expand Down Expand Up @@ -192,4 +202,8 @@ export class AffiliationsSortService {
return this.sortByDate(a, b, false, 'end')
})
}

private static isSelfAsserted(affiliationGroup: AffiliationGroup, orcid: string): boolean {
return affiliationGroup.defaultAffiliation.source === orcid
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
[(expandedContent)]="expandedContent['EMPLOYMENT']"
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
[isPublicRecord]="isPublicRecord"
[sortTypes]="['title', 'start', 'end', 'source']"
[sortType]="'end'"
(sort)="sortEvent($event, 'EMPLOYMENT')"
id="cy-affiliation-employment"
Expand Down Expand Up @@ -85,6 +86,7 @@
[(expandedContent)]="expandedContent['EDUCATION_AND_QUALIFICATION']"
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
[isPublicRecord]="isPublicRecord"
[sortTypes]="['title', 'start', 'end', 'source']"
[sortType]="'end'"
(sort)="sortEvent($event, 'EDUCATION_AND_QUALIFICATION')"
id="cy-affiliation-education-and-qualification"
Expand Down Expand Up @@ -287,7 +289,7 @@
[(expandedContent)]="expandedContent['PROFESSIONAL_ACTIVITIES']"
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
[isPublicRecord]="isPublicRecord"
[sortTypes]="['title', 'type', 'start', 'end']"
[sortTypes]="['title', 'type', 'start', 'end', 'source']"
(sort)="sortEvent($event, 'PROFESSIONAL_ACTIVITIES')"
[professionalActivitiesTogglz]="professionalActivitiesTogglz"
id="cy-affiliation-professional-activities"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[isPublicRecord]="isPublicRecord"
[(expandedContent)]="expandedContent['FUNDING']"
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
[sortTypes]="['date', 'title', 'type']"
[sortTypes]="['date', 'title', 'type', 'source']"
[sortType]="'date'"
(sort)="sortEvent($event)"
>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
[isPublicRecord]="isPublicRecord"
[(expandedContent)]="expandedContent['WORK']"
(expandedContentChange)="expandedContentChange.emit(expandedContent)"
[sortTypes]="['date', 'title', 'type']"
[sortTypes]="['date', 'title', 'type', 'source']"
[sortType]="'date'"
[addMenuOptions]="addMenuOptions"
(sort)="sortEvent($event)"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ export class AppPanelsSortByAriaLabelPipe implements PipeTransform {
return getDateLabelByType(type)
case 'type':
return getTypeLabelByType(type)
case 'source':
return getSourceLabelByType(type)
case 'order':
return $localize`:@@shared.peerReviewsSortOrderv2:Sort peer review by Publication/Grant title`
}
Expand Down Expand Up @@ -104,3 +106,19 @@ const getDateLabelByType = (type: string): string => {
return $localize`:@@shared.researchSortDate:Sort research resources by date`
}
}

const getSourceLabelByType = (type: string): string => {
switch (type) {
case 'employment':
return $localize`:@@shared.employmentSortSource:Sort employment by source`
case 'education':
case 'qualification':
return $localize`:@@shared.educationSortSource:Sort education and qualifications by source`
case 'professional-activities':
return $localize`:@@shared.professionalActivitiesSortSource:Sort professional activities by source`
case 'funding':
return $localize`:@@shared.fundingSortSource:Sort funding by source`
case 'works':
return $localize`:@@shared.worksSortSource:Sort works by source`
}
}
1 change: 1 addition & 0 deletions src/app/types/sort.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ export type SortOrderType =
| 'date'
| 'type'
| 'order'
| 'source'

export interface SortData {
direction: SortOrderDirection
Expand Down
2 changes: 1 addition & 1 deletion src/environments/environment.local.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const environment = {
BASE_URL: '',
INFO_SITE: 'https://info.orcid.org/',
GOOGLE_ANALYTICS_TESTING_MODE: true,
GOOGLE_TAG_MANAGER: 'GTM-0000000',
GOOGLE_TAG_MANAGER: 'GTM-M9Z7DHS',
DanielPalafox marked this conversation as resolved.
Show resolved Hide resolved
GOOGLE_RECAPTCHA: '6LeIxAcTAAAAAJcZVRqyHh71UMIEGNQ_MXjiZKhI',
HELP_HERO_ID: 'oYFQMrzFHA',
ZENDESK: null,
Expand Down
5 changes: 5 additions & 0 deletions src/locale/properties/shared/shared.en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -628,3 +628,8 @@ shared.researchSortDate=Sort research resources by date
shared.today=Today
share.more=more
shared.orcidHelpCenter=ORCID Help Center
shared.employmentSortSource=Sort employment by source
shared.educationSortSource=Sort education and qualifications by source
shared.fundingSortSource=Sort works by source
shared.professionalActivitiesSortSource=Sort professional activities by source
shared.worksSortSource=Sort funding by source
Loading