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> Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
parent
e203730002
commit
44ddbf8ec7
1 changed files with 12 additions and 7 deletions
|
@ -31,12 +31,6 @@
|
||||||
},
|
},
|
||||||
onReady: function( selectedDates, dateStr, instance ){
|
onReady: function( selectedDates, dateStr, instance ){
|
||||||
/* When flatpickr instance is created, automatically append a "clear date" link */
|
/* 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)
|
$(instance.input)
|
||||||
/* Add a wrapper element so that we can prevent the clear button from wrapping */
|
/* Add a wrapper element so that we can prevent the clear button from wrapping */
|
||||||
.wrap("<span class='flatpickr_wrapper'></span>")
|
.wrap("<span class='flatpickr_wrapper'></span>")
|
||||||
|
@ -67,7 +61,18 @@
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
$(document).ready(function(){
|
$(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>
|
</script>
|
||||||
[% END %]
|
[% END %]
|
||||||
|
|
Loading…
Reference in a new issue