Bugzilla – Attachment 128727 Details for
Bug 29689
Update to 21.11 broken auto-generated barcode in <branchcode>0001 option
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 29689: (bug 28445 follow-up) Fix AutoBarcode=hbyymmincr
Bug-29689-bug-28445-follow-up-Fix-AutoBarcodehbyym.patch (text/plain), 5.93 KB, created by
Jonathan Druart
on 2021-12-20 10:21:12 UTC
(
hide
)
Description:
Bug 29689: (bug 28445 follow-up) Fix AutoBarcode=hbyymmincr
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2021-12-20 10:21:12 UTC
Size:
5.93 KB
patch
obsolete
>From 6b2cc48720216d859dec539d4eec30d2747fae3b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 14 Dec 2021 12:08:13 +0100 >Subject: [PATCH] Bug 29689: (bug 28445 follow-up) Fix AutoBarcode=hbyymmincr > >The selector is not correct, we must to not rely on the number. >This patch fixes a regression caused by bug 28445, but also a >long-standing bug. > >* Regression: >The barcode plugin is broken is autoBarcode=<branchcode>yymm0001 >There is a JS error in the console: > Uncaught TypeError: form.field_value is undefined > Focustag_952_subfield_p_878344 > Focustag_952_subfield_p_878344_handler > jQuery 11 > BindEventstag_952_subfield_p_878344 > >* Long standing bug: >If there are several item forms on the same page, the branchcode is not >correctly retrieved. For instance on the "Serial edition" page there are >2 item forms, the homebranch that is used by the barcode plugin will be >the one from the last form. > >Test plan: >* regression >Set autoBarcode=<branchcode>yymm0001 >Catalogue a new item, click into the barcode input >Notice that without this patch you get a JS error in the console > >* long standing bug >Create a new subscription, select "Create an item record when receiving this serial". >Receive a serial >Open the 2 item forms ("Click to add item") >Select 2 different home library and click the barcode inputs. >The prefix (branchcode) should be correct with this patch applied. > >QA Note: it would be way easier if all add item forms were using the new >methods, it could be: > let loc = document.getElementsByName('items.homebranch')[0].value; >Yes, that's all! >--- > C4/Barcodes/ValueBuilder.pm | 26 +++++++------------ > cataloguing/value_builder/barcode.pl | 1 - > cataloguing/value_builder/barcode_manual.pl | 1 - > .../prog/en/includes/html_helpers.inc | 1 + > t/db_dependent/Barcodes_ValueBuilder.t | 2 -- > 5 files changed, 11 insertions(+), 20 deletions(-) > >diff --git a/C4/Barcodes/ValueBuilder.pm b/C4/Barcodes/ValueBuilder.pm >index ea8bffafa37..64a56657800 100644 >--- a/C4/Barcodes/ValueBuilder.pm >+++ b/C4/Barcodes/ValueBuilder.pm >@@ -56,23 +56,17 @@ sub get_barcode { > $nextnum++; > $nextnum = sprintf("%0*d", "4",$nextnum); > $nextnum = $year . $month . $nextnum; >- my $scr = " >- var form = document.getElementById('f'); >- if ( !form ) { >- form = document.getElementById('serials_edit'); >- } >- if ( !form ) { >- form = document.getElementById('Aform'); >- } >- for (i=0 ; i<form.field_value.length ; i++) { >- if (form.tag[i].value == '$args->{loctag}' && form.subfield[i].value == '$args->{locsubfield}') { >- fnum = i; >- } >+ my $scr = qq~ >+ let elt = \$("#"+id); >+ let homebranch = elt.parents('fieldset.rows:first') >+ .find('input[name="kohafield"][value="items.homebranch"]') >+ .siblings("select") >+ .val(); >+ >+ if ( \$(elt).val() == '' ) { >+ \$(elt).val(homebranch + '$nextnum'); > } >- if (\$('#' + id).val() == '') { >- \$('#' + id).val(form.field_value[fnum].value + '$nextnum'); >- } >- "; >+ ~; > return $nextnum, $scr; > } > >diff --git a/cataloguing/value_builder/barcode.pl b/cataloguing/value_builder/barcode.pl >index da1ec86ac98..8fcd45beae8 100755 >--- a/cataloguing/value_builder/barcode.pl >+++ b/cataloguing/value_builder/barcode.pl >@@ -37,7 +37,6 @@ my $builder = sub { > # find today's date > ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); > ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); >- ($args{loctag},$args{locsubfield}) = GetMarcFromKohaField( "items.homebranch" ); > > my $nextnum; > my $scr; >diff --git a/cataloguing/value_builder/barcode_manual.pl b/cataloguing/value_builder/barcode_manual.pl >index a3840bd436e..d2b7f7a4149 100755 >--- a/cataloguing/value_builder/barcode_manual.pl >+++ b/cataloguing/value_builder/barcode_manual.pl >@@ -38,7 +38,6 @@ my $builder = sub { > # find today's date > ($args{year}, $args{mon}, $args{day}) = split('-', output_pref({ dt => dt_from_string, dateformat => 'iso', dateonly => 1 })); > ($args{tag},$args{subfield}) = GetMarcFromKohaField( "items.barcode" ); >- ($args{loctag},$args{locsubfield}) = GetMarcFromKohaField( "items.homebranch" ); > > my $nextnum; > my $scr; >diff --git a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >index 8f148947b49..a2ea6ebd209 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >+++ b/koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc >@@ -148,6 +148,7 @@ > <input type="hidden" name="items.more_subfields_xml" value="[% subfield.subfield | html %]" /> > [% END %] > <input type="hidden" name="tag" value="[% subfield.tag | html %]" /> >+ <input type="hidden" name="kohafield" value="[% subfield.kohafield | html %]" /> [%# We should not need that but all item forms are not rewritten yet %] > <input type="hidden" name="subfield" value="[% subfield.subfield | html %]" /> > <input type="hidden" name="mandatory" value="[% subfield.mandatory | html %]" /> > <input type="hidden" name="important" value="[% subfield.important | html %]" /> >diff --git a/t/db_dependent/Barcodes_ValueBuilder.t b/t/db_dependent/Barcodes_ValueBuilder.t >index f21f140c389..980543afc1f 100755 >--- a/t/db_dependent/Barcodes_ValueBuilder.t >+++ b/t/db_dependent/Barcodes_ValueBuilder.t >@@ -61,8 +61,6 @@ my %args = ( > day => '30', > tag => '952', > subfield => 'p', >- loctag => '952', >- locsubfield => 'a' > ); > > my ($nextnum, $scr) = C4::Barcodes::ValueBuilder::incremental::get_barcode(\%args); >-- >2.25.1
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 29689
:
128480
|
128490
|
128521
|
128727
|
128800
|
128860