Bug 29394 - Remove flatpickr instantiations from .tt files
Summary: Remove flatpickr instantiations from .tt files
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Templates (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Testopia
URL:
Keywords:
Depends on: 29270 29477
Blocks: 29239 29500 29735
  Show dependency treegraph
 
Reported: 2021-11-02 15:17 UTC by Jonathan Druart
Modified: 2022-06-06 20:31 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: ---
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00


Attachments
Bug 29394: Remove flatpickr instantiations from most of the tt files (18.58 KB, patch)
2021-11-16 09:56 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: (follow-up) Pass correct time format and other corrections (4.76 KB, patch)
2021-11-16 16:50 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29394: (follow-up) Pass correct time format and other corrections (6.72 KB, patch)
2021-11-16 17:01 UTC, Owen Leonard
Details | Diff | Splinter Review
Bug 29394: adjust request.tt (1.17 KB, patch)
2021-11-17 08:21 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: Remove futuredate for renew (1.47 KB, patch)
2021-11-17 10:31 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: Remove flatpickr instantiations from most of the tt files (18.54 KB, patch)
2021-11-17 10:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: (follow-up) Pass correct time format and other corrections (6.73 KB, patch)
2021-11-17 10:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: adjust request.tt (1.17 KB, patch)
2021-11-17 10:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: Remove futuredate for renew (1.47 KB, patch)
2021-11-17 10:51 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 29394: Remove flatpickr instantiations from most of the tt files (18.58 KB, patch)
2021-11-17 10:59 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 29394: (follow-up) Pass correct time format and other corrections (6.79 KB, patch)
2021-11-17 10:59 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 29394: adjust request.tt (1.23 KB, patch)
2021-11-17 10:59 UTC, Martin Renvoize
Details | Diff | Splinter Review
Bug 29394: Remove futuredate for renew (1.53 KB, patch)
2021-11-17 10:59 UTC, Martin Renvoize
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2021-11-02 15:17:01 UTC
The instantiation must be done by the JS from calendar.inc, based on the classes of the inputs.
Comment 1 Jonathan Druart 2021-11-16 09:56:51 UTC
Created attachment 127683 [details] [review]
Bug 29394: Remove flatpickr instantiations from most of the tt files

We must reduce the instantiations as much as possible to take advantages
of the default values and specific behaviours we have defined in
calendar.inc

This patch is suggesting to have a .flatpickr class and using the data
attributes:
- flatpickr-futuredate
- flatpickr-pastdate
- flatpickr-enable-time
- flatpickr-on-close-focus
Comment 2 Jonathan Druart 2021-11-16 09:57:55 UTC
Owen, Martin, this is what I had in mind. Do you agree with the idea?
Comment 3 Owen Leonard 2021-11-16 16:50:29 UTC Comment hidden (obsolete)
Comment 4 Owen Leonard 2021-11-16 17:01:20 UTC
Created attachment 127700 [details] [review]
Bug 29394: (follow-up) Pass correct time format and other corrections

This patch makes a few corrections, including adding the
correct Flatpickr date format option when the timepicker is enabled.

Besides past and future date options, I've added a "pastinclusive"
option which allows dates in the past OR today. This option was
previously applied to the checkin page.

The patch also corrects a couple of places where the wrong date field
was modified with the new data attributes.

To test, apply the patch and test the datepickers on the batch checkout
and renew pages. When you select a date and time the "TimeFormat" system
preference should be correctly applied.

The calendar widget on the checkin page should allow you to select
today's date.
Comment 5 Owen Leonard 2021-11-16 17:02:51 UTC
One problem I wasn't able to understand: If you configure an input with the "pastdate" or "pastinclusive" option AND enable the time picker the defaultHour and defaultMinute options are lost.
Comment 6 Jonathan Druart 2021-11-17 08:21:38 UTC
Created attachment 127707 [details] [review]
Bug 29394: adjust request.tt
Comment 7 Jonathan Druart 2021-11-17 08:47:26 UTC
                                 <div><label for="hard_due_date" class="hint">Renewal due date [% INCLUDE 'date-format.inc' %]:</label></div>
-                                <input type="text" size="20" id="hard_due_date" name="hard_due_date" value="[% hard_due_date | $KohaDates with_hours => 1 %]" />
+                                <input type="text" size="20" id="hard_due_date" name="hard_due_date" value="[% hard_due_date | $KohaDates with_hours => 1 %]" class="flatpickr" data-flatpickr-futuredate="true" data-flatpickr-enable-time="true" />

I think this is wrong, before this patchset we didn't have a "future" restriction on the renewal due date.
Comment 8 Jonathan Druart 2021-11-17 10:31:11 UTC
Created attachment 127715 [details] [review]
Bug 29394: Remove futuredate for renew
Comment 9 Jonathan Druart 2021-11-17 10:48:05 UTC
(In reply to Owen Leonard from comment #5)
> One problem I wasn't able to understand: If you configure an input with the
> "pastdate" or "pastinclusive" option AND enable the time picker the
> defaultHour and defaultMinute options are lost.

I think that's because because TODAY 23:59 is in the future :-/
Comment 10 Jonathan Druart 2021-11-17 10:51:26 UTC
Created attachment 127716 [details] [review]
Bug 29394: Remove flatpickr instantiations from most of the tt files

We must reduce the instantiations as much as possible to take advantages
of the default values and specific behaviours we have defined in
calendar.inc

This patch is suggesting to have a .flatpickr class and using the data
attributes:
- flatpickr-futuredate
- flatpickr-pastdate
- flatpickr-enable-time
- flatpickr-on-close-focus
Comment 11 Jonathan Druart 2021-11-17 10:51:30 UTC
Created attachment 127717 [details] [review]
Bug 29394: (follow-up) Pass correct time format and other corrections

This patch makes a few corrections, including adding the
correct Flatpickr date format option when the timepicker is enabled.

Besides past and future date options, I've added a "pastinclusive"
option which allows dates in the past OR today. This option was
previously applied to the checkin page.

The patch also corrects a couple of places where the wrong date field
was modified with the new data attributes.

To test, apply the patch and test the datepickers on the batch checkout
and renew pages. When you select a date and time the "TimeFormat" system
preference should be correctly applied.

The calendar widget on the checkin page should allow you to select
today's date.
Comment 12 Jonathan Druart 2021-11-17 10:51:34 UTC
Created attachment 127718 [details] [review]
Bug 29394: adjust request.tt
Comment 13 Jonathan Druart 2021-11-17 10:51:38 UTC
Created attachment 127719 [details] [review]
Bug 29394: Remove futuredate for renew
Comment 14 Martin Renvoize 2021-11-17 10:59:33 UTC
Created attachment 127723 [details] [review]
Bug 29394: Remove flatpickr instantiations from most of the tt files

We must reduce the instantiations as much as possible to take advantages
of the default values and specific behaviours we have defined in
calendar.inc

This patch is suggesting to have a .flatpickr class and using the data
attributes:
- flatpickr-futuredate
- flatpickr-pastdate
- flatpickr-enable-time
- flatpickr-on-close-focus

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 15 Martin Renvoize 2021-11-17 10:59:37 UTC
Created attachment 127724 [details] [review]
Bug 29394: (follow-up) Pass correct time format and other corrections

This patch makes a few corrections, including adding the
correct Flatpickr date format option when the timepicker is enabled.

Besides past and future date options, I've added a "pastinclusive"
option which allows dates in the past OR today. This option was
previously applied to the checkin page.

The patch also corrects a couple of places where the wrong date field
was modified with the new data attributes.

To test, apply the patch and test the datepickers on the batch checkout
and renew pages. When you select a date and time the "TimeFormat" system
preference should be correctly applied.

The calendar widget on the checkin page should allow you to select
today's date.

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 16 Martin Renvoize 2021-11-17 10:59:40 UTC
Created attachment 127725 [details] [review]
Bug 29394: adjust request.tt

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 17 Martin Renvoize 2021-11-17 10:59:44 UTC
Created attachment 127726 [details] [review]
Bug 29394: Remove futuredate for renew

Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 18 David Nind 2021-11-19 18:39:30 UTC
It looks to me as though Martin has signed this off - have changed the status. Feel free to change back and I will test.
Comment 19 Katrin Fischer 2021-11-19 19:13:00 UTC
Also needs to be a 21.11 candidate because of dependencies.
Comment 20 Martin Renvoize 2021-11-22 10:43:09 UTC
(In reply to David Nind from comment #18)
> It looks to me as though Martin has signed this off - have changed the
> status. Feel free to change back and I will test.

Thanks David, you're right.. I had just forgotten to change the state.
Comment 21 Jonathan Druart 2021-11-22 10:49:33 UTC
Skipping QA, we need it pushed ASAP
Comment 22 Jonathan Druart 2021-11-22 11:14:58 UTC
Pushed to master for 21.11, thanks to everybody involved!