Bug 37357

Summary: Authorised values in control fields cause Javascript errors
Product: Koha Reporter: David Cook <dcook>
Component: MARC Bibliographic data supportAssignee: David Cook <dcook>
Status: Pushed to stable --- QA Contact: Martin Renvoize (ashimema) <martin.renvoize>
Severity: normal    
Priority: P5 - low CC: lucas
Version: Main   
Hardware: All   
OS: All   
Change sponsored?: --- Patch complexity: ---
Documentation contact: Documentation submission:
Text to go in the release notes:
Version(s) released in:
24.11.00,24.05.06
Circulation function:
Attachments: Bug 37357: Map @ to 00 for control field select lists
Bug 37357: Map @ to 00 for control field select lists
Bug 37357: Map @ to 00 for control field select lists

Description David Cook 2024-07-15 03:50:03 UTC
I have a library that uses an authorised value list in one of their MARC control fields, and I notice it causes Javascript errors.

The label will be for tag_001_subfield_00_597551_809285 but the select2 select will have a name and ID of tag_001_subfield_@_597551_809285

In Koha/UI/Form/Builder/Biblio.pm, @ gets rewritten to 00 in some subfield contexts, but not all.

The "id" in the "subfield_data" hash is correct, but sub build_authorized_values_list creates a name/id which uses @ instead.
Comment 1 David Cook 2024-07-15 04:03:55 UTC
Created attachment 168960 [details] [review]
Bug 37357: Map @ to 00 for control field select lists

This change adds the existing @ to 00 mapping for control fields
to work for authorized value select lists as well.

Test plan:
0. Apply the patch
1. koha-plack --reload kohadev
2. Make 001 subfield @ mandatory and give
it an authorised value of branches for Default framework
3. Go to the New record editor for a Default record
4. Click "Save"
5. Note that the editor prompts you to fill in the 001 field
6. Fill in required fields and click "Save"
7. Note that all data is captured correctly
8. prove t/db_dependent/Koha/UI/Form/Builder/Biblio.t

To prove that this wouldn't work without the patch, try the test
plan on a different branch without this patch. You won't be prompted
to fill in mandatory fields and the record will just save (or if a
possible duplicate is detected it will just redirect you back to an empty
editor)
Comment 2 David Nind 2024-07-16 04:25:07 UTC
Created attachment 169036 [details] [review]
Bug 37357: Map @ to 00 for control field select lists

This change adds the existing @ to 00 mapping for control fields
to work for authorized value select lists as well.

Test plan:
0. Apply the patch
1. koha-plack --reload kohadev
2. Make 001 subfield @ mandatory and give
it an authorised value of branches for Default framework
3. Go to the New record editor for a Default record
4. Click "Save"
5. Note that the editor prompts you to fill in the 001 field
6. Fill in required fields and click "Save"
7. Note that all data is captured correctly
8. prove t/db_dependent/Koha/UI/Form/Builder/Biblio.t

To prove that this wouldn't work without the patch, try the test
plan on a different branch without this patch. You won't be prompted
to fill in mandatory fields and the record will just save (or if a
possible duplicate is detected it will just redirect you back to an empty
editor)

Signed-off-by: David Nind <david@davidnind.com>
Comment 3 Martin Renvoize (ashimema) 2024-07-17 15:22:21 UTC
Created attachment 169092 [details] [review]
Bug 37357: Map @ to 00 for control field select lists

This change adds the existing @ to 00 mapping for control fields
to work for authorized value select lists as well.

Test plan:
0. Apply the patch
1. koha-plack --reload kohadev
2. Make 001 subfield @ mandatory and give
it an authorised value of branches for Default framework
3. Go to the New record editor for a Default record
4. Click "Save"
5. Note that the editor prompts you to fill in the 001 field
6. Fill in required fields and click "Save"
7. Note that all data is captured correctly
8. prove t/db_dependent/Koha/UI/Form/Builder/Biblio.t

To prove that this wouldn't work without the patch, try the test
plan on a different branch without this patch. You won't be prompted
to fill in mandatory fields and the record will just save (or if a
possible duplicate is detected it will just redirect you back to an empty
editor)

Signed-off-by: David Nind <david@davidnind.com>
Signed-off-by: Martin Renvoize <martin.renvoize@ptfs-europe.com>
Comment 4 Martin Renvoize (ashimema) 2024-07-17 15:22:38 UTC
Trivial fix, thanks David

Passing QA
Comment 5 Katrin Fischer 2024-07-18 15:57:43 UTC
Pushed for 24.11!

Well done everyone, thank you!
Comment 6 Lucas Gass (lukeg) 2024-11-18 18:22:56 UTC
Backported to 24.05.x for upcoming 24.05.06