Bug 29270: Remove flatpickr instantiation from request.tt
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Fri, 15 Oct 2021 07:49:19 +0000 (09:49 +0200)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Mon, 25 Oct 2021 11:56:32 +0000 (13:56 +0200)
The JS code is only used when placing a hold for club BUT the date
inputs are not displayed there.

Test plan:
Place holds for patrons and clubs and confirm that the two date inputs
are working correctly

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt

index 8e9bf1f..a6d269f 100644 (file)
                             [% IF ( reserve_in_future ) %]
                                 <li>
                                     <label for="from">Hold starts on date:</label>
-                                    <input id="reserve_date" name="reserve_date" id="from" size="10" type="text" >
-                                    <input type="hidden" class="datepickerfrom_hidden" />
+                                    <input id="reserve_date" name="reserve_date" id="from" size="10" type="text" data-start_for="expiration_date" class="flatpickr futuredate" />
                                 </li>
                             [% END %]
 
                             <li>
                                 <label for="to">Hold expires on date:</label>
-                                <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" />
-                                <input type="hidden" class="datepickerto_hidden" />
+                                <input id="expiration_date" name="expiration_date" id="to" size="10" type="text" class="flatpickr" />
                             </li>
 
                             [% UNLESS ( multi_hold ) %]
             [% END %]
 
 
-            var startPicker = $("#reserve_date").flatpickr({
-                minDate: new Date().fp_incr(1), /* Require that "Hold starts on date" be in the future */
-                onChange: function(selectedDates, dateStr, instance) {
-                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
-                    $(".datepickerfrom_hidden").val( altFormat ); /* Populate hidden field with ISO-formatted date */
-                },
-                onClose: function( selectedDates, dateText, instance) {
-                    validate_date( selectedDates, instance );
-                    endPicker.set('minDate', selectedDates[0]);
-                }
-            });
-
-            var endPicker = $("#expiration_date").flatpickr({
-                minDate: new Date().fp_incr(1), // Require that "Hold expires on date" be in the future
-                onChange: function(selectedDates, dateStr, instance) {
-                    altFormat = instance.formatDate(selectedDates[0], "Y-m-d");
-                    $(".datepickerto_hidden").val( altFormat ); /* Populate hidden field with ISO-formatted date */
-                },
-                onClose: function( selectedDates, dateText, instance) {
-                    validate_date( selectedDates, instance );
-                },
-            });
-
             var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, {
                 'bPaginate': false,
                 "sDom": '<"top pager"ilf>t',
                     data.patron_id = $('input[name="borrowernumber"]').val();
                 if($('textarea[name="notes"]').length)
                     data.notes = $('textarea[name="notes"]').val()||null;
-                if($('.datepickerto_hidden').length)
-                    data.expiration_date = $('.datepickerto_hidden').val()||null;
-                if($('.datepickerfrom_hidden').length)
-                    data.hold_date = $('.datepickerfrom_hidden').val()||null;
                 if($('input[name="itemtype"]').length) {
                     data.item_type = $('input[name="itemtype"]').val()||null;
                 }