Bug 38987 - Cannot link authorities with other authorities
Summary: Cannot link authorities with other authorities
Status: Pushed to main
Alias: None
Product: Koha
Classification: Unclassified
Component: MARC Authority data support (show other bugs)
Version: Main
Hardware: All All
: P5 - low normal
Assignee: Andreas Roussos
QA Contact: Lucas Gass (lukeg)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2025-01-28 15:52 UTC by Andreas Roussos
Modified: 2025-01-30 18:14 UTC (History)
2 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
This fixes adding (or editing) authority terms to authority records (for example, 500$a)- choosing a term using the authority finder was not adding the selected term to the authority record (it was staying on authority finder pop up window, and generated a JavaScript error).
Version(s) released in:
25.05.00
Circulation function:


Attachments
Bug 38987: Use the correct HTML id attribute (2.79 KB, patch)
2025-01-28 16:06 UTC, Andreas Roussos
Details | Diff | Splinter Review
Bug 38987: Use the correct HTML id attribute (2.84 KB, patch)
2025-01-29 11:34 UTC, David Nind
Details | Diff | Splinter Review
Bug 38987: Use the correct HTML id attribute (2.90 KB, patch)
2025-01-29 22:20 UTC, Lucas Gass (lukeg)
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Andreas Roussos 2025-01-28 15:52:14 UTC
Starting with Koha 24.11.01, we can no longer link authorities with
other authorities (linking a bibliographic record with an authority
still works fine). This affects both MARC21 and UNIMARC instances,
and is valid on the main branch, too.
Comment 1 Andreas Roussos 2025-01-28 15:53:41 UTC
Steps to reproduce:

1) Navigate to Koha's Authorities module and create a new authority
   (using the 'Default' authority type). In tab 5, expand field 500
   by clicking on its description.

2) Launch the Authority finder form by clicking on the small 'Tag
   editor' button on the far right of subfield 500$a.

3) Click the yellow 'Search' button at the bottom of the page.
   When the results appear, click on the '+ Choose' button for
   one of the authorities (any authority will do).

   Notice that nothing happens and the Authority finder stays open,
   whereas normally it should close automatically at this point and
   transfer you back to the authority editor, copying the info from
   the authority you selected into the subfields of field 500.

   Press F12 (works in Chrome and Firefox) to launch the Developer
   Tools of your browser and notice that in the JavaScript console
   the following error message has been registered:

   "Uncaught TypeError: e is null"
Comment 2 Andreas Roussos 2025-01-28 15:57:12 UTC
Analysis of the Bug:

Clicking on one of the '+ Choose' buttons actually calls the
doauth() function, defined in

koha-tmpl/intranet-tmpl/prog/en/modules/authorities/searchresultlist-auth.tt:

143         function doauth(authid, index, repet){
144             [% IF source == 'auth' %]
145                 var e = document.getElementById("relationship");
146                 var relationship = e.options[e.selectedIndex].value;
147
148                 jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet + '&relationship=' + relationship);
149             [% ELSE %]
150                 jumpfull('blinddetail-biblio-search.pl?authid=' + authid + '&index=' + index + '&repet=' + repet);
151             [% END %]
152         }

As per the code above, whenever authority-to-authority linking
takes place (source == 'auth'), `e` is the JavaScript variable
assigned to the object/HTML element with an id attribute equal
to 'relationship'. This refers to the 'Special relationship'
dropdown menu that allows you to select a relationship code
before picking an authority with the '+ Choose' button.

Commit a605c070c7 (from Bug 31470) introduced a change to
koha-tmpl/intranet-tmpl/prog/en/includes/auth-finder-search.inc
which renamed the id attribute of the 'Special relationship'
<select> element from 'relationship' to 'special_relationship'.

Therefore the fix for this Bug is trivial, and involves just
a change in the `getElementById()` call. Additionally, to avoid
any confusion regarding the variable name (AIUI `e` is often
used for Event objects), I'm suggesting we rename it to `elem`
(short for 'element').
Comment 3 Andreas Roussos 2025-01-28 16:06:59 UTC
Created attachment 177284 [details] [review]
Bug 38987: Use the correct HTML id attribute

Starting with Koha 24.11.01, we can no longer link authorities with
other authorities (linking a bibliographic record with an authority
still works fine). This affects both MARC21 and UNIMARC instances,
and is valid on the main branch, too.

This patch fixes that.

Test plan:

