Bugzilla – Attachment 171881 Details for
Bug 37398
Initialize a datepicker on all date/datetime fields when adding/editing items
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 37398: Add set to today function to calendar.inc
Bug-37398-Add-set-to-today-function-to-calendarinc.patch (text/plain), 3.19 KB, created by
Lucas Gass (lukeg)
on 2024-09-23 16:25:17 UTC
(
hide
)
Description:
Bug 37398: Add set to today function to calendar.inc
Filename:
MIME Type:
Creator:
Lucas Gass (lukeg)
Created:
2024-09-23 16:25:17 UTC
Size:
3.19 KB
patch
obsolete
>From d57219a86c2bae0777ba34b6cea8f2f3a35e372f Mon Sep 17 00:00:00 2001 >From: Lucas Gass <lucas@bywatersolutions.com> >Date: Mon, 23 Sep 2024 16:23:13 +0000 >Subject: [PATCH] Bug 37398: Add set to today function to calendar.inc > >To test: >1. Try editing some items with a empty value in the flatpickr. >2. Make sure the empty date fields get a date set to today when you click on the empty field. >3. Try a datetime field, making sure the datetime is correctly set. >--- > koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc | 9 +++++++++ > .../intranet-tmpl/prog/en/includes/html_helpers.inc | 4 ++-- > 2 files changed, 11 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >index 9f1cdb6ceb2..384ade62cc8 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -122,6 +122,15 @@ > } > } > }, >+ onOpen: function( selectedDates, dateText, instance) { >+ var thisInput = instance.input; >+ let set_to_today = $(thisInput).data('flatpickr-set-to-today'); >+ if ( set_to_today ) { >+ if ( thisInput.value === '' ) { >+ instance.setDate( new Date() ); >+ } >+ } >+ }, > onClose: function( selectedDates, dateText, instance) { > validate_date( dateText, instance ); > var thisInput = instance.input; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 48c1c682f33..ead708ade3a 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -167,9 +167,9 @@ > <textarea id="[%- mv.id | html -%]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %]" rows="5" cols="64" >[% mv.value | html %]</textarea> > [% END %] > [% ELSIF ( mv.type == 'date_field' ) %] >- <input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" class="flatpickr" /> >+ <input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" class="flatpickr" data-flatpickr-set-to-today="true" /> > [% ELSIF ( mv.type == 'datetime_field' ) %] >- <input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" data-flatpickr-enable-time="true" /> >+ <input type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" class="input_marceditor [% kohafield | html %] flatpickr" value="[% mv.value | html %]" data-flatpickr-enable-time="true" data-flatpickr-set-to-today="true" /> > [% END %] > > [% IF subfield.kohafield == 'items.more_subfields_xml' %] >-- >2.39.2
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 37398
:
171416
|
171417
|
171419
|
171420
|
171421
|
171422
|
171423
|
171424
|
171881
|
171882
|
171919
|
171963
|
172187
|
172188
|
172189
|
172190
|
172191
|
172192
|
172193
|
172194
|
172195
|
172196
|
174558
|
174559
|
174560
|
174561
|
174562
|
174563
|
174564
|
174565
|
174566