Bug 31718: Change the IF ELSE values in marc_subfields_structure breadcrumbs to facil...
[koha-ffzg.git] / koha-tmpl / intranet-tmpl / prog / en / modules / admin / marc_subfields_structure.tt
index 9a0c388..c47840b 100644 (file)
 [% USE Asset %]
 [% SET footerjs = 1 %]
 [% INCLUDE 'doc-head-open.inc' %]
-<title>Koha &rsaquo; Administration &rsaquo;[% IF ( add_form ) %][% IF ( use_heading_flags_p ) %][% IF ( heading_edit_subfields_p ) %] MARC subfield structure &rsaquo; Edit MARC subfields constraints[% END %][% ELSE %] MARC subfield structure &rsaquo; [% action | html %][% END %][% END %]
-[% IF ( delete_confirm ) %] MARC subfield structure &rsaquo; Confirm deletion of subfield [% tagsubfield | html %][% END %][% IF ( delete_confirmed ) %] MARC subfield structure &rsaquo; Subfield deleted[% END %][% IF ( else ) %]MARC subfield structure[% END %]</title>
+<title>
+    [%- IF ( add_form ) -%]
+        [%- IF ( use_heading_flags_p ) -%]
+            [%- IF ( heading_edit_subfields_p ) -%]
+                Edit MARC subfields constraints &rsaquo; MARC subfield structure
+            [%- END -%]
+
+        [%- ELSE -%]
+            [%- action | html -%] &rsaquo; MARC subfield structure
+        [%- END -%]
+
+    [%- END -%]
+
+    [%- IF ( delete_confirm ) -%]
+
+        MARC subfield structure &rsaquo; Confirm deletion of subfield [%- mss.tagsubfield | html -%]
+
+        Confirm deletion of subfield [%- tagsubfield | html -%] &rsaquo; MARC subfield structure
+    [%- END -%]
+
+    [%- IF ( delete_confirmed ) -%]
+        Subfield deleted &rsaquo; MARC subfield structure
+
+    [%- END -%]
+
+    [%- IF ( else ) -%]
+        MARC subfield structure
+    [%- END -%] &rsaquo; Administration &rsaquo; Koha
+</title>
 [% INCLUDE 'doc-head-close.inc' %]
+<style>.constraints::after { content:  " "; clear: both; display:block; }</style>
 </head>
 
 <body id="admin_marc_subfields_structure" class="admin">
-[% INCLUDE 'header.inc' %]
-[% INCLUDE 'prefs-admin-search.inc' %]
-
-<div id="breadcrumbs">
-  <a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a> &rsaquo; <a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC frameworks</a> &rsaquo; <a href="/cgi-bin/koha/admin/marctagstructure.pl?frameworkcode=[% frameworkcode | html %]&amp;searchfield=[% tagfield | uri %]">[% IF ( frameworkcode ) %][% frameworkcode | html %][% ELSE %]Default[% END %] framework structure</a> &rsaquo;
-  [% IF ( add_form ) %]
-  [% IF ( use_heading_flags_p ) %]
-  [% IF ( heading_edit_subfields_p ) %] <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Tag [% tagfield | html %] subfield structure</a> &rsaquo; Edit subfields constraints
-  [% END %]
-  [% ELSE %] <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Tag [% tagfield | html %] Subfield structure</a> &rsaquo; [% action | html %]
-  [% END %]
-  [% END %]
-[% IF ( delete_confirm ) %] <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Tag [% tagfield | html %] Subfield structure</a> &rsaquo; Confirm deletion of subfield [% tagsubfield | html %]
-[% END %]
-[% IF ( delete_confirmed ) %] <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Tag [% tagfield | html %] subfield structure</a> &rsaquo; Subfield deleted
+    [% WRAPPER 'header.inc' %]
+    [% INCLUDE 'prefs-admin-search.inc' %]
 [% END %]
