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 <david@davidnind.com>
Signed-off-by: Tomas Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Pedro Amorim 2024-01-08 16:56:06 +00:00 committed by Katrin Fischer
parent 67733589a9
commit 64134dce3c
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
1 changed files with 11 additions and 5 deletions

View File

@ -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({