Bug 30726 - Flatpickr's "yesterday" shortcut doesn't work if entry is limited to past dates
Summary: Flatpickr's "yesterday" shortcut doesn't work if entry is limited to past dates
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: Main
Hardware: All All
: P5 - low minor (vote)
Assignee: Owen Leonard
QA Contact: Katrin Fischer
URL:
Keywords:
Depends on: 29478
Blocks:
  Show dependency treegraph
 
Reported: 2022-05-10 14:57 UTC by Owen Leonard
Modified: 2023-06-08 22:26 UTC (History)
4 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.01, 21.11.07


Attachments
Bug 30726: Fix "yesterday" when limited to past dates (1.24 KB, patch)
2022-06-01 12:38 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 30726: Fix "yesterday" when limited to past dates (1.30 KB, patch)
2022-06-01 14:53 UTC, Lucas Gass
Details | Diff | Splinter Review
Bug 30726: Fix "yesterday" when limited to past dates (1.35 KB, patch)
2022-06-06 11:29 UTC, Katrin Fischer
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Owen Leonard 2022-05-10 14:57:44 UTC
If you configure a Flatpickr instance with the "pastdate" option (See the "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl), the "Yesterday" shortcut doesn't work. It should automatically select the previous day's date and populate the form field.
Comment 1 Jonathan Druart 2022-05-12 09:50:18 UTC
I think this is the correct fix:

diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
index 1e17eccd573..5b433881377 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc
@@ -152,7 +152,7 @@
                 disable_buttons.push(2); /* Tomorrow */
             }
             if( $(this).data("flatpickr-pastdate") === true ) {
-                options['maxDate'] = new Date().fp_incr(-1);
+                options['maxDate'] = new Date().fp_incr(-1).setHours(23, 59, 00, 00);
                 disable_buttons.push(1); /* Today */
                 disable_buttons.push(2); /* Tomorrow */
             }
Comment 2 Jonathan Druart 2022-06-01 12:38:23 UTC
Created attachment 135540 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field
Comment 3 Lucas Gass 2022-06-01 14:53:08 UTC
Created attachment 135552 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 4 Katrin Fischer 2022-06-06 11:29:45 UTC
Created attachment 135723 [details] [review]
Bug 30726: Fix "yesterday" when limited to past dates

Test plan:
Go to "Patrons with no checkouts" report, /cgi-bin/koha/reports/borrowers_out.pl
Select "Yesterday"
=> it automatically selects the previous day's date and populates the form field

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Comment 5 Tomás Cohen Arazi 2022-06-06 14:57:22 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 6 Lucas Gass 2022-06-17 20:15:19 UTC
Pushed to 22.05.x for 22.05.01
Comment 7 Arthur Suzuki 2022-06-21 14:03:49 UTC
thx! pushed to 21.11.x for 21.11.07
Comment 8 Victor Grousset/tuxayo 2022-06-26 00:14:47 UTC
Missing dependencies for 21.05.x, it shouldn't be affected, no backport.
Nothing to document, marking resolved.