-[% IF ( else ) %]Tag [% tagfield | html %] Subfield structure[% END %]
-</div>
-
-<div class="main container-fluid">
-    <div class="row">
-        <div class="col-sm-10 col-sm-push-2">
-            <main>
-
-[% IF ( add_form ) %]
-    <h1>
-        [% IF ( use_heading_flags_p ) %]
-            [% IF ( heading_edit_subfields_p ) %]Tag [% tagfield | html %] Subfield constraints[% END %]
-        [% ELSE %]
-            [% action | html %]
-        [% END %]
-    </h1>
-    <form action="[% script_name | html %]" name="Aform" method="post">
-    <input type="hidden" name="op" value="add_validate" />
-    <input type="hidden" name="tagfield" value="[% tagfield | html %]" />
-    <input type="hidden" name="frameworkcode" value="[% frameworkcode | html %]" />
-    <div id="subfieldtabs" class="toptabs numbered">
-   <ul>
-        [% FOREACH loo IN loop %]
-            [% IF ( loo.new_subfield ) %]
-                <li><a href="#sub[% loo.urisubfieldcode | html %]field" title="[% loo.liblibrarian | html_entity %]">New</a></li>
-            [% ELSE %]
-                <li><a href="#sub[% loo.urisubfieldcode | html %]field" title="[% loo.liblibrarian | html_entity %]">
-                    [% loo.subfieldcode | html %]
-               </a></li>
-            [% END %]
-        [% END %]
-    </ul>
-    
-    [% FOREACH loo IN loop %] 
-        <div class="constraints" id="sub[% loo.urisubfieldcode | html %]field">
-
-               <h3><a href="#basic[% loo.urisubfieldcode | html %]">Basic constraints</a></h3>
-                    <div id="basic[% loo.urisubfieldcode | html %]">
-                    <fieldset class="rows">
-                       <ol>
-                               [% IF ( subfieldcode == 0 || subfieldcode ) %] 
-                               <li><span class="label">Subfield code:</span> [% loo.subfieldcode | html %] <input type="hidden" name="tagsubfield" value="[% loo.subfieldcode | html %]" /></li>
-                               [% ELSE %]
-                               <li><label for="tagsubfield[% loo.row | html %]">Subfield code:</label> <input type="text" id="tagsubfield[% loo.row | html %]" name="tagsubfield" value="[% loo.subfieldcode | html %]" /></li>
-                               [% END %]
-                        <li><label for="liblibrarian[% loo.row | html %]">Text for librarian: </label><input id="liblibrarian[% loo.row | html %]" type="text" name="liblibrarian" value="[% loo.liblibrarian | html_entity %]" size="40" maxlength="80" /></li>
-                        <li><label for="libopac[% loo.row | html %]">Text for OPAC: </label><input type="text" id="libopac[% loo.row | html %]" name="libopac" value="[% loo.libopac | html_entity %]" size="40" maxlength="80" /></li>
+
+    [% WRAPPER 'sub-header.inc' %]
+    <nav id="breadcrumbs" aria-label="Breadcrumb" class="breadcrumb">
+        <ol>
+            <li>
+                <a href="/cgi-bin/koha/mainpage.pl">Home</a>
+            </li>
+            <li>
+                <a href="/cgi-bin/koha/admin/admin-home.pl">Administration</a>
+            </li>
+            <li>
+                <a href="/cgi-bin/koha/admin/biblio_framework.pl">MARC frameworks</a>
+            </li>
+            <li>
+                <a href="/cgi-bin/koha/admin/marctagstructure.pl?frameworkcode=[% frameworkcode | uri %]&amp;searchfield=[% tagfield | uri %]">
+                    [% IF ( frameworkcode ) %]
+                        <span>[% frameworkcode | html %] framework structure</span>
+                    [% ELSE %]
+                        <span>Default framework structure</span>
+                    [% END %]
+                </a>
+            </li>
+
+            [% IF ( add_form ) %]
+                [% IF ( use_heading_flags_p ) %]
+                    [% IF ( heading_edit_subfields_p ) %]
                         <li>
-                            <label for="repeatable[% loo.row | html %]">Repeatable: </label>
-                            [% IF loo.repeatable %]
-                                <input type="checkbox" id="repeatable[% loo.row | html %]" name="repeatable[% loo.row | html %]" checked="checked" value="1" />
-                            [% ELSE %]
-                                <input type="checkbox" id="repeatable[% loo.row | html %]" name="repeatable[% loo.row | html %]" value="1" />
-                            [% END %]
+                            <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]">Tag [% tagfield | html %] subfield structure</a>
                         </li>
                         <li>
-                            <label for="mandatory[% loo.row | html %]">Mandatory: </label>
-                            [% IF loo.mandatory %]
-                                <input type="checkbox" id="mandatory[% loo.row | html %]" name="mandatory[% loo.row | html %]" checked="checked" value="1" />
-                            [% ELSE %]
-                                <input type="checkbox" id="mandatory[% loo.row | html %]" name="mandatory[% loo.row | html %]" value="1" />
-                            [% END %]
-                        </li>
-                        <li><label for="tab[% loo.row | html %]">Managed in tab: </label>
-                            <select name="tab" tabindex="" size="1" id="tab[% loo.row | html %]">
-                            [%- IF ( loo.tab ==  -1 ) -%]
-                                <option value="-1" selected="selected">ignore</option>
-                            [%- ELSE -%]
-                                <option value="-1">ignore</option>
-                            [%- END -%]
-                            [%- FOREACH t IN [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] -%]
-                                [%- IF ( loo.tab ==  t ) -%]
-                                <option value="[%- t | html -%]" selected="selected">[%- t | html -%]</option>
-                                [%- ELSE -%]
-                                <option value="[%- t | html -%]">[%- t | html -%]</option>
-                                [%- END -%]
-                            [%- END -%]
-                            [%- IF ( loo.tab ==  10 ) -%]
-                                <option value="10" selected="selected">items (10)</option>
-                            [%- ELSE -%]
-                                <option value="10">items (10)</option>
-                            [%- END -%]
-                            </select>
-                            (ignore means that the subfield does not display in the record editor)
+                            <a href="#" aria-current="page">
+                                Edit subfields constraints
+                            </a>
                         </li>
