feat: delete cards #6

Closed
dananglin wants to merge 35 commits from delete-cards into main
4 changed files with 64 additions and 64 deletions
Showing only changes of commit 3169d341d2 - Show all commits

View file

@ -84,7 +84,7 @@ func (b *Board) StatusList() ([]Status, error) {
statuses[ind] = status statuses[ind] = status
} }
sort.Sort(ByStatusOrder(statuses)) sort.Sort(ByStatusPosition(statuses))
return statuses, nil return statuses, nil
} }
@ -119,7 +119,7 @@ func (b *Board) CreateStatus(args StatusArgs) error {
status := Status{ status := Status{
ID: -1, ID: -1,
Name: args.Name, Name: args.Name,
Order: args.Order, Position: args.Order,
CardIds: nil, CardIds: nil,
} }
@ -147,7 +147,7 @@ func (b *Board) UpdateStatus(args UpdateStatusArgs) error {
} }
if args.Order > 0 { if args.Order > 0 {
status.Order = args.Order status.Position = args.Order
} }
if _, err := db.Write(b.db, db.StatusBucket, &status); err != nil { if _, err := db.Write(b.db, db.StatusBucket, &status); err != nil {

View file

@ -9,7 +9,7 @@ type Status struct {
ID int ID int
Name string Name string
CardIds []int CardIds []int
Order int Position int
} }
// UpdateID updates the ID of the Status value. // 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:]...) s.CardIds = append(s.CardIds[:ind], s.CardIds[ind+1:]...)
} }
// ByStatusOrder implements sort.Interface for []Status based on the Order field. // ByStatusPosition implements sort.Interface for []Status based on the status' position on the Kanban board.
type ByStatusOrder []Status type ByStatusPosition []Status
func (s ByStatusOrder) Len() int { func (s ByStatusPosition) Len() int {
return len(s) 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] s[i], s[j] = s[j], s[i]
} }
func (s ByStatusOrder) Less(i, j int) bool { func (s ByStatusPosition) Less(i, j int) bool {
return s[i].Order < s[j].Order return s[i].Position < s[j].Position
} }
// defaultStatusList returns the default list of statuses. // defaultStatusList returns the default list of statuses.
@ -100,19 +100,19 @@ func defaultStatusList() []Status {
{ {
ID: -1, ID: -1,
Name: "To Do", Name: "To Do",
Order: 1, Position: 1,
CardIds: nil, CardIds: nil,
}, },
{ {
ID: -1, ID: -1,
Name: "Doing", Name: "Doing",
Order: 2, Position: 2,
CardIds: nil, CardIds: nil,
}, },
{ {
ID: -1, ID: -1,
Name: "Done", Name: "Done",
Order: 3, Position: 3,
CardIds: nil, CardIds: nil,
}, },
} }

View file

@ -106,7 +106,7 @@ func testUpdateStatus(kanban board.Board, statusID int, newName string) func(t *
ID: statusID, ID: statusID,
Name: newName, Name: newName,
CardIds: nil, CardIds: nil,
Order: 2, Position: 2,
} }
if !reflect.DeepEqual(status, want) { if !reflect.DeepEqual(status, want) {

View file

@ -84,25 +84,25 @@ func testWriteStatusList(t *testing.T, database *bolt.DB) {
ID: -1, ID: -1,
Name: "Backlog", Name: "Backlog",
CardIds: []int{1, 14, 9, 10}, CardIds: []int{1, 14, 9, 10},
Order: 1, Position: 1,
}, },
{ {
ID: -1, ID: -1,
Name: "Next", Name: "Next",
CardIds: []int{2, 5, 12}, CardIds: []int{2, 5, 12},
Order: 2, Position: 2,
}, },
{ {
ID: -1, ID: -1,
Name: "In progress", Name: "In progress",
CardIds: []int{3, 14}, CardIds: []int{3, 14},
Order: 3, Position: 3,
}, },
{ {
ID: -1, ID: -1,
Name: "Finished!", Name: "Finished!",
CardIds: []int{4, 6, 7, 8, 11, 13}, 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, ID: 1,
Name: "Backlog", Name: "Backlog",
CardIds: []int{1, 14, 9, 10}, CardIds: []int{1, 14, 9, 10},
Order: 1, Position: 1,
}, },
{ {
ID: 2, ID: 2,
Name: "Next", Name: "Next",
CardIds: []int{2, 5, 12}, CardIds: []int{2, 5, 12},
Order: 2, Position: 2,
}, },
{ {
ID: 3, ID: 3,
Name: "In progress", Name: "In progress",
CardIds: []int{3, 14}, CardIds: []int{3, 14},
Order: 3, Position: 3,
}, },
{ {
ID: 4, ID: 4,
Name: "Finished!", Name: "Finished!",
CardIds: []int{4, 6, 7, 8, 11, 13}, CardIds: []int{4, 6, 7, 8, 11, 13},
Order: 4, Position: 4,
}, },
} }