Skip to content

Commit

Permalink
rename dateRange field
Browse files Browse the repository at this point in the history
  • Loading branch information
fsimonjetz committed Feb 2, 2024
1 parent 81193c9 commit 30674c2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 13 deletions.
11 changes: 5 additions & 6 deletions src/fragmentarium/domain/archaeology.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,10 +42,9 @@ const planDto = {
references: [referenceDto],
}
const plan = { svg: '<svg></svg>', references: [reference] }
const dateRange = dateRangeFactory.build()
const findspot = findspotFactory.build({
site: excavationSites[site],
dateRange: dateRange,
date: dateRangeFactory.build(),
plans: [plan],
})
const findspotDto: FindspotDto = {
Expand All @@ -59,7 +58,7 @@ const findspotDto: FindspotDto = {
'context',
'primaryContext',
'notes',
'dateRange'
'date'
),
_id: findspot.id,
site: site,
Expand All @@ -70,7 +69,7 @@ const displayParams: Partial<Findspot> = {
building: 'a house',
buildingType: 'RESIDENTIAL' as BuildingType,
levelLayerPhase: 'II',
dateRange: {
date: {
start: -1200,
end: -1150,
notes: '',
Expand Down Expand Up @@ -141,14 +140,14 @@ test.each([
],
[
'no levelLayerPhase and date',
{ ...displayParams, levelLayerPhase: '', dateRange: null },
{ ...displayParams, levelLayerPhase: '', date: null },
'a house (Residential).',
],
[
'with date notes',
{
...displayParams,
dateRange: { ...displayParams.dateRange, notes: 'date notes' },
date: { ...displayParams.date, notes: 'date notes' },
},
'a house (Residential), II (1200 BCE - 1150 BCE, date notes).',
],
Expand Down
14 changes: 7 additions & 7 deletions src/fragmentarium/domain/archaeology.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ export class Findspot {
readonly building: string = '',
readonly buildingType: BuildingType | null = null,
readonly levelLayerPhase: string = '',
readonly dateRange: CommentedDateRange | null = null,
readonly date: CommentedDateRange | null = null,
readonly plans: readonly ExcavationPlan[] = [],
readonly room: string = '',
readonly context: string = '',
Expand All @@ -72,9 +72,9 @@ export class Findspot {
) {}

private dateString(): string {
const start = makeDate(this.dateRange?.start)
const end = makeDate(this.dateRange?.end)
const notes = padLeft(this.dateRange?.notes, ', ')
const start = makeDate(this.date?.start)
const end = makeDate(this.date?.end)
const notes = padLeft(this.date?.notes, ', ')

return end ? ` (${start} - ${end}${notes})` : start ? ` (${start})` : ''
}
Expand Down Expand Up @@ -122,7 +122,7 @@ export type FindspotDto = Pick<
> & {
_id: number
site: SiteKey
dateRange: CommentedDateRangeDto | null
date: CommentedDateRangeDto | null
plans: readonly PlanDto[]
}

Expand Down Expand Up @@ -155,7 +155,7 @@ export function fromFindspotDto(dto: FindspotDto): Findspot {
dto.building,
dto.buildingType,
dto.levelLayerPhase,
dto.dateRange,
dto.date,
dto.plans.map(fromPlanDto),
dto.room,
dto.context,
Expand All @@ -176,7 +176,7 @@ export function toFindspotDto(findspot: Findspot): FindspotDto {
primaryContext: findspot.primaryContext,
notes: findspot.notes,
site: findspot.site.name as SiteKey,
dateRange: findspot.dateRange,
date: findspot.date,
plans: findspot.plans.map(toPlanDto),
}
}
Expand Down

0 comments on commit 30674c2

Please sign in to comment.