-                       </ol>
-                    </fieldset>
-                    </div>
-
-
-            <h3><a href="#advanced[% loo.urisubfieldcode | html %]">Advanced constraints</a></h3>
-            <div id="advanced[% loo.urisubfieldcode | html %]">
-            <fieldset class="rows">
-                <ol><li><label for="defaultvalue[% loo.row | html %]">Default value:</label>
-                    <input type="text" name="defaultvalue" id="defaultvalue[% loo.row | html %]" value="[% loo.defaultvalue | html %]" /></li>
-                               <li><label for="maxlength[% loo.row | html %]">Max length:</label><input type="text" id="maxlength[% loo.row | html %]" name="maxlength" value="[% loo.maxlength | html %]" size="4" /> (see online help)</li>
-                <li><input type="hidden" id="hidden-[% loo.row | html %]" name="hidden" value="[% loo.hidden | html %]" />
-                    <label for="hidden[% loo.row | html %]" style="float: none;">Visibility: </label>
-                    <input type="checkbox" id="hidden_opac_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_opac_[% loo.row | html %]"/>
-                    <label for="hidden_opac_[% loo.row | html %]" style="float: none;">OPAC</label>
-                    <input type="checkbox" id="hidden_intranet_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_intranet_[% loo.row | html %]"/>
-                    <label for="hidden_intranet_[% loo.row | html %]" style="float: none;">Intranet</label>
-                    <input type="checkbox" id="hidden_editor_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_editor_[% loo.row | html %]"/>
-                    <label for="hidden_editor_[% loo.row | html %]" style="float: none;">Editor</label>
-                    <input type="checkbox" id="hidden_collapsed_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_collapsed_[% loo.row | html %]"/>
-                    <label for="hidden_collapsed_[% loo.row | html %]" style="float: none;">Collapsed</label>
-                    <input type="checkbox" id="hidden_flagged_[% loo.row | html %]" name="flagged_[% loo.row | html %]"/>
-                    <label for="hidden_flagged_[% loo.row | html %]" style="float: none;">Flagged</label>
+                    [% END %]
+                [% ELSE %]
+                    <li>
+                        <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]">Tag [% tagfield | html %] Subfield structure</a>
+                    </li>
+                    <li>
+                        <a href="#" aria-current="page">
+                            [% action | html %]
+                        </a>
+                    </li>
+                [% END %]
+            [% END %]
+
+            [% IF ( delete_confirm ) %]
+                <li>
+                    <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% mss.tagfield | uri %]&amp;frameworkcode=[% mss.frameworkcode | uri %]">Tag [% mss.tagfield | html %] Subfield structure</a>
                 </li>
                 <li>
-                    <label for="isurl[% loo.row | html %]">Is a URL:</label>
-                    [% IF loo.isurl %]
-                        <input type="checkbox" id="isurl[% loo.row | html %]" name="isurl[% loo.row | html %]" checked="checked" value="1" />
-                    [% ELSE %]
-                        <input type="checkbox" id="isurl[% loo.row | html %]" name="isurl[% loo.row | html %]" value="1" />
-                    [% END %]
-                    (if checked, it means that the subfield is a URL and can be clicked)
+                    <a href="#" aria-current="page">
+                        Confirm deletion of subfield [% mss.tagsubfield | html %]
+                    </a>
                 </li>
-                <li><label for="link[% loo.row | html %]">Link:</label><input type="text" id="link[% loo.row | html %]" name="link" value="[% loo.link | html %]" size="10" maxlength="80" /> (e.g., Title or Local-Number) <span class="error"><em>NOTE: If you change this value you must ask your administrator to run misc/batchRebuildBiblioTables.pl.</em></span></li>
+            [% END %]
+
+            [% IF ( else ) %]
                 <li>
-                    <label for="kohafield[% loo.row | html %]">Koha link:</label>
-                    <!-- This select should be DISABLED; value is submitted by the following hidden input -->
-                    <select name="kohafield" id="kohafield[% loo.row | html %]" size="1" disabled>
-                    [% FOREACH value IN loo.kohafields %]
-                      [% IF ( value == loo.kohafield ) %]
-                        <option value="[% value | html %]" selected="selected">[% value | html %]</option>
-                      [% ELSE %]
-                        <option value="[% value | html %]">[% value | html %]</option>
-                      [% END %]
-                    [% END %]
-                    </select>
-                    <!-- Do NOT remove this next hidden input! We need it to save kohafield. -->
-                    <input type="hidden" name="kohafield" value="[% loo.kohafield | html %]"/>
+                    <a href="#" aria-current="page">
+                        Tag [% tagfield | html %] Subfield structure
+                    </a>
                 </li>
-                       </ol>
-            </fieldset>
-            </div>
-            <h3><a href="#oth[% loo.urisubfieldcode | html %]">Other options (choose one)</a></h3>
-            <div id="oth[% loo.urisubfieldcode | html %]">
-            <fieldset class="rows">
-                       <ol>
-                            <li>
-                                <label for="authorised_value[% loo.row | html %]">Authorized value:</label>
-                                <select name="authorised_value" id="authorised_value[% loo.row | html %]" size="1">
-                                <option value=""></option>
-                                [% FOREACH value IN loo.authorised_values %]
-                                    [% IF ( value == loo.authorised_value ) %]
-                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
-                                    [% ELSE %]
-                                    <option value="[% value | html %]">[% value | html %]</option>
-                                    [% END %]
-                                [% END %]
-                                </select>
-                            </li>
-                            <li>
-                                <label for="authtypecode[% loo.row | html %]">Thesaurus:</label>
-                                <select name="authtypecode" id="authtypecode[% loo.row | html %]" size="1">
-                                [% FOREACH value IN loo.authtypes %]
-                                    [% IF ( value == loo.authtypecode ) %]
-                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
-                                    [% ELSE %]
-                                    <option value="[% value | html %]">[% value | html %]</option>
-                                    [% END %]
+            [% END %]
+        </ol>
+    </nav> <!-- /#breadcrumbs -->
+    [% END %]
+
+    <div class="main container-fluid">
+        <div class="row">
+            <div class="col-sm-10 col-sm-push-2">
+                <main>
+
+                    [% IF ( add_form ) %]
+                        <h1>
+                            [% IF ( use_heading_flags_p ) %]
+                                [% IF ( heading_edit_subfields_p ) %]<span>Tag</span> [% tagfield | html %] <span>Subfield constraints</span>[% END %]
+                            [% ELSE %]
+                                [% action | html %]
+                            [% END %]
+                        </h1>
+
+                        <form action="[% script_name | html %]" name="Aform" method="post">
+                            <input type="hidden" name="op" value="add_validate" />
+                            <input type="hidden" name="tagfield" value="[% tagfield | html %]" />
+                            <input type="hidden" name="frameworkcode" value="[% frameworkcode | html %]" />
+
+                            [% BLOCK outputsubfield %][% FILTER collapse %]
+                                [% SWITCH ( subfieldanchor ) %]
+                                    [%   CASE "@" %]
+                                    AT
+                                    [%   CASE "%" %]
+                                    %
+                                    [%   CASE  %]
+                                    [% subfieldanchor | html %]
                                 [% END %]
