From 64134dce3cea4a87e7ecf72273ef0c25959ab524 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 8 Jan 2024 16:56:06 +0000 Subject: [PATCH] Bug 35725: Fix 'Create' button enabled/disabled The previous patch fixed what it stated, but uncovered a new issue: If you input a cardnumber + a branchcode and then change type, the 'Create' button becomes disabled This happens because the trigger for it is on change only, the current patch updates this to also happen on DOMContentLoaded. Test plan: 1) Apply previous patch 2) Do steps from previous patch plan up to and including step 5) 3) Click 'Create'. Notice it doesn't submit (nothing happens). 4) Apply this patch and do a hard reload (clearing browser js cache) 5) Repeat steps 1) to 3). Notice it now submits correctly. Signed-off-by: David Nind Signed-off-by: Tomas Cohen Arazi Signed-off-by: Katrin Fischer --- Koha/ILL/Backend/intra-includes/create.inc | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/Koha/ILL/Backend/intra-includes/create.inc b/Koha/ILL/Backend/intra-includes/create.inc index 4d222b844a..0130d22fa6 100644 --- a/Koha/ILL/Backend/intra-includes/create.inc +++ b/Koha/ILL/Backend/intra-includes/create.inc @@ -120,12 +120,18 @@ [% INCLUDE "${cwd}/shared-includes/shared.js" %] // Require a username and branch selection document.addEventListener('DOMContentLoaded', function(){ - $('#create_form #cardnumber, #create_form #branchcode').change(function() { - var comp = ['#cardnumber','#branchcode'].filter(function(id) { - return $(id).val().length > 0; - }); - $('#ill-submit').attr('disabled', comp.length < 2); + let cardnumber_input = '#create_form #cardnumber'; + let branchcode_input = '#create_form #branchcode'; + updateCreateButtonStatus(); + $(cardnumber_input + ',' + branchcode_input).change(function() { + updateCreateButtonStatus(); + }); + function updateCreateButtonStatus(){ + var comp = [cardnumber_input,branchcode_input].filter(function(id) { + return $(id).val().length > 0; }); + $('#ill-submit').attr('disabled', comp.length < 2); + } /* Maintain patron autocomplete compatibility across versions */ [% IF koha_version.major <= 22 && koha_version.minor < 11 %] $('#create_form #cardnumber').autocomplete({ -- 2.39.5