Bugzilla – Attachment 164740 Details for
Bug 35087
Discount rate should only allow valid input formats
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35087: (follow-up) Accept only values which will be saved correctly
Bug-35087-follow-up-Accept-only-values-which-will-.patch (text/plain), 4.26 KB, created by
Thibaud Guillot (thibaud_g)
on 2024-04-11 14:27:47 UTC
(
hide
)
Description:
Bug 35087: (follow-up) Accept only values which will be saved correctly
Filename:
MIME Type:
Creator:
Thibaud Guillot (thibaud_g)
Created:
2024-04-11 14:27:47 UTC
Size:
4.26 KB
patch
obsolete
>From e3bacef1382d63a2f4692115ba16d6461cd69c71 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Wed, 31 Jan 2024 16:47:34 +0000 >Subject: [PATCH] Bug 35087: (follow-up) Accept only values which will be saved > correctly > >This patch adds a regex (thanks to Katrin for the help) specific to the >range of values which will be accepted by the discount column in the >database which has the type "float(6,4)". > >The patch also removes the format() filter from the template so that >values returned from the database won't be truncated: > >Using "format ('%.1f')", a value in the db of '9.009' would appear in >the edit form as '9.0', a change which could be missed if the user was >editing some other field in the vendor edit form. > >To test, apply the patch and clear your browser cache if necessary. > >- Go to Acquisitions -> Vendors -> Edit vendor. >- Under "Ordering information," test entering various values in the > "Discount" field. It should accept numbers with up to two digits > before the decimal and up to three digits after the decimal: > > 9, 99, -99, 99.9, 0.99, 99.99, 99.999 > >- In each of these cases, confirm that a value accepted by the > client-side validation is also accepted when you submit the form and > is correctly displayed when you edit that vendor again. > >- It should not accept: > > 100, 100.001, 100.00001 > >- The error message has been updated to read, "Please enter a decimal > number in the format: 0.0" > >Signed-off-by: Owen Leonard <oleonard@myacpl.org> >Signed-off-by: Sonia <sonia.bouis@univ-lyon3.fr> >--- > .../intranet-tmpl/prog/en/includes/validator-strings.inc | 1 - > koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt | 2 +- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 4 ++++ > 3 files changed, 5 insertions(+), 2 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >index 578b51da82d..87dde3e6101 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/validator-strings.inc >@@ -12,7 +12,6 @@ > digits: _("Please enter only digits."), > equalTo: _("Please enter the same value again."), > number: _("Please add amount in valid format: 0.00"), >- decimal_rate: $.validator.addMethod("decimal_rate", $.validator.methods.number, "Please add rate in valid format: 0.00"), > maxlength: $.validator.format(_("Please enter no more than {0} characters.")), > minlength: $.validator.format(_("Please enter at least {0} characters.")), > rangelength: $.validator.format(_("Please enter a value between {0} and {1} characters long.")), >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >index 827df94ad89..0a361f7fd54 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/supplier.tt >@@ -349,7 +349,7 @@ > <input type="hidden" name="tax_rate" value="0" /> > [% END %] > <li><label for="discount">Discount: </label> >- <input class="rate" type="text" size="6" id="discount" name="discount" value="[% discount | format ('%.1f') %]" />%</li> >+ <input class="rate" type="text" size="6" id="discount" name="discount" value="[% discount | html %]" />%</li> > <li> > <label for="deliverytime">Delivery time: </label> > <input type="text" size="2" id="deliverytime" name="deliverytime" value="[% deliverytime | html %]" /> days >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index 4cef40e856d..b9345ca7f50 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -119,6 +119,10 @@ $(document).ready(function() { > number: true > }); > >+ jQuery.validator.addMethod("decimal_rate", function(value, element) { >+ return this.optional( element ) || /^[\-]?\d{0,2}(\.\d{0,3})*$/.test( value ); >+ }, __('Please enter a decimal number in the format: 0.0') ); >+ > jQuery.validator.addClassRules("rate", { > decimal_rate: true > }); >-- >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 35087
:
157302
|
157626
|
158921
|
159831
|
161128
|
161225
|
161237
|
161596
|
161597
|
161598
|
161704
|
161705
|
161706
|
162065
|
162066
|
162067
|
164739
|
164740
|
167746
|
167747
|
171197
|
171198
|
171594
|
171595