From 5a558ec42ed1043f8df117386f323d4b85aad6b0 Mon Sep 17 00:00:00 2001 From: David Cook Date: Tue, 27 Aug 2024 03:50:44 +0000 Subject: [PATCH] Bug 37742: Fix error display This change fixes the display of the error message on "My virtual card" on the OPAC. Test plan: 0. Apply the patch and enable syspref "OPACVirtualCard" 1. Go to http://localhost:8081/cgi-bin/koha/members/memberentry.pl ?op=edit_form&destination=circ&borrowernumber=51 2. Add an asterisk (*) to the end of the card number 3. Go to http://localhost:8080/cgi-bin/koha/opac-virtual-card.pl 4. Note that the error message appears as follows: Code 39 must contain only digits, capital letters, spaces and the symbols -.$/+% Signed-off-by: David Nind --- .../opac-tmpl/bootstrap/js/barcode-generator.js | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/barcode-generator.js b/koha-tmpl/opac-tmpl/bootstrap/js/barcode-generator.js index 97628ba7fa..753edb6e73 100644 --- a/koha-tmpl/opac-tmpl/bootstrap/js/barcode-generator.js +++ b/koha-tmpl/opac-tmpl/bootstrap/js/barcode-generator.js @@ -17,11 +17,16 @@ document.addEventListener("DOMContentLoaded", function() { } document.getElementById('barcode-container').innerHTML = svg } catch (error) { - // Use regex to find error message - const match = error.message.match(/: (.+)$/); - const errorMessage = match ? match[1] : error.message; - console.error(error); - document.getElementById('barcode-container').innerHTML = "

" + __("Error:") + " ${errorMessage}

"; + + const p_node = document.createElement('p'); + const strong_node = document.createElement('strong'); + strong_node.textContent = __("Error: "); + const span_node = document.createElement('span'); + span_node.textContent = __("Unable to generate barcode"); + span_node.setAttribute('id','barcode-gen-error'); + p_node.appendChild(strong_node); + p_node.appendChild(span_node); + document.getElementById('barcode-container').replaceChildren(p_node); } }); -- 2.39.2