Bugzilla – Attachment 127507 Details for
Bug 29450
Allow flatPickr to instantiate in any order
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29450: Allow flatpickr to instantiate in any order
Bug-29450-Allow-flatpickr-to-instantiate-in-any-or.patch (text/plain), 2.33 KB, created by
Martin Renvoize (ashimema)
on 2021-11-10 11:06:18 UTC
(
hide
)
Description:
Bug 29450: Allow flatpickr to instantiate in any order
Filename:
MIME Type:
Creator:
Martin Renvoize (ashimema)
Created:
2021-11-10 11:06:18 UTC
Size:
2.33 KB
patch
obsolete
>From f51371360a025f5a922ce318537914774b713cc2 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Thu, 4 Nov 2021 13:22:20 +0000 >Subject: [PATCH] Bug 29450: Allow flatpickr to instantiate in any order > >This patch updates the flatpickr wrapper code to allow for cases where >the startdate/enddate pickers are pre-populated and thus the onClose >event of the startdate pickr may be fired before the enddate flatpickr >is instantiated.. which leads to an error. >--- > .../prog/en/includes/calendar.inc | 19 ++++++++++++++----- > 1 file changed, 14 insertions(+), 5 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 6464b8a0f5..1636cf41dc 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -74,22 +74,31 @@ > var thisInput = instance.input; > if ( thisInput.hasAttribute('data-date_to') ) { > var endPicker = document.querySelector("#"+thisInput.dataset.date_to)._flatpickr; >+ if ( typeof endPicker === 'undefined' ) { >+ console.log("Found non-existant picker"); >+ endPicker = document.querySelector("#"+thisInput.dataset.date_to).flatpickr(); >+ } > endPicker.set('minDate', selectedDates[0]); > } > }, > }); > $(document).ready(function(){ > $(".flatpickr").each(function(){ >- let options = {}; >+ >+ var thisPicker; >+ if ( $(this).get(0)._flatpickr ) { >+ thisPicker = $(this).get(0)._flatpickr; >+ } else { >+ thisPicker = $(this).flatpickr(); >+ } > > if( $(this).hasClass("futuredate") ) { >- options['minDate'] = new Date().fp_incr(1); >- options['allowInvalidPreload'] = true; >+ thisPicker.set('minDate', new Date().fp_incr(1)); >+ thisPicker.set('allowInvalidPreload', true); > } > if( $(this).hasClass("pastdate") ) { >- options['maxDate'] = new Date().fp_incr(-1); >+ thisPicker.set('maxDate', new Date().fp_incr(-1)); > } >- $(this).flatpickr(options); > }); > }); > </script> >-- >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 29450
:
127507
|
127621