Skip to content

Commit

Permalink
Colored the cards to move
Browse files Browse the repository at this point in the history
  • Loading branch information
shuntaka9576 committed May 23, 2020
1 parent 99866c5 commit 4a48f59
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 10 additions & 4 deletions internal/kanban/ui/column.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,20 @@ func (c *Column) setKeyBindings(tui *Tui) {
row, _ := tui.view.columns.columns[tui.pos.focusCol].GetSelection()
cardId := tui.view.columns.columns[tui.pos.focusCol].cards[row].Id
ctx := context.Background()
tui.ghpjSettings.V3Client.Projects.MoveProjectCard(ctx, cardId, &github.ProjectCardMoveOptions{Position: "top", ColumnID: tui.view.columns.columns[tui.getRightPos()].Id})
go api.ProjectWithContext(ctx, tui.ghpjSettings.Client, tui.ghpjSettings.Repository, tui.ghpjSettings.SearchString, tui.notice.ghpjChan)
tui.view.columns.columns[tui.pos.focusCol].cards[row].SetTextColor(tcell.ColorOrange)
go func() {
tui.ghpjSettings.V3Client.Projects.MoveProjectCard(ctx, cardId, &github.ProjectCardMoveOptions{Position: "top", ColumnID: tui.view.columns.columns[tui.getRightPos()].Id})
tui.notice.columUpdateDoneChan <- struct{}{}
}()
case 'b':
row, _ := tui.view.columns.columns[tui.pos.focusCol].GetSelection()
cardId := tui.view.columns.columns[tui.pos.focusCol].cards[row].Id
ctx := context.Background()
tui.ghpjSettings.V3Client.Projects.MoveProjectCard(ctx, cardId, &github.ProjectCardMoveOptions{Position: "top", ColumnID: tui.view.columns.columns[tui.getLeftPos()].Id})
go api.ProjectWithContext(ctx, tui.ghpjSettings.Client, tui.ghpjSettings.Repository, tui.ghpjSettings.SearchString, tui.notice.ghpjChan)
tui.view.columns.columns[tui.pos.focusCol].cards[row].SetTextColor(tcell.ColorOrange)
go func() {
tui.ghpjSettings.V3Client.Projects.MoveProjectCard(ctx, cardId, &github.ProjectCardMoveOptions{Position: "top", ColumnID: tui.view.columns.columns[tui.getLeftPos()].Id})
tui.notice.columUpdateDoneChan <- struct{}{}
}()
}

return event
Expand Down
9 changes: 7 additions & 2 deletions internal/kanban/ui/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@ type GhpjSettings struct {
}

type Notciation struct {
ghpjChan chan *api.GithubProject
ghpjChan chan *api.GithubProject
columUpdateDoneChan chan struct{}
}

type View struct {
Expand All @@ -50,12 +51,14 @@ func NewTui(g *GhpjSettings) *Tui {
return false
})
ghpjChan := make(chan *api.GithubProject)
columUpdateDoneChan := make(chan struct{})

return &Tui{
App: app,
ghpjSettings: g,
notice: &Notciation{
ghpjChan: ghpjChan,
ghpjChan: ghpjChan,
columUpdateDoneChan: columUpdateDoneChan,
},
pos: &Pos{},
view: &View{},
Expand All @@ -73,6 +76,8 @@ func (tui *Tui) Run(ctx context.Context) {
fmt.Printf("err!\n")
case ghpj := <-tui.notice.ghpjChan:
tui.display(ghpj)
case <-tui.notice.columUpdateDoneChan:
go api.ProjectWithContext(ctx, tui.ghpjSettings.Client, tui.ghpjSettings.Repository, tui.ghpjSettings.SearchString, tui.notice.ghpjChan)
}
}
}()
Expand Down

0 comments on commit 4a48f59

Please sign in to comment.