Bugzilla – Attachment 54905 Details for
Bug 14060
Remove readonly on date inputs
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 14060: Force the input to contain a valid date
Bug-14060-Force-the-input-to-contain-a-valid-date.patch (text/plain), 6.13 KB, created by
Jonathan Druart
on 2016-08-26 07:45:19 UTC
(
hide
)
Description:
Bug 14060: Force the input to contain a valid date
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2016-08-26 07:45:19 UTC
Size:
6.13 KB
patch
obsolete
>From 51559d347007418e72982714a5bd029d6379c6e6 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 1 Dec 2015 17:33:15 +0000 >Subject: [PATCH] Bug 14060: Force the input to contain a valid date > >Before this patch, the user was still allowed to enter a valid date. >Now, if the date is not valid, the input is emptied. >--- > .../intranet-tmpl/prog/en/includes/calendar.inc | 21 ++++++++++++++++----- > .../prog/en/modules/circ/circulation.tt | 2 ++ > .../intranet-tmpl/prog/en/modules/circ/offline.tt | 2 ++ > .../intranet-tmpl/prog/en/modules/circ/returns.tt | 2 ++ > .../prog/en/modules/members/moremember.tt | 2 ++ > .../intranet-tmpl/prog/js/pages/circulation.js | 4 ++++ > 6 files changed, 28 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 3c0b8b3..1b9e48b 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/calendar.inc >@@ -8,9 +8,8 @@ var sentmsg = 0; > if (debug > 1) {alert("dateformat: " + dformat + "\ndebug is on (level " + debug + ")");} > var MSG_PLEASE_ENTER_A_VALID_DATE = _("Please enter a valid date (should match %s)."); > >-function validate_date (dateText, inst) { >- var dateformat = '[% Koha.Preference('dateformat') %]'; >- var dateformat_str = dateformat >+function is_valid_date(date) { >+ var dateformat = dateformat_str = '[% Koha.Preference('dateformat') %]'; > if ( dateformat == 'us' ) { > dateformat = 'mm/dd/yy'; > dateformat_str = 'mm/dd/yyyy'; >@@ -22,11 +21,19 @@ function validate_date (dateText, inst) { > dateformat_str = 'yyyy-mm-dd'; > } > try { >- $.datepicker.parseDate(dateformat, dateText); >+ $.datepicker.parseDate(dateformat, date); > } catch (e) { >+ return 0; >+ }; >+ return 1; >+} >+ >+function validate_date (dateText, inst) { >+ if ( !is_valid_date(dateText) ) { >+ var dateformat_str = '[% Koha.Preference('dateformat') %]'; > alert(MSG_PLEASE_ENTER_A_VALID_DATE.format(dateformat_str)); > $('#'+inst.id).val(''); >- }; >+ } > } > > function Date_from_syspref(dstring) { >@@ -115,6 +122,8 @@ $.datepicker.setDefaults({ > onClose: function(dateText, inst) { > validate_date(dateText, inst); > }, >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > // http://jqueryui.com/demos/datepicker/#date-range > var dates = $( ".datepickerfrom, .datepickerto" ).datepicker({ >@@ -132,6 +141,8 @@ $.datepicker.setDefaults({ > onClose: function(dateText, inst) { > validate_date(dateText, inst); > }, >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > }); > //]]> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >index ba469ee..f197d7c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/circulation.tt >@@ -78,6 +78,8 @@ function toggle_onsite_checkout(){ > }, > hour: 23, > minute: 59 >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > } > } >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >index 2bf0868..d03833c 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/offline.tt >@@ -560,6 +560,8 @@ $(document).ready(function () { > }, > hour: 23, > minute: 59 >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > $('#mainform').submit(function (event) { > event.preventDefault(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >index 20f6076..f11ff83 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/circ/returns.tt >@@ -62,6 +62,8 @@ $(document).ready(function () { > hour: 23, > minute: 59, > maxDate: 0 >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > $("#return_date_override").on("blur", function() { > check_valid_return_date(); >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >index f89273f..43b1c49 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/moremember.tt >@@ -88,6 +88,8 @@ $(document).ready(function() { > validate_date(dateText, inst); > }, > minDate: 1, // require that hold suspended until date is after today >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > > $("#view_restrictions").on("click",function(){ >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >index cb0cddd..c6525ff 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/circulation.js >@@ -35,6 +35,8 @@ $(document).ready(function() { > minDate: 1, // require that renewal date is after today > hour: 23, > minute: 59 >+ }).on("change", function(e) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > $("#duedatespec").datetimepicker({ > onClose: function(dateText, inst) { >@@ -44,6 +46,8 @@ $(document).ready(function() { > }, > hour: 23, > minute: 59 >+ }).on("change", function(e, value) { >+ if ( ! is_valid_date( $(this).val() ) ) {$(this).val("");} > }); > $("#export_submit").on("click",function(){ > var output_format = $("#output_format").val(); >-- >2.8.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 14060
:
38484
|
38540
|
38541
|
44542
|
44543
|
44544
|
45282
|
46224
|
54606
|
54607
|
54608
|
54609
|
54610
|
54902
|
54903
|
54904
|
54905
|
54906
|
54907
|
55001
|
55002
|
55012
|
55013
|
55014
|
55015
|
55016
|
55017
|
55018
|
55019
|
55165
|
55246
|
55247
|
55248
|
55249
|
55250
|
55251
|
55252
|
55253
|
55254
|
55255
|
55256