Bug 28942

Summary: Use Flatpickr on acquisitions pages
Product: Koha Reporter: Owen Leonard <oleonard>
Component: TemplatesAssignee: Owen Leonard <oleonard>
Status: CLOSED FIXED QA Contact: Testopia <testopia>
Severity: enhancement    
Priority: P5 - low CC: jonathan.druart, kyle, lucas, martin.renvoize
Version: master   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: Small patch
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
21.11.00
Bug Depends on: 28937    
Bug Blocks: 29239    
Attachments: Bug 28942: Use Flatpickr on acquisitions pages
Bug 28942: Use Flatpickr on acquisitions pages
Bug 28942: Use Flatpickr on acquisitions pages

Description Owen Leonard 2021-09-02 14:15:36 UTC
This bug will cover Flatpickr additions to these pages/files:

- includes/filter-orders.inc
- acqui/invoice.tt
- acqui/invoices.tt
- acqui/lateorders.tt
- acqui/orderreceive.tt
- acqui/parcels.tt
Comment 1 Owen Leonard 2021-09-03 11:22:15 UTC Comment hidden (obsolete)
Comment 2 Lucas Gass 2021-09-13 21:57:07 UTC Comment hidden (obsolete)
Comment 3 Martin Renvoize 2021-09-30 12:48:11 UTC
Created attachment 125493 [details] [review]
Bug 28942: Use Flatpickr on acquisitions pages

This patch modifies several acquisitions pages replacing jQuery
datepickers with Flatpickr widgets.

To test, apply the patch and test datepickers on the following
Acquisitions pages:

 - Acquisitions -> Late orders (linked date fields in the sidebar)
 - Acquisitions -> Invoices (linked date fields in the sidebar)
 - Acquisitions -> Invoices -> Invoice details (shipment date and
   billing date)
 - Acquisitions -> Vendor -> Receive shipment (shipment date)
 - Acquisitions -> Vendor -> Receive shipment -> Receive (on order line)
   -> Date received field under "Accounting details
 - Acquisitions -> Orders search tab in the header -> Advanced search:
   Linked date fields in the search form."

Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize 2021-09-30 12:48:51 UTC
Great to see all these updates..

PQA
Comment 5 Jonathan Druart 2021-10-04 13:37:34 UTC
Question (not related only to this patch, but other flatpickr ones as well):
Why don't you set the flatpickrto class when needed?

For instance:

+            var billingdatefrom = $("#billingdatefrom").flatpickr({
+                onClose: function( selectedDates, dateText, instance) {
+                    validate_date( selectedDates, instance );
+                    billingdateto.set('minDate', selectedDates[0]);
+                }
+            });
+            var billingdateto = $("#billingdateto").flatpickr({
+                onClose: function( selectedDates, dateText, instance) {
+                    validate_date( selectedDates, instance );
+                },
+            });

You need billingdatefrom, but you could use .flatpickrto for #billintdateto.

Also I think we could improve it a bit more, .flatpickrfrom could have a data containing the name of its "to".

We could only have:

  <input type="text" size="10" id="from" name="date_from" value="" class="flatpickrfrom" data-date_to="to" />

  <input type="text" size="10" id="to" name="date_to" value="" class="flatpickrto" />

And a couple of line in calendar.inc to link them.

I won't ofc block this patch series for that, but it would be great to have a follow-up bug on top to clean it.
Comment 6 Jonathan Druart 2021-10-06 08:37:48 UTC
Pushed to master for 21.11, thanks to everybody involved!