diff --git a/api/task.go b/api/task.go index d339f1c..4a8f8db 100644 --- a/api/task.go +++ b/api/task.go @@ -33,13 +33,17 @@ func Task(g *gin.RouterGroup, db database.Database) { })) g.POST("/", handler("task", func(c *gin.Context) (interface{}, error) { + createdTime := time.Now() task := models.Task{} err := c.BindJSON(&task) if err != nil { return nil, slerrors.BadRequest("Invalid JSON") } - if task.EndTime != nil && task.EndTime.Before(time.Now()) { - return nil, slerrors.BadRequest("Project end time must be later than current time.") + if task.EndTime != nil && task.EndTime.Before(createdTime) { + return nil, slerrors.BadRequest("Task end time must be later than current time.") + } + if task.ItemAmount <= 0 { + return nil, slerrors.BadRequest("Item amount cannot be zero or negative.") } project, err := l.FindProject(c.Request.Context(), task.ProjectID) @@ -83,6 +87,13 @@ func Task(g *gin.RouterGroup, db database.Database) { } task.Update(update) + if task.EndTime != nil && task.EndTime.Before(task.CreatedTime) { + return nil, slerrors.BadRequest("Task end time must be later than it was created.") + } + if task.ItemAmount <= 0 { + return nil, slerrors.BadRequest("Item amount cannot be zero or negative.") + } + err = db.Tasks().Update(c.Request.Context(), task.Task) if err != nil { return nil, err diff --git a/svelte-ui/src/components/LogEntry.svelte b/svelte-ui/src/components/LogEntry.svelte index e5880fe..09bdc27 100644 --- a/svelte-ui/src/components/LogEntry.svelte +++ b/svelte-ui/src/components/LogEntry.svelte @@ -10,10 +10,12 @@ export let log: LogResult = null; let taskIconName: IconName = "question"; + let itemIconName: IconName = "question"; let mdLogEdit: ModalData; let mdLogDelete: ModalData; $: taskIconName = log.task.icon as IconName; + $: itemIconName = log.item.icon as IconName; $: mdLogEdit = {name: "log.edit", log}; $: mdLogDelete = {name: "log.delete", log}; @@ -31,7 +33,7 @@

{log.description}

- +
{log.item.name} ({log.item.groupWeight})
diff --git a/svelte-ui/src/forms/TaskAddForm.svelte b/svelte-ui/src/forms/TaskAddForm.svelte index 6648698..3fcb50e 100644 --- a/svelte-ui/src/forms/TaskAddForm.svelte +++ b/svelte-ui/src/forms/TaskAddForm.svelte @@ -26,6 +26,8 @@ projectStore.markStale(); fpProjectStore.markStale(); modalStore.close(); + }).catch(err => { + error = err.message ? err.message : err.toString(); }) error = null; diff --git a/svelte-ui/src/forms/TaskEditForm.svelte b/svelte-ui/src/forms/TaskEditForm.svelte index 84c0c94..4c70479 100644 --- a/svelte-ui/src/forms/TaskEditForm.svelte +++ b/svelte-ui/src/forms/TaskEditForm.svelte @@ -33,6 +33,8 @@ import Checkbox from "../components/Checkbox.svelte"; goalStore.markStale(); fpGoalStore.markStale(); modalStore.close(); + }).catch(err => { + error = err.message ? err.message : err.toString(); }) error = null;