Skip to content

Commit

Permalink
qol improvements (#7)
Browse files Browse the repository at this point in the history
* calendar controls while focus on latest issues view

* set focus on 'Time spent' field while adding new worklog

* CHANGELOG
  • Loading branch information
jzyinq authored Mar 27, 2024
1 parent a3543e1 commit 49e76ff
Show file tree
Hide file tree
Showing 4 changed files with 30 additions and 24 deletions.
10 changes: 9 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),

## [Unreleased]

## [0.5.3] - 2024-03-27
### Fixed
- calendar controls not working while focus is on latest issues view

### Changed
- Set focus on time spent field while adding new worklog

## [0.5.2] - 2024-03-26
### Changed
- More detailed loader while adding worklogs in a batch
Expand Down Expand Up @@ -78,7 +85,8 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
### Added
- Initial release of gojira

[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.2...master
[Unreleased]: https://github.com/jzyinq/gojira/compare/0.5.3...master
[0.5.3]: https://github.com/jzyinq/gojira/compare/0.5.2...0.5.3
[0.5.2]: https://github.com/jzyinq/gojira/compare/0.5.1...0.5.2
[0.5.1]: https://github.com/jzyinq/gojira/compare/0.5.0...0.5.1
[0.5.0]: https://github.com/jzyinq/gojira/compare/0.4.0...0.5.0
Expand Down
17 changes: 17 additions & 0 deletions gojira/calendar.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
"github.com/sirupsen/logrus"
"time"
)

Expand Down Expand Up @@ -90,3 +91,19 @@ func (c *Calendar) update() {
t = t.AddDate(0, 0, 1)
}
}

func controlCalendar(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyLeft, tcell.KeyRight:
timePeriod := -time.Hour * 24
if event.Key() == tcell.KeyRight {
timePeriod = time.Hour * 24
}
newTime := app.time.Add(timePeriod)
logrus.Debug("Changing date to ", newTime)
app.time = &newTime
loadWorklogs()
app.ui.calendar.update()
}
return event
}
19 changes: 3 additions & 16 deletions gojira/dayview.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"fmt"
"github.com/gdamore/tcell/v2"
"github.com/rivo/tview"
"github.com/sirupsen/logrus"
"strings"
"time"
)
Expand Down Expand Up @@ -75,21 +74,8 @@ func NewDayView() *DayView { //nolint:funlen

app.ui.pages.AddPage("worklog-view", flexView, true, true)

dayView.worklogList.SetInputCapture(func(event *tcell.EventKey) *tcell.EventKey {
switch event.Key() {
case tcell.KeyLeft, tcell.KeyRight:
timePeriod := -time.Hour * 24
if event.Key() == tcell.KeyRight {
timePeriod = time.Hour * 24
}
newTime := app.time.Add(timePeriod)
logrus.Debug("Changing date to ", newTime)
app.time = &newTime
loadWorklogs()
app.ui.calendar.update()
}
return event
})
dayView.worklogList.SetInputCapture(controlCalendar)
dayView.latestIssuesList.SetInputCapture(controlCalendar)

dayView.loadLatest()

Expand Down Expand Up @@ -283,6 +269,7 @@ func NewAddWorklogForm(d *DayView, issues []Issue, row int) *tview.Form {
formWidth := 36
formHeight := 9
form.SetRect(pwidth/2-(formWidth/2), pheight/2-3, formWidth, formHeight)
form.SetFocus(1)
app.ui.pages.AddPage("worklog-form", form, false, true)
return form
}
Expand Down
8 changes: 1 addition & 7 deletions gojira/ui.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,13 @@ func newUi() {
app.ui.app = tview.NewApplication()
app.ui.pages = tview.NewPages()

// do I really need those declaration here
//FIXME do I really need those declaration here
app.ui.calendar = NewCalendar()
app.ui.summary = NewSummary()
app.ui.dayView = NewDayView()
app.ui.errorView = NewErrorView()
app.ui.loaderView = NewLoaderView()

//customModal := func(p tview.Primitive, width, height int) tview.Primitive {
// return tview.NewGrid().
// SetColumns(0, width, 0).
// SetRows(0, height, 0).
// AddItem(p, 1, 1, 1, 1, 0, 0, true)
//}
app.ui.grid = tview.NewGrid().
SetRows(1, 0, 0).
SetColumns(0, 0, 27).
Expand Down

0 comments on commit 49e76ff

Please sign in to comment.