fix correct datetimes in jobslots when come from template

This commit is contained in:
Tim Gröger 2024-01-16 15:52:23 +01:00
parent 9a648e8443
commit 7b1e37b3a7
1 changed files with 11 additions and 4 deletions

View File

@ -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(<Job>copied_job);
});
}