Bug 41060: (QA follow-up) Check in change, trigger once in Blur

If we already checked and nothing changes, no need to check again.
Set focus to field if we warn.
For consistency copied these changes to validate_isbn.

Test plan:
Try various valid and invalid ISSNs.
Tab through the field repeatedly; you should only have a warning
once, if the ISSN is invalid (yellow colored).
Save a bad ISSN into a record. Open it again and tab through ISSN;
you should be warned.

Repeat similarly for ISBN field.

Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
This commit is contained in:
Marcel de Rooy 2026-01-16 09:30:14 +01:00 committed by Lucas Gass
parent c3e8b34e6a
commit 76a1dc2dd6
No known key found for this signature in database
GPG Key ID: 60B447398B0D36CA
2 changed files with 20 additions and 8 deletions

View File

@ -30,20 +30,26 @@ my $builder = sub {
return qq|
<script>
function Blur$id(event) {
function Change$id(event) {
field = \$('#'+event.data.id);
isbn = field.val();
var url = '../cataloguing/plugin_launcher.pl?plugin_name=validate_isbn.pl&isbn=' + isbn;
var req = \$.get(url);
req.done(function(resp){
if ( resp != 1 ) {
field.addClass("checked_isbn");
if ( resp == 1 ) field.removeClass("subfield_not_filled");
else {
field.addClass("subfield_not_filled");
field.focus();
alert("Invalid ISBN : " + isbn);
return;
}
field.removeClass("subfield_not_filled");
});
}
function Blur$id(event) {
field = \$('#'+event.data.id);
// when not yet checked (in existing record), trigger change event
if ( !field.hasClass("checked_isbn") ) field.trigger("change");
}
</script>|;
};

View File

@ -30,20 +30,26 @@ my $builder = sub {
return qq|
<script>
function Blur$id(event) {
function Change$id(event) {
field = \$('#'+event.data.id);
issn = field.val();
var url = '../cataloguing/plugin_launcher.pl?plugin_name=validate_issn.pl&issn=' + issn;
var req = \$.get(url);
req.done(function(resp){
if ( resp != 1 ) {
field.addClass("checked_issn");
if ( resp == 1 ) field.removeClass("subfield_not_filled");
else {
field.addClass("subfield_not_filled");
field.focus();
alert("Invalid ISSN : " + issn);
return;
}
field.removeClass("subfield_not_filled");
});
}
function Blur$id(event) {
field = \$('#'+event.data.id);
// when not yet checked (in existing record), trigger change event
if ( !field.hasClass("checked_issn") ) field.trigger("change");
}
</script>|;
};