Skip to content

Commit

Permalink
Merge branch 'main' into fix/8877-orcid-id-doesnt-wrap-on-firefox
Browse files Browse the repository at this point in the history
  • Loading branch information
amontenegro authored Oct 20, 2023
2 parents aa5a720 + ddb2548 commit 493679b
Show file tree
Hide file tree
Showing 2 changed files with 49 additions and 11 deletions.
14 changes: 14 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
## v2.43.3 - 2023-10-20

[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.43.2...v2.43.3)

### Fix

- Update sort by source functionality to sort also alphabetically (#2079)

## v2.43.2 - 2023-10-18

[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.43.1...v2.43.2)

- [#2078](https://github.com/ORCID/orcid-angular/pull/2078): Revert "Angular update 15 16"

## v2.43.1 - 2023-10-17

[Full Changelog](https://github.com/ORCID/orcid-angular/compare/v2.43.0...v2.43.1)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { Injectable } from '@angular/core'
import { MonthDayYearDate } from 'src/app/types'
import {
AffiliationUIGroup,
AffiliationGroup,
AffiliationType,
AffiliationUIGroup,
} from 'src/app/types/record-affiliation.endpoint'
import { UserRecordOptions } from 'src/app/types/record.local'

Expand Down Expand Up @@ -88,15 +88,21 @@ export class AffiliationsSortService {
}

if (by === 'source') {
affiliationGroup.sort((a, b) => {
return (
Number(AffiliationsSortService.isSelfAsserted(a, orcid)) -
Number(AffiliationsSortService.isSelfAsserted(b, orcid))
)
})
if (ascending) {
affiliationGroup.reverse()
}
const selfAsserted = this.getSelfAssertedOrValidatedAffiliations(
affiliationGroup,
ascending,
orcid,
'self-asserted'
)
const validated = this.getSelfAssertedOrValidatedAffiliations(
affiliationGroup,
ascending,
orcid,
'validated'
)
x.affiliationGroup = ascending
? [...selfAsserted, ...validated]
: [...validated, ...selfAsserted]
}
}
})
Expand Down Expand Up @@ -206,7 +212,25 @@ export class AffiliationsSortService {
})
}

private static isSelfAsserted(
private getSelfAssertedOrValidatedAffiliations(
affiliationGroup: AffiliationGroup[],
ascending: boolean,
orcid: string,
type: 'self-asserted' | 'validated'
): AffiliationGroup[] {
return affiliationGroup
.filter((affiliationGroup) => {
const selfAsserted = this.isSelfAsserted(affiliationGroup, orcid)
return type === 'self-asserted' ? selfAsserted : !selfAsserted
})
.sort((a, b) => {
return ('' + a.defaultAffiliation.affiliationName.value).localeCompare(
'' + b.defaultAffiliation.affiliationName.value
)
})
}

private isSelfAsserted(
affiliationGroup: AffiliationGroup,
orcid: string
): boolean {
Expand Down

0 comments on commit 493679b

Please sign in to comment.