From 7b1e37b3a7bf94d92af9c0ac1dccbf44b87ad6ee Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Tim=20Gr=C3=B6ger?= Date: Tue, 16 Jan 2024 15:52:23 +0100 Subject: [PATCH] fix correct datetimes in jobslots when come from template --- src/components/management/EditEvent.vue | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/components/management/EditEvent.vue b/src/components/management/EditEvent.vue index 5ee363e..d795369 100644 --- a/src/components/management/EditEvent.vue +++ b/src/components/management/EditEvent.vue @@ -183,7 +183,7 @@ export default defineComponent({ } function fromTemplate(tpl: FG.Event) { - const today = new Date(); + const today = props.modelValue?.start || new Date(); template.value = tpl; event.value = Object.assign({}, tpl, { id: undefined }); @@ -199,9 +199,16 @@ export default defineComponent({ if (event.value.end) event.value.end.setTime(event.value.end.getTime() + diff); event.value.jobs = []; tpl.jobs.forEach((job) => { - const copied_job: FG.Job = Object.assign({}, job, { id: NaN }); - copied_job.start.setTime(copied_job.start.getTime() + diff); - if (copied_job.end) copied_job.end.setTime(copied_job.end.getTime() + diff); + const copied_job: FG.Job = Object.assign({}, job, { + id: NaN, + start: new Date(), + end: undefined, + }); + copied_job.start.setTime(job.start.getTime() + diff); + if (job.end) { + copied_job.end = new Date(); + copied_job.end.setTime(job.end.getTime() + diff); + } event.value.jobs.push(copied_job); }); }