Skip to content

Commit

Permalink
add oracc numbers type
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Oct 30, 2023
1 parent b5d3ba3 commit 486bf91
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
2 changes: 2 additions & 0 deletions src/fragmentarium/domain/FragmentDtos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,8 @@ export type ExternalNumber = typeof ExternalNumberTypes[number]

export type ExternalNumbers = {
[K in ExternalNumber]?: string
} & {
oraccNumbers?: readonly string[]
}

export default interface FragmentDto {
Expand Down
14 changes: 10 additions & 4 deletions src/fragmentarium/domain/fragment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,9 @@ export class Fragment {
})
}

private getExternalNumber(numberType: ExternalNumber): string {
private getExternalNumber(
numberType: Exclude<ExternalNumber, 'oraccNumbers'>
): string {
return this.externalNumbers[numberType] || ''
}

Expand Down Expand Up @@ -262,10 +264,14 @@ export class Fragment {
get yalePeabodyNumber(): string {
return this.getExternalNumber('yalePeabodyNumber')
}
get oraccNumbers(): readonly string[] {
return this.externalNumbers['oraccNumbers'] || []
}
get hasExternalResources(): boolean {
return _.some(
ExternalNumberTypes.map((number) => this.getExternalNumber(number))
)
return _.some([
...this.oraccNumbers,
...ExternalNumberTypes.map((number) => this.getExternalNumber(number)),
])
}

get atfHeading(): string {
Expand Down

0 comments on commit 486bf91

Please sign in to comment.