Skip to content

Commit

Permalink
More intelligent proposed times when adding more schedule entries
Browse files Browse the repository at this point in the history
  • Loading branch information
carlobeltrame committed May 6, 2024
1 parent 7c6ce39 commit 3f33c20
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions frontend/src/components/program/FormScheduleEntryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,20 @@ export default {
},
methods: {
addScheduleEntry() {
const previous = this.localScheduleEntries[this.localScheduleEntries.length - 1]
const previousStart = dayjs.utc(previous.start)
const previousEnd = dayjs.utc(previous.end)
const duration = previousEnd.diff(previousStart)
const proposedEnd = previousEnd.add(duration)
const periodEnd = dayjs.utc(this.period.end).add(24, 'hour')
const start = proposedEnd.isSameOrBefore(periodEnd)
? previousEnd
: dayjs.utc(this.period.start).add(7, 'hour')
const end = start.add(duration)
this.localScheduleEntries.push({
period: () => this.period,
start: dayjs.utc(this.period.start).add(7, 'hour').format(),
end: dayjs.utc(this.period.start).add(8, 'hour').format(),
start: start.format(),
end: end.format(),
key: uniqueId(),
deleted: false,
})
Expand Down

0 comments on commit 3f33c20

Please sign in to comment.