1
0

Add bulk edit for tasks (#42)

This commit is contained in:
konrad
2018-12-28 21:49:46 +00:00
committed by Gitea
parent b050132f4f
commit 3814b8a504
16 changed files with 862 additions and 20 deletions

View File

@ -91,16 +91,8 @@ func (i *ListTask) Update() (err error) {
return
}
// When a repeating task is marked, as done, we update all deadlines and reminders and set it as undone
if !ot.Done && i.Done && ot.RepeatAfter > 0 {
ot.DueDateUnix = ot.DueDateUnix + ot.RepeatAfter
for in, r := range ot.RemindersUnix {
ot.RemindersUnix[in] = r + ot.RepeatAfter
}
i.Done = false
}
// When a repeating task is marked as done, we update all deadlines and reminders and set it as undone
updateDone(&ot, i)
// For whatever reason, xorm dont detect if done is updated, so we need to update this every time by hand
// Which is why we merge the actual task struct with the one we got from the
@ -129,3 +121,15 @@ func (i *ListTask) Update() (err error) {
*i = ot
return
}
func updateDone(oldTask *ListTask, newTask *ListTask) {
if !oldTask.Done && newTask.Done && oldTask.RepeatAfter > 0 {
oldTask.DueDateUnix = oldTask.DueDateUnix + oldTask.RepeatAfter // assuming we'll save the old task (merged)
for in, r := range oldTask.RemindersUnix {
oldTask.RemindersUnix[in] = r + oldTask.RepeatAfter
}
newTask.Done = false
}
}