Bug 31234 - SubfieldsToAllowForRestrictedEditing : data from drop-down menu not stored
Summary: SubfieldsToAllowForRestrictedEditing : data from drop-down menu not stored
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: Main
Hardware: All All
: P5 - low major (vote)
Assignee: Fridolin Somers
QA Contact: Kyle M Hall
URL:
Keywords:
Depends on: 28445
Blocks:
  Show dependency treegraph
 
Reported: 2022-07-25 09:08 UTC by pierre.genty
Modified: 2023-12-28 20:42 UTC (History)
6 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Trivial patch
Documentation contact:
Documentation submission:
Text to go in the release notes:
Version(s) released in:
22.11.00, 22.05.07, 21.11.14


Attachments
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored (2.29 KB, patch)
2022-07-26 20:51 UTC, Fridolin Somers
Details | Diff | Splinter Review
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored (2.34 KB, patch)
2022-09-11 18:41 UTC, David Nind
Details | Diff | Splinter Review
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored (2.40 KB, patch)
2022-09-30 13:51 UTC, Kyle M Hall
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description pierre.genty 2022-07-25 09:08:20 UTC
1. A librarian with edit_items_restricted permission set
2. Item subfield not authorized for editing (SubfieldsToAllowForRestrictedEditing). In Marc framework, this subfield is linked to an authorized value (= drop-down menu)
3. When adding/editing item, this subfield has a default value from drop-down menu and is not editable (OK). 
4. Once item is saved, the subfield is empty : it should have the default value from drop-down menu.
Comment 1 Fridolin Somers 2022-07-26 20:34:23 UTC
This comes from a change by Bug 28445 in items edition form :
  <select name="field_value"
change to :
  <select name="[% kohafield | html %]" 

This breaks the special JS code :
https://git.koha-community.org/Koha-community/Koha/src/commit/fc919fc796df42c29e73cd527d3c425377fcc27a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js#L112

I propose we use "select.input_marceditor".
Comment 2 Fridolin Somers 2022-07-26 20:45:53 UTC
Item restricted edition dates back to Bug 7673
Comment 3 Fridolin Somers 2022-07-26 20:51:09 UTC
Created attachment 138145 [details] [review]
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored

Problem with items restricted edition, restriced fields with a drop-down
menu are not stored, since 21.11.

This comes from a change by Bug 28445 in items edition form :
  <select name="field_value"
change to :
  <select name="[% kohafield | html %]"

This breaks the special JS code :
https://git.koha-community.org/Koha-community/Koha/src/commit/fc919fc796df42c29e73cd527d3c425377fcc27a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js#L112

I propose we use "select.input_marceditor".

Test plan :
1. A librarian with 'edit_items_restricted' permission set
2. Item subfield not authorized for editing (SubfieldsToAllowForRestrictedEditing). In Marc framework, this subfield is linked to an authorized value (= drop-down menu). For exemple homebranch.
3. When adding/editing item, this subfield has a default value from drop-down menu and is not editable (OK).
4. Save item
=> Without patch : the subfield is empty, it should have the value from drop-down menu.
=> With patch : the subfield is saved with the value from drop-down menu.
Comment 4 Fridolin Somers 2022-07-26 20:56:27 UTC
Important /!\ :

There are other places with JS calling 'field_value', we should check if there are other bugs :

 > git grep 'name..field_value'
 > git grep 'name..field_value' -- koha-tmpl/
