From 49e76ffe29c2e9753adb530a154c5a6f686467d5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaros=C5=82aw=20Zywert?= Date: Wed, 27 Mar 2024 23:33:10 +0100 Subject: [PATCH] qol improvements (#7) * calendar controls while focus on latest issues view * set focus on 'Time spent' field while adding new worklog * CHANGELOG --- CHANGELOG.md | 10 +++++++++- gojira/calendar.go | 17 +++++++++++++++++ gojira/dayview.go | 19 +++---------------- gojira/ui.go | 8 +------- 4 files changed, 30 insertions(+), 24 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 365da84..a97983e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 @@ -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 diff --git a/gojira/calendar.go b/gojira/calendar.go index 1e35072..00c791b 100644 --- a/gojira/calendar.go +++ b/gojira/calendar.go @@ -4,6 +4,7 @@ import ( "fmt" "github.com/gdamore/tcell/v2" "github.com/rivo/tview" + "github.com/sirupsen/logrus" "time" ) @@ -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 +} diff --git a/gojira/dayview.go b/gojira/dayview.go index e1303f4..07c9a5a 100644 --- a/gojira/dayview.go +++ b/gojira/dayview.go @@ -5,7 +5,6 @@ import ( "fmt" "github.com/gdamore/tcell/v2" "github.com/rivo/tview" - "github.com/sirupsen/logrus" "strings" "time" ) @@ -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() @@ -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 } diff --git a/gojira/ui.go b/gojira/ui.go index 12277db..c801e8e 100644 --- a/gojira/ui.go +++ b/gojira/ui.go @@ -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).