Bugzilla – Attachment 176285 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: Add validation for replacement price in item and batch modification forms
Bug-38839-Add-validation-for-replacement-price-in-.patch (text/plain), 7.10 KB, created by
David Nind
on 2025-01-09 09:50:06 UTC
(
hide
)
Description:
Bug 38839: Add validation for replacement price in item and batch modification forms
Filename:
MIME Type:
Creator:
David Nind
Created:
2025-01-09 09:50:06 UTC
Size:
7.10 KB
patch
obsolete
>From 8fc8d5990ec8f866b0f86c36633dcab9e0a7ecdf Mon Sep 17 00:00:00 2001 >From: Leo Stoyanov <leo.stoyanov@bywatersolutions.com> >Date: Tue, 7 Jan 2025 23:31:37 +0000 >Subject: [PATCH] Bug 38839: Add validation for replacement price in item and > batch modification forms > >Adds validation for the replacement price on the item >input and batch modification forms. > >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" (e.g., 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) and restart > everything (restart_all). >5. Repeat steps 1-3. A red error message will now appear below > 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. > >Signed-off-by: David Nind <david@davidnind.com> >--- > .../prog/css/src/staff-global.scss | 20 +++++++++++++++++++ > .../prog/en/includes/html_helpers.inc | 4 ++++ > .../en/includes/modal-replacementprice.inc | 16 +++++++++++++++ > .../prog/en/modules/cataloguing/additem.tt | 1 + > .../prog/js/cataloging_additem.js | 19 ++++++++++++++++++ > .../intranet-tmpl/prog/js/pages/batchMod.js | 20 +++++++++++++++++++ > 6 files changed, 80 insertions(+) > create mode 100644 koha-tmpl/intranet-tmpl/prog/en/includes/modal-replacementprice.inc > >diff --git a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >index 878634a08a..f29e167ab0 100644 >--- a/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >+++ b/koha-tmpl/intranet-tmpl/prog/css/src/staff-global.scss >@@ -4896,3 +4896,23 @@ div .suggestion_note { > } > } > } >+ >+#cat_additem .replacementprice_error_message { >+ color: red; >+ margin-left: 20vw; >+} >+ >+#tools_batchMod-edit .replacementprice_error_message { >+ color: red; >+ margin-left: 24.5vw; >+} >+ >+.replacementprice_error_message.hidden { >+ display: none; >+} >+ >+@media (max-width: 1000px) { >+ .replacementprice_error_message { >+ margin-left: 23.5vw; >+ } >+} >\ No newline at end of file >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 50d618f392..0d5f628377 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -216,6 +216,10 @@ > <span class="hint" id="hint[% subfield.tag | html %][% subfield.subfield | html %][% subfield.random | html %]"></span> > > </div> >+ >+ [% IF subfield.subfield == 'v' %] >+ <span class="replacementprice_error_message hidden"> Only numbers and periods (e.g., 10.99) are allowed.</span> >+ [% END %] > </li> > [% END %] > </ol> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/modal-replacementprice.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/modal-replacementprice.inc >new file mode 100644 >index 0000000000..5f1c704286 >--- /dev/null >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/modal-replacementprice.inc >@@ -0,0 +1,16 @@ >+<!-- Modal for Replacement Price Validation --> >+<div id="replacementpriceModal" class="modal fade" tabindex="-1" role="dialog" aria-labelledby="replacementpriceModalLabel" aria-hidden="true"> >+ <div class="modal-dialog" role="document"> >+ <div class="modal-content"> >+ <div class="modal-header"> >+ <h5 class="modal-title" id="replacementpriceModalLabel">Invalid Replacement Price</h5> >+ </div> >+ <div class="modal-body"> >+ <p>The replacement price format is invalid. Please only use numbers and periods (.) as the decimal separator.</p> >+ </div> >+ <div class="modal-footer"> >+ <button type="button" class="btn btn-primary" data-bs-dismiss="modal">OK</button> >+ </div> >+ </div> >+ </div> >+</div> >diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >index a41569fe99..cec36d91e6 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/additem.tt >@@ -7,6 +7,7 @@ > [% USE TablesSettings %] > [% PROCESS 'i18n.inc' %] > [% INCLUDE 'doc-head-open.inc' %] >+[% INCLUDE 'modal-replacementprice.inc' %] > <title>[% FILTER collapse %] > [% t("Items") | html %] › > [% IF ( biblio.author ) %] >diff --git a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >index d4f28bbf84..3ef01ddcc5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js >@@ -4,6 +4,25 @@ var browser = KOHA.browser(searchid, parseInt(biblionumber, 10)); > browser.show(); > > $(document).ready(function(){ >+ $("#cataloguing_additem_newitem form").on("submit", function (e) { >+ var replacementprice = $("input[name='items.replacementprice']").val(); >+ if (!/^[0-9.]+$/.test(replacementprice)) { >+ e.preventDefault(); >+ return false; >+ } >+ return true; >+ }); >+ >+ $("input[name='items.replacementprice']").on("input", function () { >+ var value = $(this).val(); >+ var isValid = /^[0-9.]*$/.test(value); >+ >+ if (!isValid) { >+ $('.replacementprice_error_message').removeClass('hidden'); >+ } else { >+ $('.replacementprice_error_message').addClass('hidden'); >+ } >+ }); > > // Remove the onclick event defined in browser.js, > // otherwise the deletion confirmation will not work correctly >diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js >index df428f831b..84e86277d9 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/pages/batchMod.js >@@ -118,6 +118,26 @@ function hideAllColumns() { > } > > $(document).ready(function () { >+ $('form[action="batchMod.pl"]').on("submit", function (e) { >+ var replacementprice = $("input[name='items.replacementprice']").val(); >+ if (!/^[0-9.]+$/.test(replacementprice)) { >+ e.preventDefault(); >+ return false; >+ } >+ return true; >+ }); >+ >+ $("input[name='items.replacementprice']").on("input", function () { >+ var value = $(this).val(); >+ var isValid = /^[0-9.]*$/.test(value); >+ >+ if (!isValid) { >+ $('.replacementprice_error_message').removeClass('hidden'); >+ } else { >+ $('.replacementprice_error_message').addClass('hidden'); >+ } >+ }); >+ > var items_table = KohaTable("itemst", { > "columnDefs": [ > { "targets": [0, 1], "orderable": false, "searchable": true }, >-- >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