From 30674c27e20e4c7ccbc59f9ccd8ae8e5f849799a Mon Sep 17 00:00:00 2001 From: fsimonjetz Date: Fri, 2 Feb 2024 14:29:07 +0000 Subject: [PATCH] rename dateRange field --- src/fragmentarium/domain/archaeology.test.ts | 11 +++++------ src/fragmentarium/domain/archaeology.ts | 14 +++++++------- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/src/fragmentarium/domain/archaeology.test.ts b/src/fragmentarium/domain/archaeology.test.ts index 35971f36e..31d7d12d0 100644 --- a/src/fragmentarium/domain/archaeology.test.ts +++ b/src/fragmentarium/domain/archaeology.test.ts @@ -42,10 +42,9 @@ const planDto = { references: [referenceDto], } const plan = { svg: '', references: [reference] } -const dateRange = dateRangeFactory.build() const findspot = findspotFactory.build({ site: excavationSites[site], - dateRange: dateRange, + date: dateRangeFactory.build(), plans: [plan], }) const findspotDto: FindspotDto = { @@ -59,7 +58,7 @@ const findspotDto: FindspotDto = { 'context', 'primaryContext', 'notes', - 'dateRange' + 'date' ), _id: findspot.id, site: site, @@ -70,7 +69,7 @@ const displayParams: Partial = { building: 'a house', buildingType: 'RESIDENTIAL' as BuildingType, levelLayerPhase: 'II', - dateRange: { + date: { start: -1200, end: -1150, notes: '', @@ -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).', ], diff --git a/src/fragmentarium/domain/archaeology.ts b/src/fragmentarium/domain/archaeology.ts index f72f4f87d..a906e529f 100644 --- a/src/fragmentarium/domain/archaeology.ts +++ b/src/fragmentarium/domain/archaeology.ts @@ -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 = '', @@ -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})` : '' } @@ -122,7 +122,7 @@ export type FindspotDto = Pick< > & { _id: number site: SiteKey - dateRange: CommentedDateRangeDto | null + date: CommentedDateRangeDto | null plans: readonly PlanDto[] } @@ -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, @@ -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), } }