Bugzilla – Attachment 127892 Details for
Bug 29478
flatpickr misses quick shortcut to "Today" date
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29478: Today should select now for pastinclusive
Bug-29478-Today-should-select-now-for-pastinclusiv.patch (text/plain), 3.04 KB, created by
David Nind
on 2021-11-19 18:27:54 UTC
(
hide
)
Description:
Bug 29478: Today should select now for pastinclusive
Filename:
MIME Type:
Creator:
David Nind
Created:
2021-11-19 18:27:54 UTC
Size:
3.04 KB
patch
obsolete
>From 3a59be1bc12058eae313bb37138f5f000f501c49 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 17 Nov 2021 12:19:50 +0100 >Subject: [PATCH] Bug 29478: Today should select now for pastinclusive > >If Today is clicked when we only allow dates in the past and today/now, >we should select the current date/time >We need to update the maxDate to make it up-to-date, or the maxDate may >be set to the minute before and clicking Today will blank the input. > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/en/includes/calendar.inc | 18 +++++++++++++++--- > 1 file changed, 15 insertions(+), 3 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 83ae48013e..11c8ee4e50 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -101,18 +101,23 @@ > label: __("or"), > onClick: (index, fp) => { > let date; >+ let hh = 23, mm = 59; > switch (index) { > case 0: > date = new Date().fp_incr(-1); > break; > case 1: > date = new Date(); >+ if ( $(fp.input).data("flatpickr-pastinclusive") === true ) { >+ hh = date.getHours(); >+ mm = date.getMinutes(); >+ } > break; > case 2: > date = new Date().fp_incr(1); > break; > } >- date.setHours(23, 59, 0, 0); >+ date.setHours(hh, mm, 0, 0); > fp.setDate(date); > } > }) >@@ -121,6 +126,7 @@ > $(document).ready(function(){ > $(".flatpickr").each(function(){ > let options = {}; >+ let refresh_max_date = 0; > > if( $(this).data("flatpickr-futuredate") === true ) { > let original_date = $(this).val(); >@@ -139,7 +145,8 @@ > } > } > if( $(this).data("flatpickr-pastinclusive") === true ) { >- options['maxDate'] = "today"; >+ options['maxDate'] = new Date(); /* Not today or hh:mm will be 00:00 */ >+ refresh_max_date = 1; > } > if( $(this).data("flatpickr-pastdate") === true ) { > options['maxDate'] = new Date().fp_incr(-1); >@@ -149,7 +156,12 @@ > options['dateFormat'] = flatpickr_dateformat_string + " " + flatpickr_timeformat_string; > } > >- $(this).flatpickr(options); >+ let fp = $(this).flatpickr(options); >+ if ( refresh_max_date ) { >+ /* Refresh the maxDate every 30 secondes to make sure the user will not >+ be stuck with the minute passed */ >+ setInterval(() => { fp.set("maxDate", new Date()) }, 30000); >+ } > }); > }); > </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 29478
:
127626
|
127676
|
127694
|
127721
|
127722
|
127730
|
127804
|
127850
|
127890
|
127891
|
127892
|
127893
|
127920
|
127921
|
127922
|
127923
|
127968