koha-tmpl/intranet-tmpl/prog/en/modules/acqui/addorderiso2709.tt:                                                                        <select name="field_value" class="input_marceditor">
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt:                        <input type="hidden" name="field_value" value="[% authid | html %]" />
koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt:                        <input type="hidden" name="field_value" value="[% authtypecode | html %]" />
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:    if(! $(subfield_div).children("input[type='text'][name='field_value']").val() ){
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:        $(subfield_div).children("input[type='text'][name='field_value']").val($("#serialseq" + serialId).val());
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:                  <select name="field_value" class="select2 input_marceditor">
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:        <input type="hidden" name="field_value" value="[% item.itemnumber | html %]" />
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:                  <select name="field_value">
koha-tmpl/intranet-tmpl/prog/en/modules/serials/serials-edit.tt:        <input type="hidden" name="field_value" value="[% newserialloo.itemnumber | html %]" />
koha-tmpl/intranet-tmpl/prog/en/modules/services/itemrecorddisplay.tt:        <select name="field_value" class="input_marceditor">
koha-tmpl/intranet-tmpl/prog/en/modules/tools/marc_modification_templates.tt:                                    with value <input type="text" name="field_value" id="field_value" />
koha-tmpl/intranet-tmpl/prog/js/additem.js:            .prevAll("[name='field_value']")[0];
koha-tmpl/intranet-tmpl/prog/js/additem.js:            $(original).find("input[name='field_value']").each(function(){
koha-tmpl/intranet-tmpl/prog/js/additem.js:                    $(clone).find("div[id^='"+id+"'] input[name='field_value']").val(value);
koha-tmpl/intranet-tmpl/prog/js/additem.js:            $(original).find("select[name='field_value']").each(function(){
koha-tmpl/intranet-tmpl/prog/js/additem.js:                    $(clone).find("div[id^='"+id+"'] select[name='field_value']").val(value);
koha-tmpl/intranet-tmpl/prog/js/additem.js:            var input = $(this).prevAll("input[name='field_value']")[0];
Comment 5 Fridolin Somers 2022-07-26 21:05:01 UTC
BTW : 
The system preference 'SubfieldsToAllowForRestrictedEditing' edition is quite strange, why enter itemsfield 952/995 when it is obvious.
Could be simply subfields separated with a comma : a,b,c
Comment 6 Katrin Fischer 2022-08-21 22:09:46 UTC
(In reply to Fridolin Somers from comment #5)
> BTW : 
> The system preference 'SubfieldsToAllowForRestrictedEditing' edition is
> quite strange, why enter itemsfield 952/995 when it is obvious.
> Could be simply subfields separated with a comma : a,b,c

In theory someone could have changed the item subfield and used something else... we'd never recommend to do that, but I guess it might be the case or was thought to be an option when the preference was added.
Comment 7 David Nind 2022-09-11 18:41:44 UTC
Created attachment 140410 [details] [review]
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored

Problem with items restricted edition, restriced fields with a drop-down
menu are not stored, since 21.11.

This comes from a change by Bug 28445 in items edition form :
  <select name="field_value"
change to :
  <select name="[% kohafield | html %]"

This breaks the special JS code :
https://git.koha-community.org/Koha-community/Koha/src/commit/fc919fc796df42c29e73cd527d3c425377fcc27a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js#L112

I propose we use "select.input_marceditor".

Test plan :
1. A librarian with 'edit_items_restricted' permission set
2. Item subfield not authorized for editing (SubfieldsToAllowForRestrictedEditing). In Marc framework, this subfield is linked to an authorized value (= drop-down menu). For exemple homebranch.
3. When adding/editing item, this subfield has a default value from drop-down menu and is not editable (OK).
4. Save item
=> Without patch : the subfield is empty, it should have the value from drop-down menu.
=> With patch : the subfield is saved with the value from drop-down menu.

Signed-off-by: David Nind <david@davidnind.com>
Comment 8 Kyle M Hall 2022-09-30 13:51:56 UTC
Created attachment 141156 [details] [review]
Bug 31234: SubfieldsToAllowForRestrictedEditing - data from drop-down menu not stored

Problem with items restricted edition, restriced fields with a drop-down
menu are not stored, since 21.11.

This comes from a change by Bug 28445 in items edition form :
  <select name="field_value"
change to :
  <select name="[% kohafield | html %]"

This breaks the special JS code :
https://git.koha-community.org/Koha-community/Koha/src/commit/fc919fc796df42c29e73cd527d3c425377fcc27a/koha-tmpl/intranet-tmpl/prog/js/cataloging_additem.js#L112

I propose we use "select.input_marceditor".

Test plan :
1. A librarian with 'edit_items_restricted' permission set
2. Item subfield not authorized for editing (SubfieldsToAllowForRestrictedEditing). In Marc framework, this subfield is linked to an authorized value (= drop-down menu). For exemple homebranch.
3. When adding/editing item, this subfield has a default value from drop-down menu and is not editable (OK).
4. Save item
=> Without patch : the subfield is empty, it should have the value from drop-down menu.
=> With patch : the subfield is saved with the value from drop-down menu.

Signed-off-by: David Nind <david@davidnind.com>

Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com>
Comment 9 Tomás Cohen Arazi 2022-10-03 16:53:19 UTC
Pushed to master for 22.11.

Nice work everyone, thanks!
Comment 10 Fridolin Somers 2022-10-27 23:29:18 UTC
This must be backported to untill 21.11.x right ?
Comment 11 Lucas Gass 2022-11-04 20:56:05 UTC
Backported to 22.05.x for upcoming 22.05.07 release
Comment 12 Arthur Suzuki 2022-11-15 17:08:34 UTC
applied to 21.11 for 21.11.14
Comment 13 Victor Grousset/tuxayo 2022-11-27 00:05:42 UTC
Missing dependencies for 21.05.x, it shouldn't be affected, no backport.

Nothing to document it seems, marking resolved.