Fix resetting list, label & namespace colors

This commit is contained in:
kolaente 2020-06-15 11:32:07 +02:00
parent 47d7e713af
commit 24c1098736
No known key found for this signature in database
GPG key ID: F40E70337AB24C9B
3 changed files with 10 additions and 7 deletions

View file

@ -92,7 +92,14 @@ func (l *Label) Create(a web.Auth) (err error) {
// @Failure 500 {object} models.Message "Internal error" // @Failure 500 {object} models.Message "Internal error"
// @Router /labels/{id} [put] // @Router /labels/{id} [put]
func (l *Label) Update() (err error) { func (l *Label) Update() (err error) {
_, err = x.ID(l.ID).Update(l) _, err = x.
ID(l.ID).
Cols(
"title",
"description",
"hex_color",
).
Update(l)
if err != nil { if err != nil {
return return
} }

View file

@ -460,13 +460,11 @@ func CreateOrUpdateList(list *List) (err error) {
"title", "title",
"is_archived", "is_archived",
"identifier", "identifier",
"hex_color",
} }
if list.Description != "" { if list.Description != "" {
colsToUpdate = append(colsToUpdate, "description") colsToUpdate = append(colsToUpdate, "description")
} }
if list.HexColor != "" {
colsToUpdate = append(colsToUpdate, "hex_color")
}
_, err = x. _, err = x.
ID(list.ID). ID(list.ID).

View file

@ -448,13 +448,11 @@ func (n *Namespace) Update() (err error) {
colsToUpdate := []string{ colsToUpdate := []string{
"name", "name",
"is_archived", "is_archived",
"hex_color",
} }
if n.Description != "" { if n.Description != "" {
colsToUpdate = append(colsToUpdate, "description") colsToUpdate = append(colsToUpdate, "description")
} }
if n.HexColor != "" {
colsToUpdate = append(colsToUpdate, "hex_color")
}
// Do the actual update // Do the actual update
_, err = x. _, err = x.