refactor: change Status.Order to Status.Position
Change Status.Order to Status.Position, and the ByStatusOrder type to ByStatusPosition to make it clearer that status' are ordered by their position on the Kanban board.
This commit is contained in:
parent
e13d3e2085
commit
3169d341d2
4 changed files with 64 additions and 64 deletions
|
@ -84,7 +84,7 @@ func (b *Board) StatusList() ([]Status, error) {
|
|||
statuses[ind] = status
|
||||
}
|
||||
|
||||
sort.Sort(ByStatusOrder(statuses))
|
||||
sort.Sort(ByStatusPosition(statuses))
|
||||
|
||||
return statuses, nil
|
||||
}
|
||||
|
@ -119,7 +119,7 @@ func (b *Board) CreateStatus(args StatusArgs) error {
|
|||
status := Status{
|
||||
ID: -1,
|
||||
Name: args.Name,
|
||||
Order: args.Order,
|
||||
Position: args.Order,
|
||||
CardIds: nil,
|
||||
}
|
||||
|
||||
|
@ -147,7 +147,7 @@ func (b *Board) UpdateStatus(args UpdateStatusArgs) error {
|
|||
}
|
||||
|
||||
if args.Order > 0 {
|
||||
status.Order = args.Order
|
||||
status.Position = args.Order
|
||||
}
|
||||
|
||||
if _, err := db.Write(b.db, db.StatusBucket, &status); err != nil {
|
||||
|
|
|
@ -9,7 +9,7 @@ type Status struct {
|
|||
ID int
|
||||
Name string
|
||||
CardIds []int
|
||||
Order int
|
||||
Position int
|
||||
}
|
||||
|
||||
// UpdateID updates the ID of the Status value.
|
||||
|
@ -79,19 +79,19 @@ func (s *Status) RemoveCardID(cardID int) {
|
|||
s.CardIds = append(s.CardIds[:ind], s.CardIds[ind+1:]...)
|
||||
}
|
||||
|
||||
// ByStatusOrder implements sort.Interface for []Status based on the Order field.
|
||||
type ByStatusOrder []Status
|
||||
// ByStatusPosition implements sort.Interface for []Status based on the status' position on the Kanban board.
|
||||
type ByStatusPosition []Status
|
||||
|
||||
func (s ByStatusOrder) Len() int {
|
||||
func (s ByStatusPosition) Len() int {
|
||||
return len(s)
|
||||
}
|
||||
|
||||
func (s ByStatusOrder) Swap(i, j int) {
|
||||
func (s ByStatusPosition) 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
|
||||
func (s ByStatusPosition) Less(i, j int) bool {
|
||||
return s[i].Position < s[j].Position
|
||||
}
|
||||
|
||||
// defaultStatusList returns the default list of statuses.
|
||||
|
@ -100,19 +100,19 @@ func defaultStatusList() []Status {
|
|||
{
|
||||
ID: -1,
|
||||
Name: "To Do",
|
||||
Order: 1,
|
||||
Position: 1,
|
||||
CardIds: nil,
|
||||
},
|
||||
{
|
||||
ID: -1,
|
||||
Name: "Doing",
|
||||
Order: 2,
|
||||
Position: 2,
|
||||
CardIds: nil,
|
||||
},
|
||||
{
|
||||
ID: -1,
|
||||
Name: "Done",
|
||||
Order: 3,
|
||||
Position: 3,
|
||||
CardIds: nil,
|
||||
},
|
||||
}
|
||||
|
|
|
@ -106,7 +106,7 @@ func testUpdateStatus(kanban board.Board, statusID int, newName string) func(t *
|
|||
ID: statusID,
|
||||
Name: newName,
|
||||
CardIds: nil,
|
||||
Order: 2,
|
||||
Position: 2,
|
||||
}
|
||||
|
||||
if !reflect.DeepEqual(status, want) {
|
||||
|
|
|
@ -84,25 +84,25 @@ func testWriteStatusList(t *testing.T, database *bolt.DB) {
|
|||
ID: -1,
|
||||
Name: "Backlog",
|
||||
CardIds: []int{1, 14, 9, 10},
|
||||
Order: 1,
|
||||
Position: 1,
|
||||
},
|
||||
{
|
||||
ID: -1,
|
||||
Name: "Next",
|
||||
CardIds: []int{2, 5, 12},
|
||||
Order: 2,
|
||||
Position: 2,
|
||||
},
|
||||
{
|
||||
ID: -1,
|
||||
Name: "In progress",
|
||||
CardIds: []int{3, 14},
|
||||
Order: 3,
|
||||
Position: 3,
|
||||
},
|
||||
{
|
||||
ID: -1,
|
||||
Name: "Finished!",
|
||||
CardIds: []int{4, 6, 7, 8, 11, 13},
|
||||
Order: 4,
|
||||
Position: 4,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -146,25 +146,25 @@ func testReadStatusList(t *testing.T, database *bolt.DB) {
|
|||
ID: 1,
|
||||
Name: "Backlog",
|
||||
CardIds: []int{1, 14, 9, 10},
|
||||
Order: 1,
|
||||
Position: 1,
|
||||
},
|
||||
{
|
||||
ID: 2,
|
||||
Name: "Next",
|
||||
CardIds: []int{2, 5, 12},
|
||||
Order: 2,
|
||||
Position: 2,
|
||||
},
|
||||
{
|
||||
ID: 3,
|
||||
Name: "In progress",
|
||||
CardIds: []int{3, 14},
|
||||
Order: 3,
|
||||
Position: 3,
|
||||
},
|
||||
{
|
||||
ID: 4,
|
||||
Name: "Finished!",
|
||||
CardIds: []int{4, 6, 7, 8, 11, 13},
|
||||
Order: 4,
|
||||
Position: 4,
|
||||
},
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue