Bugzilla – Attachment 134683 Details for
Bug 30514
Error in date format check following datepicker removal
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 30514: Error in date format check following datepicker removal
Bug-30514-Error-in-date-format-check-following-dat.patch (text/plain), 5.41 KB, created by
Katrin Fischer
on 2022-05-06 08:36:57 UTC
(
hide
)
Description:
Bug 30514: Error in date format check following datepicker removal
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2022-05-06 08:36:57 UTC
Size:
5.41 KB
patch
obsolete
>From e6c31e411dc608f8f76826203c43252cdd2f71fd Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Tue, 12 Apr 2022 14:23:42 +0000 >Subject: [PATCH] Bug 30514: Error in date format check following datepicker > removal > >This patch corrects the is_valid_date function in the OPAC and staff >interface so that it work correctly with Flatpickr. > >To test, apply the patch and clear your browser cache if necessary. > >- In the staff client, locate a bibliographic record and edit its items. >- Test that the "Date acquired" date picker works correctly and that > there are no errors in the browser console. >- Test other date input fields to check that they still work, e.g. > specify due date during checkout; Catalog statistics wizard; Patron > entry/modification, etc. >- Perform similar tests in the OPAC: Hold suspension; Update your > personal details. > >Signed-off-by: David Cook <dcook@prosentient.com.au> > >Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de> >--- > koha-tmpl/intranet-tmpl/prog/js/calendar.js | 12 +++---- > .../bootstrap/en/includes/calendar.inc | 31 ++++++++----------- > 2 files changed, 19 insertions(+), 24 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/js/calendar.js b/koha-tmpl/intranet-tmpl/prog/js/calendar.js >index 7a4a5083e8..81561cc42d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/calendar.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/calendar.js >@@ -1,4 +1,4 @@ >-/* global debug sentmsg __ dateformat_pref dateformat_string bidi calendarFirstDayOfWeek */ >+/* global debug sentmsg __ dateformat_pref flatpickr_dateformat_string bidi calendarFirstDayOfWeek */ > /* exported DateTime_from_syspref flatpickr_weekdays flatpickr_months */ > var MSG_PLEASE_ENTER_A_VALID_DATE = ( __("Please enter a valid date (should match %s).") ); > if (debug > 1) { >@@ -8,19 +8,19 @@ if (debug > 1) { > function is_valid_date(date) { > // An empty string is considered as a valid date for convenient reasons. > if (date === '') return 1; >- var dateformat = dateformat_string; >+ var dateformat = flatpickr_dateformat_string; > if (dateformat == 'us') { > if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0; >- dateformat = 'mm/dd/yy'; >+ dateformat = 'm/d/Y'; > } else if (dateformat == 'metric') { > if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0; >- dateformat = 'dd/mm/yy'; >+ dateformat = 'd/m/Y'; > } else if (dateformat == 'iso') { > if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0; >- dateformat = 'yy-mm-dd'; >+ dateformat = 'Y-m-d'; > } else if (dateformat == 'dmydot') { > if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0; >- dateformat = 'dd.mm.yy'; >+ dateformat = 'd.m.Y'; > } > try { > flatpickr.parseDate(date, dateformat); >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >index 3a2fb12936..2cb09f2a1b 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/includes/calendar.inc >@@ -18,23 +18,18 @@ > var calendarFirstDayOfWeek = '[% Koha.Preference('CalendarFirstDayOfWeek') | html %]'; > var flatpickr_timeformat_string = [% IF Koha.Preference('TimeFormat') == '12hr' %]"G:i K"[% ELSE %]"H:i"[% END %]; > var flatpickr_timeformat = [% IF Koha.Preference('TimeFormat') == '12hr' %]false[% ELSE %]true[% END %]; >- var dateformat_string = ""; > var flatpickr_dateformat_string = ""; > switch ( dateformat_pref ){ > case "us": >- dateformat_string = "mm/dd/yy"; > flatpickr_dateformat_string = "m/d/Y"; > break; > case "metric": >- dateformat_string = "dd/mm/yy"; > flatpickr_dateformat_string = "d/m/Y"; > break; > case "dmydot": >- dateformat_string = "dd.mm.yy"; > flatpickr_dateformat_string = "d.m.Y"; > break; > default: >- dateformat_string = "yy-mm-dd"; > flatpickr_dateformat_string = "Y-m-d"; > } > </script> >@@ -94,19 +89,19 @@ > function is_valid_date(date) { > // An empty string is considered as a valid date for convenient reasons. > if (date === '') return 1; >- var dateformat = dateformat_string; >- if (dateformat == 'us') { >- if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0; >- dateformat = 'mm/dd/yy'; >- } else if (dateformat == 'metric') { >- if (date.search(/^\d{2}\/\d{2}\/\d{4}($|\s)/) == -1) return 0; >- dateformat = 'dd/mm/yy'; >- } else if (dateformat == 'iso') { >- if (date.search(/^\d{4}-\d{2}-\d{2}($|\s)/) == -1) return 0; >- dateformat = 'yy-mm-dd'; >- } else if (dateformat == 'dmydot') { >- if (date.search(/^\d{2}\.\d{2}\.\d{4}($|\s)/) == -1) return 0; >- dateformat = 'dd.mm.yy'; >+ var dateformat = flatpickr_dateformat_string; >+ switch ( dateformat_pref ){ >+ case "us": >+ flatpickr_dateformat_string = "m/d/Y"; >+ break; >+ case "metric": >+ flatpickr_dateformat_string = "d/m/Y"; >+ break; >+ case "dmydot": >+ flatpickr_dateformat_string = "d.m.Y"; >+ break; >+ default: >+ flatpickr_dateformat_string = "Y-m-d"; > } > try { > flatpickr.parseDate(date, dateformat); >-- >2.30.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 30514
:
133218
|
133428
| 134683