Bugzilla – Attachment 126674 Details for
Bug 29241
Flatpickr not displaying date in the past for futuredate
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29241: Allow display of past date for .futuredate
Bug-29241-Allow-display-of-past-date-for-futuredat.patch (text/plain), 2.57 KB, created by
David Nind
on 2021-10-21 17:42:32 UTC
(
hide
)
Description:
Bug 29241: Allow display of past date for .futuredate
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-10-21 17:42:32 UTC
Size:
2.57 KB
patch
obsolete
>From 16ca0bab95b9f0ff3b4c49d78433b8b4eb5cbde6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 14 Oct 2021 11:36:02 +0200 >Subject: [PATCH] Bug 29241: Allow display of past date for .futuredate > >When a past date is set for a flatpickr instance with the .futuredate >class, only dates in the future are available AND the input is blanked. >It does not display the date in the past. > >For instance if a hold is expired (expirationdate in the past), the date input will be blanked. > >We can use the flatpickr's allowInvalidPreload option to allow date in the past to be displayed. > >Test plan: >Place a hold >Edit its expirationdate and set a date in the past (yesterday is fine) >Go to /reserve/request.pl?biblionumbers=42 >=> With the patch you see the date, and the widget let you chose anoter date, >in the future >=> Without this patch the expiration date is not displayed > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/includes/calendar.inc | 19 ++++++++++++------- > 1 file changed, 12 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 231d97d48a..bd8c9e7b86 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -31,12 +31,6 @@ > }, > onReady: function( selectedDates, dateStr, instance ){ > /* When flatpickr instance is created, automatically append a "clear date" link */ >- if( $(instance.input).hasClass("futuredate") ){ >- instance.set("minDate", new Date().fp_incr(1)); >- } >- if( $(instance.input).hasClass("pastdate") ){ >- instance.set("maxDate", new Date().fp_incr(-1)); >- } > $(instance.input) > /* Add a wrapper element so that we can prevent the clear button from wrapping */ > .wrap("<span class='flatpickr_wrapper'></span>") >@@ -67,7 +61,18 @@ > }, > }); > $(document).ready(function(){ >- $(".flatpickr").flatpickr(); >+ $(".flatpickr").each(function(){ >+ let options = {}; >+ >+ if( $(this).hasClass("futuredate") ) { >+ options['minDate'] = new Date().fp_incr(1); >+ options['allowInvalidPreload'] = true; >+ } >+ if( $(this).hasClass("pastdate") ) { >+ options['maxDate'] = new Date().fp_incr(-1); >+ } >+ $(this).flatpickr(options); >+ }); > }); > </script> > [% END %] >-- >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 29241
:
126260
|
126268
|
126473
|
126674
|
126795