1) Navigate to Koha's Authorities module and create a new authority
   (using the 'Default' authority type). In tab 5, expand field 500
   by clicking on its description.

2) Launch the Authority finder form by clicking on the small 'Tag
   editor' button on the far right of subfield 500$a.

3) Click the yellow 'Search' button at the bottom of the page.
   When the results appear, click on the '+ Choose' button for
   one of the authorities (any authority will do).

   Notice that nothing happens and the Authority finder stays open,
   whereas normally it should close automatically at this point and
   transfer you back to the authority editor, copying the info from
   the authority you selected into the subfields of field 500.

   Press F12 (works in Chrome and Firefox) to launch the Developer
   Tools of your browser and notice that in the JavaScript console
   the following error message has been registered:

   "Uncaught TypeError: e is null"

4) Apply this patch (and restart_all for good measure), then press
   CTRL-F5 to reload all JS assets.

5) Repeat step 3) above; this time, when you click on the '+ Choose'
   button the authority finder window will close and the contents of
   the authority you selected will be copied into the subfields of
   field 500.
Comment 4 David Nind 2025-01-29 11:34:02 UTC
Created attachment 177310 [details] [review]
Bug 38987: Use the correct HTML id attribute

Starting with Koha 24.11.01, we can no longer link authorities with
other authorities (linking a bibliographic record with an authority
still works fine). This affects both MARC21 and UNIMARC instances,
and is valid on the main branch, too.

This patch fixes that.

Test plan:

1) Navigate to Koha's Authorities module and create a new authority
   (using the 'Default' authority type). In tab 5, expand field 500
   by clicking on its description.

2) Launch the Authority finder form by clicking on the small 'Tag
   editor' button on the far right of subfield 500$a.

3) Click the yellow 'Search' button at the bottom of the page.
   When the results appear, click on the '+ Choose' button for
   one of the authorities (any authority will do).

   Notice that nothing happens and the Authority finder stays open,
   whereas normally it should close automatically at this point and
   transfer you back to the authority editor, copying the info from
   the authority you selected into the subfields of field 500.

   Press F12 (works in Chrome and Firefox) to launch the Developer
   Tools of your browser and notice that in the JavaScript console
   the following error message has been registered:

   "Uncaught TypeError: e is null"

4) Apply this patch (and restart_all for good measure), then press
   CTRL-F5 to reload all JS assets.

5) Repeat step 3) above; this time, when you click on the '+ Choose'
   button the authority finder window will close and the contents of
   the authority you selected will be copied into the subfields of
   field 500.

Signed-off-by: David Nind <david@davidnind.com>
Comment 5 Andreas Roussos 2025-01-29 14:43:55 UTC
Thank you very much, David, for adding the release notes for this!
Comment 6 Lucas Gass (lukeg) 2025-01-29 22:20:51 UTC
Created attachment 177325 [details] [review]
Bug 38987: Use the correct HTML id attribute

Starting with Koha 24.11.01, we can no longer link authorities with
other authorities (linking a bibliographic record with an authority
still works fine). This affects both MARC21 and UNIMARC instances,
and is valid on the main branch, too.

This patch fixes that.

Test plan:

1) Navigate to Koha's Authorities module and create a new authority
   (using the 'Default' authority type). In tab 5, expand field 500
   by clicking on its description.

2) Launch the Authority finder form by clicking on the small 'Tag
   editor' button on the far right of subfield 500$a.

3) Click the yellow 'Search' button at the bottom of the page.
   When the results appear, click on the '+ Choose' button for
   one of the authorities (any authority will do).

   Notice that nothing happens and the Authority finder stays open,
   whereas normally it should close automatically at this point and
   transfer you back to the authority editor, copying the info from
   the authority you selected into the subfields of field 500.

   Press F12 (works in Chrome and Firefox) to launch the Developer
   Tools of your browser and notice that in the JavaScript console
   the following error message has been registered:

   "Uncaught TypeError: e is null"

4) Apply this patch (and restart_all for good measure), then press
   CTRL-F5 to reload all JS assets.

5) Repeat step 3) above; this time, when you click on the '+ Choose'
   button the authority finder window will close and the contents of
   the authority you selected will be copied into the subfields of
   field 500.

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Lucas Gass <lucas@bywatersolutions.com>
Comment 7 Katrin Fischer 2025-01-30 18:01:18 UTC
Reported yesterday, pushed today... not too bad :)
Comment 8 Katrin Fischer 2025-01-30 18:14:21 UTC
Pushed for 25.05!

Well done everyone, thank you!