Bugzilla – Attachment 153874 Details for
Bug 34352
It would be great to have a generic flatpickr based input for datatables column filters
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 34352: Add allowyear to flatpickr options
Bug-34352-Add-allowyear-to-flatpickr-options.patch (text/plain), 3.02 KB, created by
Martin Renvoize
on 2023-07-25 13:31:27 UTC
(
hide
)
Description:
Bug 34352: Add allowyear to flatpickr options
Filename:
MIME Type:
Creator:
Martin Renvoize
Created:
2023-07-25 13:31:27 UTC
Size:
3.02 KB
patch
obsolete
>From f6b09f6b41d3c2f7558da7ec422c7453185205d9 Mon Sep 17 00:00:00 2001 >From: Martin Renvoize <martin.renvoize@ptfs-europe.com> >Date: Tue, 25 Jul 2023 11:58:09 +0100 >Subject: [PATCH] Bug 34352: Add allowyear to flatpickr options > >An attempt at allowing four digit years to be entered into the flatpickr >bound date filter input. > >However, we're triggering at the wrong stage and I'm not sure where else >to look right now :(. >--- > .../prog/en/includes/calendar.inc | 19 +++++++++++++------ > koha-tmpl/intranet-tmpl/prog/js/datatables.js | 2 +- > 2 files changed, 14 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 5606e9956e..5c0ee4c961 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -70,15 +70,22 @@ > } > }); > }, >- onClose: function( selectedDates, dateText, instance) { >- validate_date( dateText, instance ); >+ onClose: function(selectedDates, dateText, instance) { > var thisInput = instance.input; >- if ( thisInput.hasAttribute('data-date_to') ) { >- var endPicker = document.querySelector("#"+thisInput.dataset.date_to)._flatpickr; >- endPicker.set('minDate', selectedDates[0]); >+ const regex = new RegExp('^\d{4}$'); >+ if ( $(thisInput).data('flatpickr-allowyear') && regex.test(dateText) ) { >+ console.log('Skipping validation'); >+ } >+ else { >+ validate_date( dateText, instance ); >+ >+ if ( thisInput.hasAttribute('data-date_to') ) { >+ var endPicker = document.querySelector("#"+thisInput.dataset.date_to)._flatpickr; >+ endPicker.set('minDate', selectedDates[0]); >+ } > } > >- let = on_close_focus = $(thisInput).data('flatpickr-on-close-focus'); >+ var on_close_focus = $(thisInput).data('flatpickr-on-close-focus'); > if ( on_close_focus ) { > $(on_close_focus).focus(); > } >diff --git a/koha-tmpl/intranet-tmpl/prog/js/datatables.js b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >index d61556681a..fced5a750b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/datatables.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/datatables.js >@@ -892,7 +892,7 @@ function _dt_add_filters(table_node, table_dt, filters_options = {}) { > $(this).html( select ); > } else if (table_dt.settings()[0].aoColumns[i].sType == 'date' ) { > let existing_search = table_dt.column(i).search(); >- let input = $('<input type="text" class="flatpickr" style="width: 100%" />'); >+ let input = $('<input type="text" class="flatpickr" data-flatpickr-allowyear="true" style="width: 100%" />'); > if (existing_search) { > input.prop("value", existing_search); > } >-- >2.41.0
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 34352
:
153873
| 153874