diff --git a/api/project.go b/api/project.go index 61c0647..6fc4d9d 100644 --- a/api/project.go +++ b/api/project.go @@ -54,6 +54,10 @@ func Project(g *gin.RouterGroup, db database.Database) { return nil, err } + if project.Active && project.StatusTag != nil { + project.StatusTag = nil + } + return &models.ProjectResult{ Project: project, Tasks: []*models.TaskResult{}, diff --git a/migrations/postgres/20210227192216_update_project_fix_active_and_status_tag.sql b/migrations/postgres/20210227192216_update_project_fix_active_and_status_tag.sql new file mode 100644 index 0000000..96e03d9 --- /dev/null +++ b/migrations/postgres/20210227192216_update_project_fix_active_and_status_tag.sql @@ -0,0 +1,9 @@ +-- +goose Up +-- +goose StatementBegin +UPDATE project SET status_tag=NULL WHERE active=true; +-- +goose StatementEnd + +-- +goose Down +-- +goose StatementBegin +SELECT 'Nothing to do'; +-- +goose StatementEnd diff --git a/models/project.go b/models/project.go index 0e398df..0d39991 100644 --- a/models/project.go +++ b/models/project.go @@ -47,6 +47,10 @@ func (project *Project) Update(update ProjectUpdate) { if update.Favorite != nil { project.Favorite = *update.Favorite } + + if project.StatusTag != nil && !project.Active { + project.StatusTag = nil + } } type ProjectUpdate struct { diff --git a/svelte-ui/src/forms/ProjectForm.svelte b/svelte-ui/src/forms/ProjectForm.svelte index f979c60..e10bd5e 100644 --- a/svelte-ui/src/forms/ProjectForm.svelte +++ b/svelte-ui/src/forms/ProjectForm.svelte @@ -53,7 +53,7 @@ stuffLogClient.createProject({ active: statusTag === "", endTime: ( endTime == "" ) ? null : new Date(endTime), - statusTag: statusTag || null, + statusTag: statusTag !== "" ? statusTag : null, name, description, icon, favorite, }).then(() => {