-                                </select>
-                            </li>
-                            <li>
-                                <label for="value_builder[% loo.row | html %]">Plugin:</label>
-                                <select name="value_builder" id="value_builder[% loo.row | html %]" size="1">
-                                [% FOREACH value IN loo.value_builders %]
-                                    [% IF ( value == loo.value_builder ) %]
-                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
-                                    [% ELSE %]
-                                    <option value="[% value | html %]">[% value | html %]</option>
+                            [% END %][% END %]
+
+                            <div id="subfieldtabs" class="toptabs numbered">
+                                 <ul class="nav nav-tabs" role="tablist">
+                                    [% FOREACH loo IN loop %]
+                                        <li id="tab_subfield_[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]" class="tab-item" role="presentation">
+                                            [% IF ( loo.new_subfield ) %]
+                                                <a href="#sub[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]field" aria-controls="sub[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]field" role="tab" data-toggle="tab" title="[% loo.liblibrarian | html_entity %]">New</a>
+                                            [% ELSE %]
+                                                <a href="#sub[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]field" aria-controls="sub[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]field" role="tab" data-toggle="tab" title="[% loo.liblibrarian | html_entity %]">
+                                                    [% loo.subfieldcode | html %]
+                                                </a>
+                                            [% END %]
+                                        </li>
                                     [% END %]
-                                [% END %]
-                                </select>
-                            </li>
-                       </ol>
-            </fieldset>
-            </div>
-        </div><!-- /content_sub -->
-        [% END %]
-               </div><!-- /content -->
-    <fieldset class="action">
-        <input type="submit" value="Save changes" /> <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield  | uri %]&amp;frameworkcode=[% frameworkcode | html %]" class="cancel">Cancel</a>
-    </fieldset>
-    </form>
-[% END %]
+                                </ul>
 
-[% IF ( delete_confirm ) %]
+                                <div class="tab-content">
 
-    <div class="dialog alert">
-        <h3>Confirm deletion of subfield [% tagsubfield | html %]?</h3>
-        <p>Subfield: [% tagsubfield | html %]</p>
-        <p>Description: [% liblibrarian | html_entity %]</p>
+                                    [% FOREACH loo IN loop %]
+                                        <div class="constraints tab-pane" role="tabpanel" id="sub[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]field">
+                                            <input type="hidden" name="tab_id" value="[% loo.row | html %]" />
+                                            <div id="basic[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]" class="contraints">
+                                                <fieldset class="rows">
+                                                    <legend>Basic constraints</legend>
+                                                    <ol>
+                                                        [% IF ( loo.subfieldcode == 0 || loo.subfieldcode ) %]
+                                                            <li>
+                                                                <span class="label">Subfield code:</span>
+                                                                [% loo.subfieldcode | html %]
+                                                                <input type="hidden" id="tagsubfield[% loo.row | html %]" name="tagsubfield" value="[% loo.subfieldcode | html %]" />
+                                                            </li>
+                                                        [% ELSE %]
+                                                            <li>
+                                                                <label for="tagsubfield[% loo.row | html %]">Subfield code:</label>
+                                                                    <input type="text" id="tagsubfield[% loo.row | html %]" name="tagsubfield" value="[% loo.subfieldcode | html %]" />
+                                                                </li>
+                                                        [% END %]
+                                                        <li>
+                                                            <label for="liblibrarian[% loo.row | html %]">Text for librarian: </label>
+                                                            <input id="liblibrarian[% loo.row | html %]" type="text" name="liblibrarian_[% loo.row | html %]" value="[% loo.liblibrarian | html_entity %]" size="40" maxlength="80" />
+                                                        </li>
+                                                        <li>
+                                                            <label for="libopac[% loo.row | html %]">Text for OPAC: </label>
+                                                            <input type="text" id="libopac[% loo.row | html %]" name="libopac_[% loo.row | html %]" value="[% loo.libopac | html_entity %]" size="40" maxlength="80" />
+                                                        </li>
+                                                        <li>
+                                                            <label for="repeatable[% loo.row | html %]">Repeatable: </label>
+                                                            [% IF loo.repeatable %]
+                                                                <input type="checkbox" id="repeatable[% loo.row | html %]" name="repeatable_[% loo.row | html %]" checked="checked" value="1" />
+                                                            [% ELSE %]
+                                                                <input type="checkbox" id="repeatable[% loo.row | html %]" name="repeatable_[% loo.row | html %]" value="1" />
+                                                            [% END %]
+                                                        </li>
+                                                        <li>
+                                                            <label for="mandatory[% loo.row | html %]">Mandatory: </label>
+                                                            [% IF loo.mandatory %]
+                                                                <input type="checkbox" id="mandatory[% loo.row | html %]" name="mandatory_[% loo.row | html %]" checked="checked" value="1" />
+                                                            [% ELSE %]
+                                                                <input type="checkbox" id="mandatory[% loo.row | html %]" name="mandatory_[% loo.row | html %]" value="1" />
+                                                            [% END %]
+                                                        </li>
+                                                        <li>
+                                                            <label for="important[% loo.row | html %]">Important: </label>
+                                                            [% IF loo.important %]
+                                                                <input type="checkbox" id="important[% loo.row | html %]" name="important_[% loo.row | html %]" checked="checked" value="1" />
+                                                            [% ELSE %]
+                                                                <input type="checkbox" id="important[% loo.row | html %]" name="important_[% loo.row | html %]" value="1" />
+                                                            [% END %]
+                                                        </li>
+                                                        <li><label for="tab[% loo.row | html %]">Managed in tab: </label>
+                                                            <select name="tab_[% loo.row | html %]" tabindex="" id="tab[% loo.row | html %]">
+                                                            [%- IF ( loo.tab ==  -1 ) -%]
+                                                                <option value="-1" selected="selected">ignore</option>
+                                                            [%- ELSE -%]
+                                                                <option value="-1">ignore</option>
+                                                            [%- END -%]
+                                                            [%- FOREACH t IN [ '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'] -%]
+                                                                [%- IF ( loo.tab ==  t ) -%]
+                                                                <option value="[%- t | html -%]" selected="selected">[%- t | html -%]</option>
+                                                                [%- ELSE -%]
+                                                                <option value="[%- t | html -%]">[%- t | html -%]</option>
+                                                                [%- END -%]
+                                                            [%- END -%]
+                                                            [%- IF ( loo.tab ==  10 ) -%]
+                                                                <option value="10" selected="selected">items (10)</option>
+                                                            [%- ELSE -%]
+                                                                <option value="10">items (10)</option>
+                                                            [%- END -%]
+                                                            </select>
+                                                            <div class="hint">Ignore means that the subfield does not display in the record editor</div>
+                                                        </li>
+                                                    </ol>
+                                                </fieldset> <!-- /.rows -->
+                                            </div> <!-- /#basic[%- PROCESS outputsubfield subfieldanchor = subfieldcode -%] -->
 
