Bug 21946: (follow-up) Add optgroup label in circ rules
authorOwen Leonard <oleonard@myacpl.org>
Tue, 28 Jul 2020 13:17:54 +0000 (13:17 +0000)
committerJonathan Druart <jonathan.druart@bugs.koha-community.org>
Thu, 13 Aug 2020 08:13:14 +0000 (10:13 +0200)
This patch adds a label to the optgroup showing child itemtypes in the
circulation and fine rules interface.

The parent itemtype description is the optgroup label, and then the
parent itemtype is repeated as an <option> with the additional label
"All"

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

koha-tmpl/intranet-tmpl/prog/en/modules/admin/smart-rules.tt

index a36daf5..b34d02e 100644 (file)
                     <td>
                         <select name="itemtype" id="matrixitemtype" style="width:13em;">
                             <option value="*">All</option>
-                        [% FOREACH itemtypeloo IN itemtypeloop %]
-                            [% NEXT IF itemtypeloo.parent_type %]
-                            <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
-                            [% SET children = itemtypeloo.children_with_localization %]
-                            [% IF children %]
-                                <optgroup>
-                                [% FOREACH child IN children %]
-                                    <option value="[% child.itemtype | html %]">[% child.translated_description | html %]</option>
+                            [% FOREACH itemtypeloo IN itemtypeloop %]
+                                [% NEXT IF itemtypeloo.parent_type %]
+                                [% SET children = itemtypeloo.children_with_localization %]
+                                [% IF children %]
+                                    <optgroup label="[% itemtypeloo.translated_description | html %]">
+                                        <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %] (All)</option>
+                                        [% FOREACH child IN children %]
+                                            <option value="[% child.itemtype | html %]">[% child.translated_description | html %]</option>
+                                        [% END %]
+                                    </optgroup>
+                                [% ELSE %]
+                                    <option value="[% itemtypeloo.itemtype | html %]">[% itemtypeloo.translated_description | html %]</option>
                                 [% END %]
-                                </optgroup>
                             [% END %]
-                        [% END %]
                         </select>
                     </td>
                     <td class="actions">