2021-09-23 21:14:35 +01:00
|
|
|
package board
|
2021-09-18 01:03:09 +01:00
|
|
|
|
|
|
|
// Status represents the status of the Kanban board.
|
|
|
|
type Status struct {
|
|
|
|
ID int
|
|
|
|
Name string
|
|
|
|
CardIds []int
|
|
|
|
Order int
|
|
|
|
}
|
|
|
|
|
2021-09-23 21:14:35 +01:00
|
|
|
// UpdateId updates the ID of the Status value.
|
|
|
|
func (s *Status) UpdateId(id int) {
|
|
|
|
s.ID = id
|
|
|
|
}
|
|
|
|
|
|
|
|
// Id returns the ID of the Status value.
|
|
|
|
func (s *Status) Id() int {
|
|
|
|
return s.ID
|
|
|
|
}
|
|
|
|
|
|
|
|
func (s *Status) AddCardID(id int) {
|
|
|
|
s.CardIds = append(s.CardIds, id)
|
|
|
|
}
|
|
|
|
|
2021-09-18 01:03:09 +01:00
|
|
|
// 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
|
|
|
|
}
|
|
|
|
|
2021-09-23 21:14:35 +01:00
|
|
|
// defaultStatusList returns the default list of statuses.
|
|
|
|
func defaultStatusList() []Status {
|
2021-09-18 01:03:09 +01:00
|
|
|
return []Status{
|
|
|
|
{
|
|
|
|
ID: -1,
|
|
|
|
Name: "To Do",
|
|
|
|
Order: 1,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: -1,
|
|
|
|
Name: "Doing",
|
|
|
|
Order: 2,
|
|
|
|
},
|
|
|
|
{
|
|
|
|
ID: -1,
|
|
|
|
Name: "Done",
|
|
|
|
Order: 3,
|
|
|
|
},
|
|
|
|
}
|
|
|
|
}
|