From cac2694533baae42cf5bad1434287ca69c72116b Mon Sep 17 00:00:00 2001 From: Jason Stephenson Date: Sat, 30 Sep 2017 15:30:22 -0400 Subject: [PATCH] LP 1694058: Add confirmation dialog for multiple title holds. Add a dialog to confirm that the user really wants to place the requested number of title or metarecord holds to the validateHoldForm() function. Along the way, we add a format() function to the JS String prototype in the i18n_strings.tt2 so that we can have translated strings with placeholders in JavaScript. Signed-off-by: Jason Stephenson Signed-off-by: Kathy Lussier --- Open-ILS/src/templates/opac/i18n_strings.tt2 | 14 ++++++++++++++ .../web/js/ui/default/opac/holds-validation.js | 17 ++++++++++++++--- 2 files changed, 28 insertions(+), 3 deletions(-) diff --git a/Open-ILS/src/templates/opac/i18n_strings.tt2 b/Open-ILS/src/templates/opac/i18n_strings.tt2 index d92c2b5f63..1617e29684 100644 --- a/Open-ILS/src/templates/opac/i18n_strings.tt2 +++ b/Open-ILS/src/templates/opac/i18n_strings.tt2 @@ -3,7 +3,21 @@ This file allows us to bring TT2 i18n'ized strings to js source files, via js blob. --> diff --git a/Open-ILS/web/js/ui/default/opac/holds-validation.js b/Open-ILS/web/js/ui/default/opac/holds-validation.js index ef3c4cd616..7345e3fca9 100644 --- a/Open-ILS/web/js/ui/default/opac/holds-validation.js +++ b/Open-ILS/web/js/ui/default/opac/holds-validation.js @@ -60,11 +60,22 @@ function validateMethodSelections (alertMethodCboxes) { return { isValid: isFormOK, culpritNames : culprits }; } +function confirmMultipleHolds() { + var result = true; + var numSelect = document.getElementById("num_copies"); + if (numSelect) { + var num = parseInt(numSelect.value); + if (num > 1) { + result = window.confirm(eg_opac_i18n.EG_MULTIHOLD_MESSAGE.format(num)); + } + } + return result; +} + function validateHoldForm() { var res = validateMethodSelections(document.getElementsByClassName("hold-alert-method")); - if (res.isValid) - { - return true; + if (res.isValid) { + return confirmMultipleHolds(); } else { alert(eg_opac_i18n.EG_MISSING_REQUIRED_INPUT); res.culpritNames.forEach(function(n){ -- 2.43.2