Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added shortcuts '+', '-' and 'o', underlining for those and 'e' #26

Merged

Conversation

sdrwtf
Copy link
Contributor

@sdrwtf sdrwtf commented Oct 6, 2021

Info

I've tested the changes on Ubuntu 20.04 without any issues but please be aware that this is the first time I do something in Go, so please double-check if the changes are alright 😉

PR fixes #20

Changes

Added shortcuts:

  • o for set due date to today
  • + for due date plus 1 day
  • - for due date minus 1 day

Marked shortcuts by underlining for the above and and e in edit.

Added new shortcuts to the README.

Comment on lines 331 to 338
case 'o':
td.setTaskDate(parseDateInputOrCurrent("").Unix(), true)
return nil
case '+':
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, 1).Unix(), true)
return nil
case '-':
td.setTaskDate(parseDateInputOrCurrent(td.taskDate.GetText()).AddDate(0, 0, -1).Unix(), true)
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a quick idea, can we reuse previously defined todaySelector(), prevDaySelector(), nextDaySelector() methods here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have no idea to be honest, my experience with Go pretty much non existent. But I guess it works, otherwise you probably wouldn't have suggested it 😉

I'll check out the tutorials and see if I can figure it out 🙂

Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe I can assist. You need to do a few changes:

  1. Remove todaySelector(), prevDaySelector(), nextDaySelector() functions from inside makeDateRow()

CleanShot 2021-10-06 at 23 41 19@2x

  1. Now, at the end of file, define them as methods of TaskDetailPane

CleanShot 2021-10-06 at 23 43 47@2x

  1. InmakeDateRow(), use these methods

CleanShot 2021-10-06 at 23 45 18@2x

  1. Use the same methods in shortcut switch-case

CleanShot 2021-10-06 at 23 45 48@2x

Then compile and test, hope it'll work. :)
The only thing we're achieving by these changes is - avoiding duplication of the same logic in several places.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok, got it, thanks for the explanation! I thought there might be some magic possibility to basically call function within functions in Go 😄

I've implemented the changes, build went well and buttons as well as the shortcuts work as expected, see commit 3af36bd.

@ajaxray ajaxray merged commit eaba237 into ajaxray:master Oct 7, 2021
@ajaxray
Copy link
Owner

ajaxray commented Oct 7, 2021

Hi @sdrwtf,

Merged with many many thanks 😊

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Shortcut improvement for Task Detail panel
2 participants