Bug 28853 - Textarea in biblio record editor breaks authority plugin
Summary: Textarea in biblio record editor breaks authority plugin
Status: RESOLVED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2021-08-12 20:29 UTC by Fridolin Somers
Modified: 2021-12-22 21:37 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Text to go in the release notes:
This fixes an issue when adding or editing record subfields using the authority plugin and it has a value with more than 100 characters. (When a subfield has more than 100 characters it changes to a text area rather than a standard input field, this caused JavaScript issues when using authority terms over 100 characters.)
Version(s) released in:
22.05.00,21.11.01,21.05.08


Attachments
Bug 28853: Fix authority plugin when textarea in biblio record editor (2.69 KB, patch)
2021-08-12 20:53 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 28853: Fix authority plugin when textarea in biblio record editor (2.75 KB, patch)
2021-11-05 09:30 UTC, Florian
Details | Diff | Splinter Review
Bug 28853: Fix authority plugin when textarea in biblio record editor (2.83 KB, patch)
2021-12-02 13:26 UTC, Jonathan Druart
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Fridolin Somers 2021-08-12 20:29:17 UTC
In biblio record editor, when subfield value contains more than 100 characters the editor uses a textarea instead of an input.
On a field using authority plugin, this breaks the JavaScript because it only searches for input tags :
In /koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt :
> this.getElementsByTagName('input')[1].value = values[i];
Comment 1 Fridolin Somers 2021-08-12 20:52:51 UTC
BTW :

This JavaScript code is a mix of JQuery and old style.
It seams it is not very solid and several parts are repeated, like :
> var re = new RegExp('^subfield' + subfield_name,'g');
> var subfields = $(field_start).children('ul').children('li').filter( function() {
>   return this.id.match(re);
> });
This would need a big revamping.
Comment 2 Fridolin Somers 2021-08-12 20:53:18 UTC
Created attachment 123819 [details] [review]
Bug 28853: Fix authority plugin when textarea in biblio record editor

In biblio record editor, when subfield value contains more than 100 characters the editor uses a textarea instead of an input.
On a field using authority plugin, this breaks the JavaScript because it only searches for input tags :
In /koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt :
> this.getElementsByTagName('input')[1].value = values[i];

Test plan :
1) Prepare :
1.1) Create a new biblio record this a field using authority plugin, for example 606
1.2) Do not use authority plugin but enter in 606$x more than 100 chars
1.3) Save record
1.4) Create a new autority for 606 biblio field with $a and a $x containing more than 100 chars
2) Test 1 :
2.1) Edit again the biblio record, you see a text area for 606$x
2.2) Use authority plugin on field 606
2.3) Search and choose the new autority
2.4) Check $a,$x and $9 are well filled
3) Test 2 :
3.1) Empty field 606
3.2) Create a second $x subfield and fill it with a random value
3.3) Use authority plugin again on field 606
3.4) Search and choose the new autority
3.5) Check $a and $9 are well filled
3.6) Check first $x contains the value from autority and second $x is empty
Comment 3 Florian 2021-11-05 09:30:03 UTC
Created attachment 127348 [details] [review]
Bug 28853: Fix authority plugin when textarea in biblio record editor

In biblio record editor, when subfield value contains more than 100 characters the editor uses a textarea instead of an input.
On a field using authority plugin, this breaks the JavaScript because it only searches for input tags :
In /koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt :
> this.getElementsByTagName('input')[1].value = values[i];

Test plan :
1) Prepare :
1.1) Create a new biblio record with a field using authority plugin, for example 606
1.2) Do not use authority plugin but enter in 606$x more than 100 chars
1.3) Save record
1.4) Create a new autority for 606 biblio field with $a and a $x containing more than 100 chars
2) Test 1 :
2.1) Edit again the biblio record, you see a text area for 606$x
2.2) Use authority plugin on field 606
2.3) Search and choose the new autority
2.4) Check $a,$x and $9 are well filled
3) Test 2 :
3.1) Empty field 606
3.2) Create a second $x subfield and fill it with a random value
3.3) Use authority plugin again on field 606
3.4) Search and choose the new autority
3.5) Check $a and $9 are well filled
3.6) Check first $x contains the value from autority and second $x is empty

Signed-off-by: Florian Bontemps <florian.bontemps@biblibre.com>
Comment 4 Florian 2021-11-05 09:31:09 UTC
I know Fridolin and i work in the same company but this patch has gone unattended for a couple months now.

Feel free to ask for another signoff if needed.
Comment 5 Jonathan Druart 2021-12-02 13:26:23 UTC
Created attachment 128161 [details] [review]
Bug 28853: Fix authority plugin when textarea in biblio record editor

In biblio record editor, when subfield value contains more than 100 characters the editor uses a textarea instead of an input.
On a field using authority plugin, this breaks the JavaScript because it only searches for input tags :
In /koha-tmpl/intranet-tmpl/prog/en/modules/authorities/blinddetail-biblio-search.tt :
> this.getElementsByTagName('input')[1].value = values[i];

Test plan :
1) Prepare :
1.1) Create a new biblio record with a field using authority plugin, for example 606
1.2) Do not use authority plugin but enter in 606$x more than 100 chars
1.3) Save record
1.4) Create a new autority for 606 biblio field with $a and a $x containing more than 100 chars
2) Test 1 :
2.1) Edit again the biblio record, you see a text area for 606$x
2.2) Use authority plugin on field 606
2.3) Search and choose the new autority
2.4) Check $a,$x and $9 are well filled
3) Test 2 :
3.1) Empty field 606
3.2) Create a second $x subfield and fill it with a random value
3.3) Use authority plugin again on field 606
3.4) Search and choose the new autority
3.5) Check $a and $9 are well filled
3.6) Check first $x contains the value from autority and second $x is empty

Signed-off-by: Florian Bontemps <florian.bontemps@biblibre.com>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
Comment 6 Fridolin Somers 2021-12-03 07:07:37 UTC
Pushed to master for 22.05, thanks to everybody involved!
Comment 7 Kyle M Hall 2021-12-03 15:20:23 UTC
Pushed to 21.11.x for 21.11.01
Comment 8 Andrew Fuerste-Henry 2021-12-17 19:31:27 UTC
Pushed to 21.05.x for 21.05.08
Comment 9 Victor Grousset/tuxayo 2021-12-22 21:37:45 UTC
Not backported to oldoldstable (20.11.x). Feel free to ask if it's needed.