Bugzilla – Attachment 127723 Details for
Bug 29394
Remove flatpickr instantiations from .tt files
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29394: Remove flatpickr instantiations from most of the tt files
Bug-29394-Remove-flatpickr-instantiations-from-mos.patch (text/plain), 18.58 KB, created by
Martin Renvoize (ashimema)
on 2021-11-17 10:59:33 UTC
(
hide
)
Description:
Bug 29394: Remove flatpickr instantiations from most of the tt files
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-17 10:59:33 UTC
Size:
18.58 KB
patch
obsolete
>From b70bf71ab71b9e4591d9c17da4bba180e96ab0ee Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 16 Nov 2021 10:54:10 +0100 >Subject: [PATCH] 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> >--- > .../prog/en/includes/borrower_debarments.inc | 2 +- > .../prog/en/includes/calendar.inc | 13 ++++++++-- > .../prog/en/includes/holds_table.inc | 4 +-- > .../prog/en/modules/circ/circulation.tt | 2 +- > .../circ/circulation_batch_checkouts.tt | 14 ++++------- > .../prog/en/modules/circ/renew.tt | 25 ++++++------------- > .../prog/en/modules/circ/returns.tt | 11 +------- > .../prog/en/modules/ill/ill-requests.tt | 7 +----- > .../prog/en/modules/members/moremember.tt | 2 +- > .../prog/en/modules/reports/borrowers_out.tt | 2 +- > .../prog/en/modules/reserve/request.tt | 9 +------ > .../prog/en/modules/tools/scheduler.tt | 2 +- > 12 files changed, 33 insertions(+), 60 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc >index b1aa6d1f61..bd224f6a73 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/borrower_debarments.inc >@@ -62,7 +62,7 @@ > <li><label for="rcomment">Comment:</label> <input type="text" id="rcomment" name="comment" /></li> > <li> > <label for="rexpiration">Expiration:</label> >- <input name="expiration" id="rexpiration" size="20" value="" class="flatpickr futuredate" type="text" /> >+ <input name="expiration" id="rexpiration" size="20" value="" class="flatpickr" data-flatpickr-futuredate="true" type="text" /> > </li> > </ol> > <fieldset class="action"><input type="submit" value="Add restriction" /> <a href="#" class="cancel" id="cancel_manual_restriction">Cancel</a></fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 117dbd9960..f67bffe313 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -78,19 +78,28 @@ > var endPicker = document.querySelector("#"+thisInput.dataset.date_to)._flatpickr; > endPicker.set('minDate', selectedDates[0]); > } >+ >+ let = on_close_focus = $(thisInput).data('flatpickr-on-close-focus'); >+ if ( on_close_focus ) { >+ $(on_close_focus).focus(); >+ } > }, > }); > $(document).ready(function(){ > $(".flatpickr").each(function(){ > let options = {}; > >- if( $(this).hasClass("futuredate") ) { >+ if( $(this).data("flatpickr-futuredate") === true ) { > options['minDate'] = new Date().fp_incr(1); > options['allowInvalidPreload'] = true; > } >- if( $(this).hasClass("pastdate") ) { >+ if( $(this).data("flatpickr-pastdate") === true ) { > options['maxDate'] = new Date().fp_incr(-1); > } >+ if ( $(this).data('flatpickr-enable-time') === true ) { >+ options['enableTime'] = true; >+ } >+ > $(this).flatpickr(options); > }); > }); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >index dfddd9c75c..99a6bef496 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/holds_table.inc >@@ -114,7 +114,7 @@ > [% END %] > </td> > <td> >- <input type="text" class="flatpickr futuredate" value="[% hold.expirationdate | $KohaDates %]" size="10" name="expirationdate" /> >+ <input type="text" class="flatpickr" data-flatpickr-futuredate="true" value="[% hold.expirationdate | $KohaDates %]" size="10" name="expirationdate" /> > </td> > <td> > [%- IF ( hold.found ) -%] >@@ -211,7 +211,7 @@ > > [% IF Koha.Preference('AutoResumeSuspendedHolds') %] > <label for="suspend_until_[% hold.reserve_id | html %]">[% IF ( hold.suspend ) %] on [% ELSE %] until [% END %]</label> >- <input type="text" name="suspend_until_[% hold.reserve_id | html %]" id="suspend_until_[% hold.reserve_id | html %]" size="10" value="[% hold.suspend_until | $KohaDates %]" class="suspend_until_datepicker" /> >+ <input type="text" name="suspend_until_[% hold.reserve_id | html %]" id="suspend_until_[% hold.reserve_id | html %]" size="10" value="[% hold.suspend_until | $KohaDates %]" class="flatpickr" data-flatpickr-futuredate="true" /> > [%- ELSE -%] > <input type="hidden" name="suspend_until_[% hold.reserve_id | html %]" id="suspend_until_[% hold.reserve_id | html %]" value=""/> > [%- END -%] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index bc8a32e631..1196a16425 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -875,7 +875,7 @@ > > [% IF Koha.Preference('AutoResumeSuspendedHolds') %] > <label for="suspend_until">until</label> >- <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr futuredate"/> >+ <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr" data-flatpickr-futuredate="true" /> > <span class="hint">Specify date on which to resume [% INCLUDE 'date-format.inc' %]: </span> > [% END %] > </form> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt >index 41679237bc..dc584eabdc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation_batch_checkouts.tt >@@ -112,7 +112,11 @@ > <fieldset class="rows"> > <legend>Due date: </legend> > <label for="duedatespec">Hard due date [% INCLUDE 'date-format.inc' %]:</label> >- <input type="text" size="20" id="duedatespec" name="duedatespec" value="[% duedatespec | $KohaDates with_hours => 1 %]" /> >+ [% IF Koha.Preference('SpecifyDueDate') %] >+ <input type="text" size="20" id="duedatespec" name="duedatespec" value="[% duedatespec | $KohaDates with_hours => 1 %]" class="flatpickr" data-flatpickr-enable-time="true" /> >+ [% ELSE %] >+ <input type="text" size="20" id="duedatespec" name="duedatespec" value="[% duedatespec | $KohaDates with_hours => 1 %]" /> >+ [% END %] > </fieldset> > [% END %] > <input type="hidden" name="op" value="show" /> >@@ -357,14 +361,6 @@ > ], > "bPaginate": false > })); >- >- [% IF Koha.Preference('SpecifyDueDate') %] >- $("#duedatespec").flatpickr({ >- enableTime: true, >- dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string, >- defaultDate: new Date().setHours(23, 59, 0, 0) /* Today a 11:59PM */ >- }); >- [% END %] > }); > > </script> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >index e126144991..499c09bd27 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/renew.tt >@@ -147,7 +147,8 @@ > <input type="hidden" name="override_limit" value="1" /> > <input type="hidden" name="override_holds" value="1" /> > <div> >- <label for="renewonholdduedate">Renewal due date:</label> <input type="text" size="20" id="renewonholdduedate" name="renewonholdduedate" value="" /> >+ <label for="renewonholdduedate">Renewal due date:</label> >+ <input type="text" size="20" id="renewonholdduedate" name="renewonholdduedate" value="" class="flatpickr" data-flatpickr-futuredate="true" data-flatpickr-enable-time="true" /> > </div> > <button type="submit" class="approve"><i class="fa fa-check"></i> Override and renew</button> > </form> >@@ -170,7 +171,11 @@ > [% END %] > > <form method="get" action="/cgi-bin/koha/circ/renew.pl"> >- <input type="hidden" name="hard_due_date" value="[% hard_due_date | html %]" /> >+ [% IF Koha.Preference('SpecifyDueDate') %] >+ <input type="hidden" name="hard_due_date" value="[% hard_due_date | html %]" class="flatpickr flatpickr-enable-time" /> >+ [% ELSE %] >+ <input type="hidden" name="hard_due_date" value="[% hard_due_date | html %]" /> >+ [% END %] > <button type="submit" class="deny"><i class="fa fa-times"></i> Continue without renewing</button> > </form> > </div> >@@ -251,22 +256,6 @@ > }); > </script> > [% END %] >- <script> >- $( document ).ready(function() { >- var renewonholdduedate = $("#renewonholdduedate").flatpickr({ >- enableTime: true, >- dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string, >- minDate: new Date().fp_incr(1) >- }); >- >- [% IF Koha.Preference('SpecifyDueDate') %] >- var hard_due_date = $("#hard_due_date").flatpickr({ >- enableTime: true, >- dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string, >- }); >- [% END %] >- }); >- </script> > [% END %] > > [% INCLUDE 'intranet-bottom.inc' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index b3d8c04e59..c234bd64ca 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -808,7 +808,7 @@ > <div class="date-select" id="return_date_override_fields"> > <div class="hint">Specify return date [% INCLUDE 'date-format.inc' %]: </div> > >- <input type="text" size="20" class="pastdate" id="return_date_override" name="return_date_override" value="[% return_date_override | html %]" /> >+ <input type="text" size="20" id="return_date_override" name="return_date_override" value="[% return_date_override | html %]" class="flatpickr" data-flatpickr-pastdate="true" data-flatpickr-enable-time="true" data-flatpickr-on-close-focus="#barcode" /> > > <div class="circ-setting"> > [% IF ( return_date_override_remember ) %] >@@ -1038,15 +1038,6 @@ > "dom": 'B<"clearfix">t', > }, columns_settings); > >- $("#return_date_override").flatpickr({ >- enableTime: true, >- dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string, >- maxDate: "today", >- onClose: function() { >- $("#barcode").focus(); >- } >- }); >- > $("#exemptcheck").change(function () { > if (this.checked == true) { > $("#barcode").addClass("input-warning"); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >index a5889a10e6..74545dc119 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt >@@ -248,7 +248,7 @@ > </li> > <li class="ill_checkout_due_date"> > <label for="duedate" class="ill_checkout_duedate_label">Due date:</label> >- <input name="duedate" id="ill_checkout_duedate_input" type="text" value="[% params.duedate | html %]"> [% INCLUDE 'date-format.inc' %] >+ <input name="duedate" id="ill_checkout_duedate_input" type="text" value="[% params.duedate | html %]" class="flatpickr" data-flatpickr-enable-time="true" /> [% INCLUDE 'date-format.inc' %] > <div class="hint">If you do not specify a due date, it will be set according to circulation rules</p> > </li> > </ol> >@@ -840,11 +840,6 @@ > // Set column settings > var columns_settings = [% TablesSettings.GetColumns( 'illrequests', 'ill-requests', 'ill-requests', 'json' ) %]; > >- $("#ill_checkout_duedate_input").flatpickr({ >- enableTime: true, >- dateFormat: flatpickr_dateformat_string + " " + flatpickr_timeformat_string, >- }); >- > [% IF services_json.length > 0 %] > var services = [% services_json | $raw %]; > [% ELSE %] >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index 91bc3db21f..8f7263b1dd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -812,7 +812,7 @@ > > [% IF Koha.Preference('AutoResumeSuspendedHolds') %] > <label for="suspend_until">until</label> >- <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr futuredate"/> >+ <input type="text" size="10" id="suspend_until" name="suspend_until" class="flatpickr" data-flatpickr-futuredate="true"/> > <span class="hint">Specify date on which to resume [% INCLUDE 'date-format.inc' %]: </span> > [% END %] > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt >index f32f1f3ba4..f3dba0031d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reports/borrowers_out.tt >@@ -68,7 +68,7 @@ > [% END %] > </select> > </li> >- <li><label for="to">Not checked out since: </label> <input size="10" id="to" class="flatpickr pastdate" name="Filter" value="" type="text" /> >+ <li><label for="to">Not checked out since: </label> <input size="10" id="to" class="flatpickr" data-flatpickr-pastdate="true" name="Filter" value="" type="text" /> > </li> > </ol> > </fieldset> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >index 59ff7e6e9f..3611e0864f 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/reserve/request.tt >@@ -518,7 +518,7 @@ > [% 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" data-date_to="expiration_date" class="flatpickr futuredate" /> >+ <input id="reserve_date" name="reserve_date" id="from" size="10" type="text" data-date_to="expiration_date" class="flatpickr" data-flatpickr-futuredate="true" /> > </li> > [% END %] > >@@ -1209,13 +1209,6 @@ > }); > [% END %] > >- [% IF AutoResumeSuspendedHolds %] >- $(".suspend_until_datepicker").flatpickr({ >- minDate: new Date().fp_incr(1) /* Require that "until date" be in the future */ >- }); >- [% END %] >- >- > var my_table = $("#requestspecific").dataTable($.extend(true, {}, dataTablesDefaults, { > 'bPaginate': false, > "sDom": '<"top pager"ilf>t', >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >index bf144309e2..2ffd7b0868 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tools/scheduler.tt >@@ -46,7 +46,7 @@ > <input type="text" name="starttime" id="starttime" value="" maxlength="5" size="5" /></li> > <li> > <label for="startdate">Date: </label> >- <input type="text" size="10" id="startdate" name="startdate" class="flatpickr futuredate" value="" /> >+ <input type="text" size="10" id="startdate" name="startdate" class="flatpickr" data-flatpickr-futuredate="true" value="" /> > <div class="hint">[% INCLUDE 'date-format.inc' %]</div> > </li> > <li><label for="report">Report:</label> >-- >2.20.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29394
:
127683
|
127699
|
127700
|
127707
|
127715
|
127716
|
127717
|
127718
|
127719
| 127723 |
127724
|
127725
|
127726