-        <form action="[% delete_link | html %]" method="post"><input type="hidden" name="op" value="delete_confirmed" />
-            <input type="hidden" name="searchfield" value="[% searchfield | html %]" />
-            <input type="hidden" name="tagfield" value="[% tagfield | html %]" />
-            <input type="hidden" name="tagsubfield" value="[% tagsubfield | html %]" />
-            <input type="hidden" name="frameworkcode" value="[% frameworkcode | html %]" />
-            <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this subfield</button>
-        </form>
+                                            <div id="advanced[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]" class="contraints">
+                                                <fieldset class="rows">
+                                                    <legend>Advanced constraints</legend>
+                                                    <ol>
+                                                        <li>
+                                                            <label for="defaultvalue[% loo.row | html %]">Default value:</label>
+                                                            <input type="text" name="defaultvalue_[% loo.row | html %]" id="defaultvalue[% loo.row | html %]" value="[% loo.defaultvalue | html %]" />
+                                                        </li>
+                                                        <li>
+                                                            <label for="maxlength[% loo.row | html %]">Max length:</label>
+                                                            <input type="text" id="maxlength[% loo.row | html %]" name="maxlength_[% loo.row | html %]" value="[% loo.maxlength | html %]" size="4" />
+                                                        </li>
+                                                        <li>
+                                                            [% IF loo.hidden_protected %]
+                                                                <input type="hidden" id="hidden-[% loo.row | html %]" name="hidden_[% loo.row | html %]" value="[% loo.hidden | html %]" data-koha-protected="1" />
+                                                            [% ELSE %]
+                                                                <input type="hidden" id="hidden-[% loo.row | html %]" name="hidden_[% loo.row | html %]" value="[% loo.hidden | html %]" />
+                                                            [% END %]
+                                                            <label for="hidden[% loo.row | html %]">Visibility: </label>
+                                                            <input type="checkbox" id="hidden_opac_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_opac_[% loo.row | html %]"/>
+                                                            <label for="hidden_opac_[% loo.row | html %]" style="float: none;">OPAC</label>
+                                                            <input type="checkbox" id="hidden_intranet_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_intranet_[% loo.row | html %]"/>
+                                                            <label for="hidden_intranet_[% loo.row | html %]" style="float: none;">Intranet</label>
+                                                            <input type="checkbox" id="hidden_editor_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_editor_[% loo.row | html %]"/>
+                                                            <label for="hidden_editor_[% loo.row | html %]" style="float: none;">Editor</label>
+                                                            <input type="checkbox" id="hidden_collapsed_[% loo.row | html %]" class="inclusive_[% loo.row | html %]" name="hidden_collapsed_[% loo.row | html %]"/>
+                                                            <label for="hidden_collapsed_[% loo.row | html %]" style="float: none;">Collapsed</label>
+                                                            <input type="checkbox" id="hidden_flagged_[% loo.row | html %]" name="flagged_[% loo.row | html %]"/>
+                                                            <label for="hidden_flagged_[% loo.row | html %]" style="float: none;">Flagged</label>
+                                                        </li>
+                                                        <li>
+                                                            <label for="isurl[% loo.row | html %]">Is a URL:</label>
+                                                            [% IF loo.isurl %]
+                                                                <input type="checkbox" id="isurl[% loo.row | html %]" name="isurl_[% loo.row | html %]" checked="checked" value="1" />
+                                                            [% ELSE %]
+                                                                <input type="checkbox" id="isurl[% loo.row | html %]" name="isurl_[% loo.row | html %]" value="1" />
+                                                            [% END %]
+                                                            <span class="hint">If checked, it means that the subfield is a URL and can be clicked</span>
+                                                        </li>
+                                                        <li>
+                                                            <label for="link[% loo.row | html %]">Link:</label>
+                                                            <input type="text" id="link[% loo.row | html %]" name="link_[% loo.row | html %]" value="[% loo.link | html %]" size="10" maxlength="80" />
+                                                            <div class="hint">An index name, e.g. title or Local-Number</div>
+                                                        </li>
+                                                        <li>
+                                                            <label for="kohafield[% loo.row | html %]">Koha link:</label>
+                                                            <!-- This select should be DISABLED; value is submitted by the following hidden input -->
+                                                            <select name="kohafield_[% loo.row | html %]" id="kohafield[% loo.row | html %]" disabled>
+                                                            [% FOREACH value IN loo.kohafields %]
+                                                            [% IF ( value == loo.kohafield ) %]
+                                                                <option value="[% value | html %]" selected="selected">[% value | html %]</option>
+                                                            [% ELSE %]
+                                                                <option value="[% value | html %]">[% value | html %]</option>
+                                                            [% END %]
+                                                            [% END %]
+                                                            </select>
+                                                            <!-- Do NOT remove this next hidden input! We need it to save kohafield. -->
+                                                            <input type="hidden" name="kohafield_[% loo.row | html %]" value="[% loo.kohafield | html %]"/>
+                                                        </li>
+                                                    </ol>
+                                                </fieldset> <!-- /.rows -->
+                                            </div> <!-- /#advanced[%- PROCESS outputsubfield subfieldanchor = subfieldcode -%] -->
 
