Bug 29689: (bug 28445 follow-up) Fix AutoBarcode=hbyymmincr
authorJonathan Druart <jonathan.druart@bugs.koha-community.org>
Tue, 14 Dec 2021 11:08:13 +0000 (12:08 +0100)
committerFridolin Somers <fridolin.somers@biblibre.com>
Tue, 4 Jan 2022 07:37:40 +0000 (21:37 -1000)
commit0c8496a85af997a1a5f367d975e252e637c087ce
tree2204bbf075cd9aacb290aa3b4ef61d817c19f0dd
parent3d1556dafa7cd09614f86512cae8fa2e215d9ab7
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!

Signed-off-by: Hayley Pelham <hayleypelham@catalyst.net.nz>
Signed-off-by: Nick Clemens <nick@bywatersolutions.com>
Signed-off-by: Fridolin Somers <fridolin.somers@biblibre.com>
C4/Barcodes/ValueBuilder.pm
cataloguing/value_builder/barcode.pl
cataloguing/value_builder/barcode_manual.pl
koha-tmpl/intranet-tmpl/prog/en/includes/html_helpers.inc
t/db_dependent/Barcodes_ValueBuilder.t