fix(ui): display status message when moving card
After moving cards from one status to another the status bar now shows either a confirmation or an error message depending on the success of the move.
This commit is contained in:
parent
eb2ed4060a
commit
43095b9932
3 changed files with 24 additions and 7 deletions
|
@ -48,7 +48,7 @@ func (c *cardView) setDoneFunc(handler func(key tcell.Key)) {
|
|||
c.SetDoneFunc(handler)
|
||||
}
|
||||
|
||||
func (c *cardView) print(id int, title, status, created, description string) {
|
||||
func (c *cardView) setText(id int, title, status, created, description string) {
|
||||
fmt.Fprintf(c, c.contentFormat, id, title, status, created, description)
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,10 @@
|
|||
package ui
|
||||
|
||||
import "codeflow.dananglin.me.uk/apollo/pelican/internal/board"
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
"codeflow.dananglin.me.uk/apollo/pelican/internal/board"
|
||||
)
|
||||
|
||||
type statusSelection struct {
|
||||
cardID int
|
||||
|
@ -8,13 +12,16 @@ type statusSelection struct {
|
|||
nextStatusID int
|
||||
}
|
||||
|
||||
func (s statusSelection) moveCard(kanban board.Board) {
|
||||
func (s statusSelection) moveCard(kanban board.Board) error {
|
||||
moveArgs := board.MoveToStatusArgs{
|
||||
CardID: s.cardID,
|
||||
CurrentStatusID: s.currentStatusID,
|
||||
NextStatusID: s.nextStatusID,
|
||||
}
|
||||
|
||||
// TODO: grab error for status line.
|
||||
_ = kanban.MoveToStatus(moveArgs)
|
||||
if err := kanban.MoveToStatus(moveArgs); err != nil {
|
||||
return fmt.Errorf("error moving card; %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
|
|
@ -187,13 +187,23 @@ func (u *UI) inputCapture() func(event *tcell.EventKey) *tcell.EventKey {
|
|||
}
|
||||
|
||||
status := u.focusedStatusName()
|
||||
u.view.print(card.ID, card.Title, status, card.Created, card.Description)
|
||||
u.view.setText(card.ID, card.Title, status, card.Created, card.Description)
|
||||
u.pages.ShowPage(viewPage)
|
||||
u.SetFocus(u.view)
|
||||
case selection:
|
||||
u.statusSelection.nextStatusID = u.focusedStatusID()
|
||||
if u.statusSelection.currentStatusID != u.statusSelection.nextStatusID {
|
||||
u.statusSelection.moveCard(u.board)
|
||||
if err := u.statusSelection.moveCard(u.board); err != nil {
|
||||
u.statusbar.displayMessage(
|
||||
errorLevel,
|
||||
fmt.Sprintf("Failed to move card: %v", err),
|
||||
)
|
||||
} else {
|
||||
u.statusbar.displayMessage(
|
||||
infoLevel,
|
||||
"Card moved successfully.",
|
||||
)
|
||||
}
|
||||
}
|
||||
|
||||
u.statusSelection = statusSelection{0, 0, 0}
|
||||
|
|
Loading…
Reference in a new issue