fix tags and duedates

This commit is contained in:
bel
2020-01-26 18:34:41 +00:00
parent 2f0c09ff72
commit 6733ccd4b8
4 changed files with 34 additions and 2 deletions

View File

@@ -39,7 +39,7 @@ func New(r *http.Request) (*Task, error) {
UUID: form.NewUUID(),
Title: form.Get(r, "title"),
Priority: form.ToInt(form.Get(r, "prio")),
Tags: StrList(form.ToStrArr(form.Get(r, "tags"))),
Tags: append(StrList(form.ToStrArr(form.Get(r, "tag"))), StrList(form.ToStrArr(form.Get(r, "tags")))...),
Created: time.Now(),
Edited: time.Now(),
@@ -110,6 +110,13 @@ func (t *Task) MarshalJSON() ([]byte, error) {
"dueInt": t.Due.Unix(),
"dueTitle": "Due ",
}
if t.Due.IsZero() {
for k := range m {
if strings.HasPrefix(k, "due") {
delete(m, k)
}
}
}
if t.Complete {
m["dateCompleted"] = t.Completed.Format(fullFormat)
m["dateCompletedInline"] = t.Completed.Format(shortFormat)