+                                            <div id="oth[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%]" class="constraints">
+                                                <fieldset class="rows">
+                                                    <legend>Other options (choose one)</legend>
+                                                    <ol>
+                                                        <li>
+                                                            <label for="authorised_value[% loo.row | html %]">Authorized value:</label>
+                                                            <select name="authorised_value_[% loo.row | html %]" id="authorised_value[% loo.row | html %]">
+                                                            <option value=""></option>
+                                                            [% FOREACH value IN loo.authorised_values %]
+                                                                [% IF ( value == loo.authorised_value ) %]
+                                                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
+                                                                [% ELSE %]
+                                                                    <option value="[% value | html %]">[% value | html %]</option>
+                                                                [% END %]
+                                                            [% END %]
+                                                            </select>
+                                                        </li>
+                                                        <li>
+                                                            <label for="authtypecode[% loo.row | html %]">Thesaurus:</label>
+                                                            <select name="authtypecode_[% loo.row | html %]" id="authtypecode[% loo.row | html %]">
+                                                            [% FOREACH value IN loo.authtypes %]
+                                                                [% IF ( value == loo.authtypecode ) %]
+                                                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
+                                                                [% ELSE %]
+                                                                    <option value="[% value | html %]">[% value | html %]</option>
+                                                                [% END %]
+                                                            [% END %]
+                                                            </select>
+                                                        </li>
+                                                        <li>
+                                                            <label for="value_builder[% loo.row | html %]">Plugin:</label>
+                                                            <select name="value_builder_[% loo.row | html %]" id="value_builder[% loo.row | html %]">
+                                                            [% FOREACH value IN loo.value_builders %]
+                                                                [% IF ( value == loo.value_builder ) %]
+                                                                    <option value="[% value | html %]" selected="selected">[% value | html %]</option>
+                                                                [% ELSE %]
+                                                                    <option value="[% value | html %]">[% value | html %]</option>
+                                                                [% END %]
+                                                            [% END %]
+                                                            </select>
+                                                        </li>
+                                                    </ol>
+                                                </fieldset> <!-- /.rows -->
+                                            </div> <!-- /#oth[%- PROCESS outputsubfield subfieldanchor = loo.subfieldcode -%] -->
+                                        </div><!-- /constraints -->
+                                    [% END # /FOREACH loo %]
+                                </div> <!-- /.tab-content -->
+                            </div><!-- /subfieldtabs -->
 
-        <form action="[% script_name | html %]" method="post">
-            <input type="hidden" name="searchfield" value="[% searchfield | html %]" />
-            <input type="hidden" name="tagfield" value="[% tagfield | html %]" />
-            <input type="hidden" name="tagsubfield" value="[% tagsubfield | html %]" />
-            <input type="hidden" name="frameworkcode" value="[% frameworkcode | html %]" />
-            <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
-        </form>
-    </div>
+                            <fieldset class="action">
+                                <input type="submit" value="Save changes" /> <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?tagfield=[% tagfield  | uri %]&amp;frameworkcode=[% frameworkcode | uri %]" class="cancel">Cancel</a>
+                            </fieldset>
+                        </form>
+                    [% END # /IF ( add_form ) %]
 
-[% END %]
+                    [% IF ( delete_confirm ) %]
+                        <div class="dialog alert">
+                            <h1>Confirm deletion of subfield [% mss.tagsubfield | html %]?</h1>
+                            <p>Subfield: [% mss.tagsubfield | html %]</p>
+                            <p>Description: [% mss.liblibrarian | html_entity %]</p>
 
-[% IF ( delete_confirmed ) %]
+                            <form action="[% delete_link | html %]" method="post"><input type="hidden" name="op" value="delete_confirmed" />
+                                <input type="hidden" name="tagfield" value="[% mss.tagfield | html %]" />
+                                <input type="hidden" name="tagsubfield" value="[% mss.tagsubfield | html %]" />
+                                <input type="hidden" name="frameworkcode" value="[% mss.frameworkcode | html %]" />
+                                <button type="submit" class="approve"><i class="fa fa-fw fa-check"></i> Yes, delete this subfield</button>
+                            </form>
 
-    <h3>Data deleted</h3>
-    <form action="[% script_name | html %]" method="post">
-        <input type="hidden" name="tagfield" value="[% tagfield | html %]" />
-    <input type="submit" value="OK" />
-    </form>
-[% END %]
 
+                            <form action="[% script_name | html %]" method="post">
+                                <input type="hidden" name="tagfield" value="[% mss.tagfield | html %]" />
+                                <input type="hidden" name="tagsubfield" value="[% mss.tagsubfield | html %]" />
+                                <input type="hidden" name="frameworkcode" value="[% mss.frameworkcode | html %]" />
+                                <button type="submit" class="deny"><i class="fa fa-fw fa-remove"></i> No, do not delete</button>
+                            </form>
+                        </div> <!-- /.dialog.alert -->
+                    [% END # /IF ( delete_confirm ) %]
 
-[% IF ( else ) %]
-<h1>MARC subfield structure admin for [% tagfield | html %] [% IF ( frameworkcode ) %](framework [% frameworkcode | html %])[% ELSE %](default framework)[% END %]</h1>
-<p>This screen shows the subfields associated with the selected tag. You can edit subfields or add a new one by clicking on edit.</p>
-<p>The column 'Koha field' shows that the subfield is linked with a Koha field.</p>
-
-<table>
-<tr>
-    <th>Subfield</th>
-    <th>Text</th>
-    <th>Constraints</th>
-    <th>Actions</th>
-</tr>
-[% FOREACH loo IN loop %]
-<tr>
-    <td><a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | html %]&amp;frameworkcode=[% frameworkcode | html %]#sub[% loo.tagsubfield | html %]field">[% loo.tagsubfield | html %]</a></td>
-    <td>
-        [% IF ( loo.subfield_ignored ) %]
-            <i>[% loo.liblibrarian | html_entity %]</i>
-        [% ELSE %]
-            [% loo.liblibrarian | html_entity %]
-        [% END %]
-    </td>
-    <td>
-        [% IF ( loo.subfield_ignored ) %]
-            <i>subfield ignored</i>
-        [% ELSE %]
-            Tab:[% loo.tab | html %],
-            [% IF ( loo.kohafield ) %] | Koha field: [% loo.kohafield | html %], [% END %]
-            [% IF ( loo.repeatable ) %]Repeatable, [% ELSE %]Not repeatable,[% END %]
-            [% IF ( loo.mandatory ) %]Mandatory, [% ELSE %]Not mandatory,[% END %]
-            [% IF ( loo.seealso ) %] | See Also: [% loo.seealso | html %],[% END %]
-            [% IF ( loo.hidden ) %]hidden,[% END %]
-            [% IF ( loo.isurl ) %]is a URL,[% END %]
-            [% IF ( loo.authorised_value ) %] | Auth value:[% loo.authorised_value | html %],[% END %]
-            [% IF ( loo.authtypecode ) %] | Authority:[% loo.authtypecode | html %],[% END %]
-            [% IF ( loo.value_builder ) %] | Plugin:[% loo.value_builder | html %],[% END %]
-            [% IF ( loo.link ) %] | Link:[% loo.link | html %],[% END %]
-        [% END %]
-    </td>
-    <td class="actions">
-        <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | html %]&amp;frameworkcode=[% frameworkcode | html %]#sub[% loo.tagsubfield | html %]field" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
-        <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=delete_confirm&amp;tagfield=[% loo.tagfield | html %]&amp;tagsubfield=[% loo.tagsubfield | html %]&amp;frameworkcode=[% frameworkcode | html %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
-    </td>
-</tr>
-[% END %]
-</table>
+                    [% IF ( else ) %]
+                        <h1>MARC subfield structure admin for [% tagfield | html %] [% IF ( frameworkcode ) %](framework [% frameworkcode | html %])[% ELSE %](default framework)[% END %]</h1>
 
-<form action="[% script_name | html %]" method="get">
-    <fieldset class="action"><input type="hidden" name="op" value="add_form" />
-    <input type="hidden" name="tagfield" value="[% edit_tagfield | html %]" />
-    <input type="hidden" name="frameworkcode" value="[% edit_frameworkcode | html %]" />
-    <input type="submit" value="Edit subfields" />
-        <a class="cancel" href="marctagstructure.pl?searchfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Cancel</a>
-       </fieldset>
-</form>
+                        <p>This screen shows the subfields associated with the selected tag. You can edit subfields or add a new one by clicking on edit.</p>
+                        <p>The column 'Koha field' shows that the subfield is linked with a Koha field.</p>
 
-[% END %]
+                        <table id="table_marcsubfieldstructure">
+                            <thead>
+                                <tr>
+                                    <th>Subfield</th>
+                                    <th>Text</th>
+                                    <th>Constraints</th>
+                                    <th class="NoSort noExport">Actions</th>
+                                </tr>
+                            </thead>
+                            <tbody>
+                                [% FOREACH loo IN loop %]
+                                    <tr>
+                                        <td><a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]#sub[% loo.tagsubfield | uri %]field">[% loo.tagsubfield | html %]</a></td>
+                                        <td>
+                                            [% IF loo.tab == -1 %]
+                                                <em>[% loo.liblibrarian | html_entity %]</em>
+                                            [% ELSE %]
+                                                [% loo.liblibrarian | html_entity %]
+                                            [% END %]
+                                        </td>
+                                        <td>
+                                            [% IF loo.tab == -1 %]
+                                                <em>subfield ignored</em>
+                                            [% ELSE %]
+                                                <span>Tab:</span>[% loo.tab | html %],
+                                                [% IF ( loo.kohafield ) %] | <span>Koha field:</span> [% loo.kohafield | html %], [% END %]
+                                                [% IF ( loo.repeatable ) %]<span>Repeatable</span>, [% ELSE %]<span>Not repeatable</span>,[% END %]
+                                                [% IF ( loo.mandatory ) %]<span>Mandatory</span>, [% ELSE %]<span>Not mandatory</span>,[% END %]
+                                                [% IF ( loo.important ) %]<span>Important</span>, [% ELSE %]<span>Not important</span>,[% END %]
+                                                [% IF ( loo.seealso ) %] | <span>See also:</span> [% loo.seealso | html %],[% END %]
+                                                [% IF ( loo.hidden ) %]<span>hidden</span>,[% END %]
+                                                [% IF ( loo.isurl ) %]<span>is a URL</span>,[% END %]
+                                                [% IF ( loo.authorised_value ) %] | <span>Auth value:</span>[% loo.authorised_value | html %],[% END %]
+                                                [% IF ( loo.authtypecode ) %] | <span>Authority:</span>[% loo.authtypecode | html %],[% END %]
+                                                [% IF ( loo.value_builder ) %] | <span>Plugin:</span>[% loo.value_builder | html %],[% END %]
+                                                [% IF ( loo.link ) %] | <span>Link:</span>[% loo.link | html %],[% END %]
+                                            [% END %]
+                                        </td>
+                                        <td class="actions">
+                                            <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=add_form&amp;tagfield=[% loo.tagfield | uri %]&tagsubfield=[% loo.tagsubfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]#sub[% loo.tagsubfield | uri %]field" class="btn btn-default btn-xs"><i class="fa fa-pencil"></i> Edit</a>
+                                            <a href="/cgi-bin/koha/admin/marc_subfields_structure.pl?op=delete_confirm&amp;tagfield=[% loo.tagfield | uri %]&amp;tagsubfield=[% loo.tagsubfield | uri %]&amp;frameworkcode=[% frameworkcode | uri %]" class="btn btn-default btn-xs"><i class="fa fa-trash"></i> Delete</a>
+                                        </td>
+                                    </tr>
+                                [% END %]
+                            </tbody>
+                        </table> <!-- /#table_marcsubfieldstructure -->
 
-            </main>
-        </div> <!-- /.col-sm-10.col-sm-push-2 -->
+                        <form action="[% script_name | html %]" method="get">
+                            <fieldset class="action"><input type="hidden" name="op" value="add_form" />
+                                <input type="hidden" name="tagfield" value="[% edit_tagfield | html %]" />
+                                <input type="hidden" name="frameworkcode" value="[% edit_frameworkcode | html %]" />
+                                <input type="submit" value="Edit subfields" />
+                                <a class="cancel" href="marctagstructure.pl?searchfield=[% tagfield | uri %]&amp;frameworkcode=[% frameworkcode | html %]">Cancel</a>
+                            </fieldset>
+                        </form>
 
-        <div class="col-sm-2 col-sm-pull-10">
-            <aside>
-                [% INCLUDE 'admin-menu.inc' %]
-            </aside>
-        </div> <!-- /.col-sm-2.col-sm-pull-10 -->
-     </div> <!-- /.row -->
+                    [% END # /IF else %]
 
-[% MACRO jsinclude BLOCK %]
-    [% Asset.js("js/admin-menu.js") | $raw %]
-    [% Asset.js("js/marc_subfields_structure.js") | $raw %]
-[% END %]
-[% INCLUDE 'intranet-bottom.inc' %]
+                </main>
+            </div> <!-- /.col-sm-10.col-sm-push-2 -->
+
+            <div class="col-sm-2 col-sm-pull-10">
+                <aside>
+                    [% INCLUDE 'admin-menu.inc' %]
+                </aside>
+            </div> <!-- /.col-sm-2.col-sm-pull-10 -->
+        </div> <!-- /.row -->
+
+    [% MACRO jsinclude BLOCK %]
+        [% INCLUDE 'datatables.inc' %]
+        [% Asset.js("js/admin-menu.js") | $raw %]
+        <script>
+            var tagsubfield = "[% tagsubfield | html %]";
+        </script>
+        [% Asset.js("js/marc_subfields_structure.js") | $raw %]
+    [% END %]
+
+    [% INCLUDE 'intranet-bottom.inc' %]