46 lines
789 B
Go
46 lines
789 B
Go
|
package status
|
||
|
|
||
|
// Status represents the status of the Kanban board.
|
||
|
type Status struct {
|
||
|
ID int
|
||
|
Name string
|
||
|
CardIds []int
|
||
|
Order int
|
||
|
}
|
||
|
|
||
|
// ByStatusOrder implements sort.Interface for []Status based on the Order field.
|
||
|
type ByStatusOrder []Status
|
||
|
|
||
|
func (s ByStatusOrder) Len() int {
|
||
|
return len(s)
|
||
|
}
|
||
|
|
||
|
func (s ByStatusOrder) Swap(i, j int) {
|
||
|
s[i], s[j] = s[j], s[i]
|
||
|
}
|
||
|
|
||
|
func (s ByStatusOrder) Less(i, j int) bool {
|
||
|
return s[i].Order < s[j].Order
|
||
|
}
|
||
|
|
||
|
// NewDefaultStatusList creates the default list of statuses and saves the statuses to the database.
|
||
|
func NewDefaultStatusList() []Status {
|
||
|
return []Status{
|
||
|
{
|
||
|
ID: -1,
|
||
|
Name: "To Do",
|
||
|
Order: 1,
|
||
|
},
|
||
|
{
|
||
|
ID: -1,
|
||
|
Name: "Doing",
|
||
|
Order: 2,
|
||
|
},
|
||
|
{
|
||
|
ID: -1,
|
||
|
Name: "Done",
|
||
|
Order: 3,
|
||
|
},
|
||
|
}
|
||
|
}
|