Skip to content

Commit

Permalink
Merge pull request #5131 from carlobeltrame/better-proposals-for-sche…
Browse files Browse the repository at this point in the history
…dule-entry-times

More intelligent proposed times when adding more schedule entries to an activity
  • Loading branch information
pmattmann committed May 18, 2024
2 parents 244689a + e3f775b commit 2ea1a1f
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions frontend/src/components/program/FormScheduleEntryList.vue
Original file line number Diff line number Diff line change
Expand Up @@ -68,13 +68,32 @@ export default {
scheduleEntriesWithoutDeleted() {
return this.scheduleEntries.filter((entry) => !entry.deleted)
},
lastScheduleEntry() {
return this.localScheduleEntries[this.localScheduleEntries.length - 1]
},
lastScheduleEntryStart() {
return dayjs.utc(this.lastScheduleEntry.start)
},
lastScheduleEntryEnd() {
return dayjs.utc(this.lastScheduleEntry.end)
},
lastScheduleEntryDuration() {
return this.lastScheduleEntryEnd.diff(this.lastScheduleEntryStart)
},
},
methods: {
addScheduleEntry() {
const proposedStart = this.lastScheduleEntryStart.add(1, 'day')
const proposedEnd = proposedStart.add(this.lastScheduleEntryDuration)
const periodEnd = dayjs.utc(this.period.end).add(24, 'hour')
const start = proposedEnd.isSameOrBefore(periodEnd)
? proposedStart
: dayjs.utc(this.period.start).add(7, 'hour')
const end = start.add(this.lastScheduleEntryDuration)
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 2ea1a1f

Please sign in to comment.