Bugzilla – Attachment 177093 Details for
Bug 38839
Add validation for replacement price in item input form
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 38839: (follow-up) Added stricter validation for replacement price fields.
Bug-38839-follow-up-Added-stricter-validation-for-.patch (text/plain), 3.49 KB, created by
Leo Stoyanov
on 2025-01-23 22:53:00 UTC
(
hide
)
Description:
Bug 38839: (follow-up) Added stricter validation for replacement price fields.
Filename:
MIME Type:
Creator:
Leo Stoyanov
Created:
2025-01-23 22:53:00 UTC
Size:
3.49 KB
patch
obsolete
>From b1ee48abf81c7d00febd45c2cf2f503c36872a7f Mon Sep 17 00:00:00 2001 >From: Leo Stoyanov <leo.stoyanov@bywatersolutions.com> >Date: Thu, 23 Jan 2025 22:48:20 +0000 >Subject: [PATCH] Bug 38839: (follow-up) Added stricter validation for > replacement price fields. > >Adds validation for the replacement price on the item input and batch modification forms. > >This follow-up utilizes a new jQuery "replacement_price_decimal" validator for more strict validation; that is, there may only be up to 6 digits before the decimal and 2 digits after the decimal. > >Test plan: >1. Search for a record in the staff interface, select any record with an item, click "Edit", and select "Manage items". >2. Click "Actions" on the item in the table, select "Edit", and input an invalid "v - Cost, replacement price" (for example, 1,00). >3. Click "Save changes" and the form will submit but with no price shown in the table on the next page. >4. Apply the patch, update the CSS (yarn build), restart everything (restart_all), AND clear browser cache. >5. Repeat steps 1-3. A red error message will now appear to the right of the input field, notifying the user that only numbers and periods are allowed. The user will not be able to submit the form. >6. The same change was also made to the batch modification form under Cataloging > Batch item modification. >--- > .../intranet-tmpl/prog/en/includes/html_helpers.inc | 2 +- > koha-tmpl/intranet-tmpl/prog/js/staff-global.js | 9 +++++++++ > 2 files changed, 10 insertions(+), 1 deletion(-) > >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 2a3b47ef17..5ec9045714 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -171,7 +171,7 @@ > [% 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" data-flatpickr-set-to-today="true" /> > [% ELSIF ( mv.type == 'replacementprice' ) %] >- <input class="decimal valid input_marceditor [% kohafield | html %]" type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" value="[% mv.value | html %]" aria-invalid="false" /> >+ <input class="replacement_price_decimal valid input_marceditor [% kohafield | html %]" type="text" id="[% mv.id | html %]" name="[% kohafield | html %]" value="[% mv.value | html %]" /> > [% END %] > > [% IF subfield.kohafield == 'items.more_subfields_xml' %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >index e76bf876f6..2e0d6d0afd 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/staff-global.js >@@ -157,6 +157,15 @@ $(document).ready(function () { > decimal_rate: true > }); > >+ jQuery.validator.addMethod("replacement_price_decimal_rate", function(value, element) { >+ return this.optional(element) || /^\d{1,6}(\.\d{1,2})?$/.test(value); >+ }, __('Please enter up to 6 digits before the decimal and 2 digits after.')); >+ >+ jQuery.validator.addClassRules("replacement_price_decimal", { >+ replacement_price_decimal_rate: true >+ }); >+ >+ > $("#logout").on("click", function () { > logOut(); > }); >-- >2.39.5
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 38839
:
176279
|
176285
|
176286
|
176403
|
176407
|
176839
| 177093