From 57221e083bb329f3c428fd20e7e7f65a6ab10186 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 13 May 2022 15:14:26 +0000 Subject: [PATCH] Bug 24010: Number of issues to display to staff accepts non-integer values This patch modifies the subscription entry form so that it will perform a check on the staffdisplaycount and opacdisplaycount fields before proceding to the second step. It verifies that the values are numeric. The changes are made in the style of the existing form validation, which should be rewritten to either use the validation plugin or to peform checks in a way that all checks are run before warning the user. However, this smaller change will work in the meantime. To test, apply the patch and go to Serials -> New subscription. - Fill out the form with at least the required fields, but put something other than a number if the "Number of issues to display to staff" and "Number of issues to display to the public" with non-numeric characters. - When you click the "Next" button you should get an error message, "Number of issues to display to staff must be a number." - Correct the issues to display to staff field and submit again. - You should get a different error message, "Number of issues to display to the public must be a number." - Correct this field and you should be able to proceed to the next step. Signed-off-by: David Nind Signed-off-by: Jonathan Druart Signed-off-by: Tomas Cohen Arazi --- .../prog/en/modules/serials/subscription-add.tt | 4 ++-- .../intranet-tmpl/prog/js/subscription-add.js | 17 +++++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt index 53760cf4fb..74eafacd8c 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/serials/subscription-add.tt @@ -246,11 +246,11 @@ fieldset.rows table { clear: none; margin: 0; }
  • - +
  • - +
  • diff --git a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js index 557b5b18a7..c0938ef035 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js +++ b/koha-tmpl/intranet-tmpl/prog/js/subscription-add.js @@ -68,8 +68,21 @@ function Check_page1() { var bib_exists = $("input[name='title']").val().length; - if (!bib_exists) alert( __("Bibliographic record does not exist!") ); - return bib_exists; + if (!bib_exists){ + alert( __("Bibliographic record does not exist!") ); + return false; + } + + if( isNaN( $("#staffdisplaycount").val() ) ){ + alert( __("Number of issues to display to staff must be a number") ); + return false; + } + if( isNaN( $("#opacdisplaycount").val() ) ){ + alert( __("Number of issues to display to the public must be a number") ); + return false; + } else { + return true; + } } function Check_page2(){ -- 2.39.5