Colors for lists and namespaces (#155)
Add Hex Color properties migration Add Hex Color properties Co-authored-by: kolaente <k@knt.li> Reviewed-on: https://kolaente.dev/vikunja/api/pulls/155
This commit is contained in:
@ -34,6 +34,8 @@ type List struct {
|
||||
Description string `xorm:"longtext null" json:"description"`
|
||||
// The unique list short identifier. Used to build task identifiers.
|
||||
Identifier string `xorm:"varchar(10) null" json:"identifier" valid:"runelength(0|10)" minLength:"0" maxLength:"10"`
|
||||
// The hex color of this list
|
||||
HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"`
|
||||
|
||||
OwnerID int64 `xorm:"int(11) INDEX not null" json:"-"`
|
||||
NamespaceID int64 `xorm:"int(11) INDEX not null" json:"-" param:"namespace"`
|
||||
@ -382,6 +384,9 @@ func CreateOrUpdateList(list *List) (err error) {
|
||||
if list.Identifier != "" {
|
||||
colsToUpdate = append(colsToUpdate, "identifier")
|
||||
}
|
||||
if list.HexColor != "" {
|
||||
colsToUpdate = append(colsToUpdate, "hex_color")
|
||||
}
|
||||
|
||||
_, err = x.
|
||||
ID(list.ID).
|
||||
|
@ -36,6 +36,9 @@ type Namespace struct {
|
||||
Description string `xorm:"longtext null" json:"description"`
|
||||
OwnerID int64 `xorm:"int(11) not null INDEX" json:"-"`
|
||||
|
||||
// The hex color of this namespace
|
||||
HexColor string `xorm:"varchar(6) null" json:"hex_color" valid:"runelength(0|6)" maxLength:"6"`
|
||||
|
||||
// Whether or not a namespace is archived.
|
||||
IsArchived bool `xorm:"not null default false" json:"is_archived" query:"is_archived"`
|
||||
|
||||
@ -461,6 +464,9 @@ func (n *Namespace) Update() (err error) {
|
||||
if n.Description != "" {
|
||||
colsToUpdate = append(colsToUpdate, "description")
|
||||
}
|
||||
if n.HexColor != "" {
|
||||
colsToUpdate = append(colsToUpdate, "hex_color")
|
||||
}
|
||||
|
||||
// Do the actual update
|
||||
_, err = x.
|
||||
|
Reference in New Issue
Block a user