Browse Source

fix statusTag being non-nil on active projects.

main
Gisle Aune 4 years ago
parent
commit
e7be563407
  1. 4
      api/project.go
  2. 9
      migrations/postgres/20210227192216_update_project_fix_active_and_status_tag.sql
  3. 4
      models/project.go
  4. 2
      svelte-ui/src/forms/ProjectForm.svelte

4
api/project.go

@ -54,6 +54,10 @@ func Project(g *gin.RouterGroup, db database.Database) {
return nil, err return nil, err
} }
if project.Active && project.StatusTag != nil {
project.StatusTag = nil
}
return &models.ProjectResult{ return &models.ProjectResult{
Project: project, Project: project,
Tasks: []*models.TaskResult{}, Tasks: []*models.TaskResult{},

9
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

4
models/project.go

@ -47,6 +47,10 @@ func (project *Project) Update(update ProjectUpdate) {
if update.Favorite != nil { if update.Favorite != nil {
project.Favorite = *update.Favorite project.Favorite = *update.Favorite
} }
if project.StatusTag != nil && !project.Active {
project.StatusTag = nil
}
} }
type ProjectUpdate struct { type ProjectUpdate struct {

2
svelte-ui/src/forms/ProjectForm.svelte

@ -53,7 +53,7 @@
stuffLogClient.createProject({ stuffLogClient.createProject({
active: statusTag === "", active: statusTag === "",
endTime: ( endTime == "" ) ? null : new Date(endTime), endTime: ( endTime == "" ) ? null : new Date(endTime),
statusTag: statusTag || null,
statusTag: statusTag !== "" ? statusTag : null,
name, description, icon, favorite, name, description, icon, favorite,
}).then(() => { }).then(() => {

Loading…
Cancel
Save