Bug 31234 - SubfieldsToAllowForRestrictedEditing : data from drop-down menu not stored
Summary: SubfieldsToAllowForRestrictedEditing : data from drop-down menu not stored
Status: Signed Off
Alias: None
Product: Koha
Classification: Unclassified
Component: Cataloging (show other bugs)
Version: master
Hardware: All All
: P5 - low major (vote)
Assignee: Fridolin Somers
QA Contact: Testopia
URL:
Keywords:
Depends on: 28445
Blocks:
  Show dependency treegraph
 
Reported: 2022-07-25 09:08 UTC by pierre.genty
Modified: 2022-09-11 18:41 UTC (History)
2 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:


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

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>