Bug 35245: Set default width for select2 in authorities
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / authorities / authorities.tt
1 [% USE raw %]
2 [% USE To %]
3 [% USE Asset %]
4 [% PROCESS 'i18n.inc' %]
5 [% INCLUDE 'doc-head-open.inc' %]
6 <title>[% FILTER collapse %]
7     [% IF ( authid ) %]
8         [% tx("Modify authority #{authority_id} ({authtypetext})", { authority_id = authid, authtypetext = authtypetext }) | html %]
9     [% ELSE %]
10         [% tx("Adding authority ({authtypetext})", { authtypetext = authtypetext }) | html %]
11     [% END %] &rsaquo;
12     [% t("Authorities") | html %] &rsaquo;
13     [% t("Koha") | html %]
14 [% END %]</title>
15 [% INCLUDE 'doc-head-close.inc' %]
16 [% Asset.js("lib/hc-sticky.js") | $raw %]
17 [% INCLUDE 'select2.inc' %]
18 <script>
19     [% IF Koha.Preference('CreateAVFromCataloguing') && CAN_user_parameters_manage_auth_values %]
20         var auth_values_creation = 1;
21     [% ELSE %]
22         var auth_values_creation = 0;
23     [% END %]
24     $.fn.select2.defaults.set("width", "100%" );
25 </script>
26 [% Asset.js( "lib/sortable/Sortable.min.js" ) | $raw %]
27 [% Asset.js("js/cataloging.js") | $raw %]
28
29 <script>
30     $(window).load(function(){
31         $("#loading").hide();
32     });
33     var Sticky;
34     $(document).ready(function() {
35
36         $("a[data-toggle='tab']").on("shown.bs.tab", function (e) {
37             $( e.target.hash + " .input_marceditor:visible:eq(0)").focus();
38         });
39
40         /* On page load, check for location.hash in the page URL */
41         /* If present the location hash will be used to activate the correct tab */
42         var hash = location.hash;
43         var hashPieces = hash.split('?');
44         if( hashPieces[0] !== "" ){
45             selectTab( hashPieces[0] );
46             window.scrollTo( 0, 0 );
47         } else {
48             selectTab( "#tab0XX_panel" );
49         }
50
51         $("#authoritytabs ul.sortable_field").each( (i, e) => {
52             Sortable.create(e, {
53                 animation: 150
54             });
55         });
56
57         $("#authoritytabs ul.sortable_subfield").each( (i, e) => {
58             Sortable.create(e, {
59                 animation: 150
60             });
61         });
62
63         Sticky = $("#toolbar");
64         Sticky.hcSticky({
65             stickTo: "#f",
66             stickyClass: "floating"
67         });
68
69         $("#addauth").click(function(){
70             if(Check()){
71                 $("#f").submit();
72             }
73         });
74         $("#z3950submit").click(function(){
75             var strQuery = GetZ3950Terms();
76             var index = "&index=[% index | html %]";
77             if(strQuery){
78                 window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid | html %]"+strQuery+index,"z3950search",'width=800,height=500,location=yes,toolbar=no,scrollbars=yes,resize=yes');
79             }
80             return false;
81         });
82
83         $(".toolbar-tabs-container .nav-tabs a").on("click",function(e){
84             e.preventDefault();
85             selectTab( this.hash );
86         });
87
88         $(".tag_anchor").on("click", function(e){
89             e.preventDefault();
90             $(".tag_anchor").removeClass("selected");
91             $(this).addClass("selected");
92             var link = this.href;
93             var linkid = link.substring( link.indexOf("#") + 1 );
94             window.scrollTo( 0, getScrollto( linkid, "toolbar" ) );
95         });
96
97         $("body").on("click", ".linkfield", function(e){
98             e.preventDefault();
99             var tab = $(this).data("tab");
100             var field = $(this).data("field");
101             var tablink = $("a[data-tabname='tab" + tab + "XX']" ).get(0).hash;
102             selectTab( tablink );
103             window.scrollTo( 0, getScrollto( field, "toolbar" ) );
104         });
105
106         $(".change-authtype").on("click", function(){
107             var authtypecode = $(this).data("authtypecode");
108             var f = document.f;
109             f.op.value = "[% op | html %]";
110             f.authid.value = "[% authid | html %]";
111             f.changed_authtype.value = "changed";
112             f.authtypecode.value = authtypecode;
113             f.submit();
114         });
115
116         $("body").on("click", ".linkfield", function(e){
117             e.preventDefault();
118             var tab = $(this).data("tab");
119             var field = $(this).data("field");
120             var tablink = $("a[data-tabname='tab" + tab + "XX']" ).get(0).hash;
121             selectTab( tablink );
122             window.scrollTo( 0, getScrollto( field, "toolbar" ) );
123         });
124
125         $("body").on("click", ".show-errors", function(e){
126             document.getElementById("form-errors").scrollIntoView();
127             Sticky.hcSticky('refresh');
128         });
129
130     });
131
132     function selectTab( tablink ){
133         /* return if no tabs displayed (BIG_LOOP.size <= 1) */
134         if ($(".toolbar-tabs-container .nav-tabs li").length === 0){
135             return;
136         }
137         let a = $("a[href='" + tablink + "']");
138         $(".toolbar-tabs-container .nav-tabs li").removeClass("selected");
139         a.tab("show").parent().addClass("selected");
140         /* Get number from string like "tab9XX" */
141         var tabid = a.data("tabname").substring(3, 4);
142         $(".tag_anchors").removeClass("tab_selected").hide();
143         $(".tag_anchors_" + tabid ).addClass("tab_selected").show();
144     }
145
146     /**
147     * Returns a roughly ideal position to scroll an element into view
148     * @param {string} target - The HTML id of the element to scroll into view
149     * @param {string} elemid - The HTML id of the element which might obscure
150     *                          the view of the target element e.g. a floating toolbar
151     * @return {number} - The y-coordinate to pass to window.scrollTo()
152     */
153     function getScrollto( target, elemid ){
154         var dest = $("#" + target );
155         var yoffset = dest.offset();
156
157         if( elemid != "" ){
158             var element = $("#" + elemid );
159             var elem_height = element.outerHeight();
160         } else {
161             elem_height = 0;
162         }
163         return yoffset.top - elem_height - 20;
164     }
165
166
167     /**
168     * check if z3950 mandatories are set or not
169     */
170     function GetZ3950Terms(){
171         var strQuery="&authtypecode="+document.forms['f'].authtypecode.value;
172         var mandatories = new Array();
173         var mandatories_label = new Array();
174         [% FOREACH BIG_LOO IN BIG_LOOP %][% FOREACH innerloo IN BIG_LOO.innerloop %][% FOREACH subfield_loo IN innerloo.subfield_loop %][% IF ( subfield_loo.z3950_mandatory ) %]mandatories.push("[% subfield_loo.id | html %]");
175             mandatories_label.push("[% subfield_loo.z3950_mandatory | html %]");[% END %][% END %][% END %][% END %]
176
177         for(var i=0,len=mandatories.length; i<len ; i++){
178             var field_value = document.getElementById(mandatories[i]).value;
179             if( field_value ){
180                 strQuery += "&"+mandatories_label[i]+"="+encodeURIComponent(field_value);
181             }
182         }
183         return strQuery;
184     }
185
186     /**
187     * check if mandatory subfields are written
188     */
189     function AreMandatoriesNotOk(){
190         var fields = new Array();
191         var subfields = new Array();
192         var   tab = new Array();
193         var label = new Array();
194         var flag = false;
195         var tabflag= new Array();
196         var StrAlert = "<div id='form-errors' class='dialog alert list'>";
197         var notFilledClass = "subfield_not_filled";
198
199         [% FOREACH BIG_LOO IN BIG_LOOP %]
200             [% FOREACH innerloo IN BIG_LOO.innerloop %]
201                 [% IF ( innerloo.mandatory ) %]
202                     fields.push(new Array("[% innerloo.tag | html %]","[% innerloo.index | html %][% innerloo.random | html %]","[% innerloo.index | html %]", "[% BIG_LOO.number | html %]"));
203                 [% END %]
204                 [% FOREACH subfield_loo IN innerloo.subfield_loop %]
205                     [% IF ( subfield_loo.mandatory ) %]subfields.push("[% subfield_loo.id | html %]");
206                         tab.push("[% BIG_LOO.number | html %]");
207                         label.push("[% subfield_loo.marc_lib | $raw %]");
208                     [% END %]
209                 [% END %]
210             [% END %]
211         [% END %]
212
213         StrAlert += "<h4>" + _("The following mandatory subfields aren't filled:") + "</h4>";
214         StrAlert += "<ul>";
215
216         for(var i=0,len=subfields.length; i<len ; i++){
217             var tag=subfields[i].substr(4,3);
218             var subfield=subfields[i].substr(17,1);
219             var tagnumber=subfields[i].substr(19,subfields[i].lastIndexOf("_")-19);
220             if (tabflag[tag+subfield+tagnumber] ==  null) {
221                 tabflag[tag+subfield+tagnumber]=new Array();
222                 tabflag[tag+subfield+tagnumber][0]=0;
223             }
224             if( tabflag[tag+subfield+tagnumber][0] != 1 && (document.getElementById(subfields[i]) != null && ! document.getElementById(subfields[i]).value || document.getElementById(subfields[i]) == null)){
225                 tabflag[tag+subfield+tagnumber][0] = 0 + tabflag[tag+subfield+tagnumber] ;
226
227                 var elt = document.getElementById(subfields[i]);
228                 if ( elt.nodeName == 'SELECT' ) {
229                     $(elt).siblings('.select2').find("span[role='combobox']").addClass(notFilledClass);
230                 } else {
231                     elt.setAttribute('class','input_marceditor noEnterSubmit ' + notFilledClass);
232                 }
233                 $('#' + subfields[i]).focus();
234                 tabflag[tag+subfield+tagnumber][1]=label[i];
235                 tabflag[tag+subfield+tagnumber][2]=tab[i];
236             } else {
237                 tabflag[tag+subfield+tagnumber][0] = 1;
238             }
239             tabflag[tag+subfield+tagnumber][3] = subfields[i];
240         }
241
242         for (var tagsubfieldid in tabflag){
243             if (tabflag[tagsubfieldid][0]==0){
244                 var tag=tagsubfieldid.substr(0,3);
245                 var subfield=tagsubfieldid.substr(3,1);
246                 StrAlert += "<li>"+_("Tag %s subfield %s %s in tab %s").format(tag, subfield, formatFieldName( tabflag[tagsubfieldid][1] ), tabflag[tagsubfieldid][2]) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + tabflag[tagsubfieldid][2] + '" data-field="' + tabflag[tagsubfieldid][3] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
247                 flag = true;
248             }
249         }
250
251         StrAlert += "</ul>";
252         mandatoryFields = new Object();
253
254         /* Check for mandatories field(not subfields) */
255         for(var i=0,len=fields.length; i<len; i++){
256             isempty  = true;
257             arr      = fields[i];
258             divid    = "tag_" + arr[0] + "_" + arr[1];
259             varegexp = new RegExp("^tag_" + arr[0] + "_code_");
260
261             if(parseInt(arr[0]) >= 10){
262                 elem = document.getElementById(divid);
263                 eleminputs = elem.getElementsByTagName('input');
264
265                 for(var j=0,len2=eleminputs.length; j<len2; j++){
266
267                     if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
268                         inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
269
270                         for( var k=0; k<len2; k++){
271                             if( eleminputs[k].id.match(inputregexp) ){
272                                 if( eleminputs[k].value ){
273                                     isempty = false
274                                 }
275                             }
276                         }
277
278                         elemselect = elem.getElementsByTagName('select');
279                         for( var k=0; k<elemselect.length; k++){
280                             if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
281                                 isempty = false
282                             }
283                         }
284                     }
285                 }
286
287                 elemtextareas = elem.getElementsByTagName('textarea');
288                 for(var j=0,len2=elemtextareas.length; j<len2; j++){
289                     // this bit assumes that the only textareas in this context would be for subfields
290                     if (elemtextareas[j].value) {
291                         isempty = false;
292                     }
293                 }
294
295             } else {
296                 isempty = false;
297             }
298
299             if(isempty){
300                 flag = true;
301                 mandatoryFields[ arr[0] ] = {
302                     importance: "mandatory",
303                     elemid: "div_indicator_" + divid,
304                     tab: arr[3]
305                 }
306             }
307
308         }
309
310         if( Object.entries(mandatoryFields).length > 0 ){
311             StrAlert += "<h4>" + _("The following fields aren't filled:") + "</h4>";
312             StrAlert += "<ul>";
313             for( var prop in mandatoryFields ){
314                 if( mandatoryFields[prop]["importance"] == "mandatory" ){
315                     StrAlert += "<li>" + _("Field %s is mandatory, at least one of its subfields must be filled.").format( prop ) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
316                 } else {
317                     StrAlert += "<li>" + _("Field %s is important, at least one of its subfields must be filled.").format(prop) + ' <a class="linkfield btn btn-link" href="#" data-tab="' + mandatoryFields[prop]["tab"] + '" data-field="' + mandatoryFields[prop]["elemid"] + '"><i class="fa fa-arrow-right" aria-hidden="true"></i> ' + _("Go to field") + '</a></li>';
318                 }
319             }
320             StrAlert += "</ul>";
321         }
322         StrAlert += "</div>";
323         if ( flag ) {
324             $("#show-errors").html('<button type="button" class="btn btn-danger show-errors"><i class="fa-solid fa-triangle-exclamation"></i> ' + _("Errors") + '</span>');
325             return StrAlert;
326         } else {
327             return flag;
328         }
329     }
330
331     function Check(){
332         var StrAlert = AreMandatoriesNotOk();
333         if( ! StrAlert ){
334             document.f.submit();
335             return true;
336         } else {
337             $("#check_errors").html( StrAlert );
338             $('html, body').animate({ scrollTop: 0 }, 'fast');
339             Sticky.hcSticky('refresh');
340             return false;
341         }
342     }
343
344     function AddField(field,cntrepeatfield) {
345         document.forms['f'].op.value = "addfield";
346         document.forms['f'].addfield_field.value=field;
347         document.forms['f'].repeat_field.value=cntrepeatfield;
348         document.f.submit();
349     }
350
351     function addauthority() {
352         X = document.forms[0].authtype.value;
353         window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
354     }
355     function searchauthority() {
356         X = document.forms[0].authtype2.value;
357         Y = document.forms[0].value.value;
358         window.location="/cgi-bin/koha/authorities/authorities-home.pl?op=do_search&type=intranet&authtypecode="+X+"&value="+Y+"&marclist=&and_or=and&excluding=&operator=contains";
359     }
360     function confirmnotdup(redirect){
361         $("#confirm_not_duplicate").attr("value","1");
362         Check();
363     }
364     /* Wrap a value in HTML without putting HTML in translatable string */
365     function formatFieldName( string ){
366         return "<strong><em>" + string + "</em></strong>";
367     }
368
369     $(document).ready(function(){
370         $('body').on('click','.expandfield',ExpandField);
371     });
372 </script>
373 [% Asset.css("css/addbiblio.css") | $raw %]
374
375 </head>
376 <body id="auth_authorities" class="auth">
377
378     <div id="loading">
379         <div>Loading, please wait...</div>
380     </div>
381
382     [% INCLUDE 'header.inc' %]
383
384 [% WRAPPER 'sub-header.inc' %]
385     [% WRAPPER breadcrumbs %]
386         [% WRAPPER breadcrumb_item %]
387             <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a>
388         [% END %]
389
390         [% IF ( authid ) %]
391             [% WRAPPER breadcrumb_item bc_active= 1 %]
392                 <span>Modify authority #[% authid | html %] ([% authtypetext | html %])</span>
393             [% END %]
394
395         [% ELSE %]
396             [% WRAPPER breadcrumb_item bc_active= 1 %]
397                 <span>Adding authority [% authtypetext | html %]</span>
398             [% END %]
399
400         [% END %]
401     [% END #/ WRAPPER breadcrumbs %]
402 [% END #/ WRAPPER sub-header.inc %]
403
404     <div class="main container-fluid">
405         <div class="row">
406             <div class="col-md-10 col-md-offset-1">
407
408                 [% IF ( authid ) %]
409                     <h1>Modify authority #[% authid | html %] [% authtypetext | html %]</h1>
410                 [% ELSE %]
411                     <h1>Adding authority [% authtypetext | html %]</h1>
412                 [% END %]
413
414                 <div id="check_errors"></div>
415
416                 [% IF ( duplicateauthid ) %]
417                     <div class="dialog alert">
418                         <h3>Duplicate record suspected</h3>
419                         <p>Is this a duplicate of <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid | uri %]" class="popup" onclick="openWindow('/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid | html %]&amp;popup=1', 'DuplicateAuthority','800','600'); return false;" class="button">[% duplicateauthvalue | html %]</a> ?</p>
420
421                         <form action="authorities.pl" method="get">
422                             <input type="hidden" name="authid" value="[% duplicateauthid | html %]" />
423                             <button type="submit" class="new"><i class="fa-solid fa-pencil" aria-hidden="true"></i> Yes: Edit existing authority</button>
424                         </form>
425                         <form action="authorities.pl" method="get">
426                             <button class="new" onclick="confirmnotdup('items'); return false;"><i class="fa fa-save"></i> No: Save as new authority</button>
427                         </form>
428                     </div>
429                 [% END # /IF duplicateauthid %]
430
431                 <form method="post" id="f" name="f" action="/cgi-bin/koha/authorities/authorities.pl">
432                     <input type="hidden" name="op" value="add" />
433                     <input type="hidden" name="addfield_field" value="" />
434                     <input type="hidden" name="repeat_field" value="" />
435                     <input type="hidden" name="authtypecode" value="[% authtypecode | html%]" />
436                     <input type="hidden" name="authid" value="[% authid | html %]" />
437                     <input type="hidden" name="index" value="[% index | html %]" />
438                     <input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
439                     <input type="hidden" name="changed_authtype" value="" />
440
441                     <div id="toolbar" class="btn-toolbar">
442                         <div class="btn-group"><a href="#" id="addauth" class="btn btn-primary" accesskey="w"><i class="fa fa-save"></i> Save</a></div>
443                         <div class="btn-group">
444                             [% IF ( authid ) %]
445                                 <a class="btn btn-default" id="z3950submit" href="#"><i class="fa fa-search"></i> Replace record via Z39.50/SRU search</a>
446                             [% ELSE %]
447                                 <a class="btn btn-default" id="z3950submit" href="#"><i class="fa fa-search"></i> Z39.50/SRU search</a>
448                             [% END %]
449                         </div>
450                         <div class="btn-group">
451                             <button class="btn btn-default dropdown-toggle" data-toggle="dropdown"><i class="fa fa-cog"></i> Settings <span class="caret"></span></button>
452                             <ul id="settings-menu" class="dropdown-menu">
453                                 <li class="dropdown-header">Change authority type</li>
454                                 <li>
455                                     <a href="#" class="change-authtype" data-authtypecode="">
456                                         [% IF ( authtypecode ) %]
457                                            <i class="fa fa-fw">&nbsp;</i>
458                                         [% ELSE %]
459                                             <i class="fa fa-fw fa-check"></i>
460                                         [% END %]
461                                         Default
462                                     </a>
463                                 </li>
464                                 [% FOREACH authority_type IN authority_types %]
465                                     <li>
466                                         <a href="#" class="change-authtype" data-authtypecode="[% authority_type.authtypecode | html %]">
467                                             [% IF authority_type.authtypecode == authtypecode %]
468                                                 <i class="fa fa-fw fa-check"></i>
469                                             [% ELSE %]
470                                                 <i class="fa fa-fw">&nbsp;</i>
471                                             [% END %]
472                                             [% authority_type.authtypetext | html %]
473                                         </a>
474                                     </li>
475                                 [% END %]
476                             </ul> <!-- /#settings-menu -->
477                         </div> <!-- /.btn-group -->
478                         <div class="btn-group">
479                             [% IF ( authid ) %]
480                                 <a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/detail.pl?authid=[% authid | url %]">Cancel</a>
481                             [% ELSE %]
482                                 <a class="btn btn-default" id="cancel" href="/cgi-bin/koha/authorities/authorities-home.pl">Cancel</a>
483                             [% END %]
484                         </div>
485                         <div id="show-errors" class="btn-group"></div>
486                         <div class="toolbar-tabs-container">
487                             [% IF ( BIG_LOOP && BIG_LOOP.size > 1 ) %]
488                                 [% WRAPPER tabs_nav %]
489                                     [%- FOREACH BIG_LOO IN BIG_LOOP -%]
490                                         [% IF loop.first %]
491                                             [% SET bt_active = 1 %]
492                                         [% ELSE %]
493                                             [% SET bt_active = 0 %]
494                                         [% END %]
495                                         [% WRAPPER tab_item tabname= "tab${BIG_LOO.number}XX" bt_active= bt_active %]
496                                             <span>[% BIG_LOO.number | html %]</span>
497                                         [% END %]
498                                     [%- END -%]
499                                 [% END # /WRAPPER tabs_nav %]
500                             [% END %]
501                             <ul class="tag_anchors_list">
502                                 [% FOREACH BIG_LOO IN BIG_LOOP %]
503                                     [% IF loop.first %][% SET tab_selected = "tab_selected" %][% ELSE %][% SET tab_selected = "" %][% END %]
504                                     [% FOREACH innerloo IN BIG_LOO.innerloop %]
505                                         [% IF ( innerloo.tag ) %]
506                                             <li class="tag_anchors tag_anchors_[% BIG_LOO.number | html %] [% tab_selected | html %]">
507                                                 <a class="tag_anchor" id="tag_anchor_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" title="tag_anchor_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" href="#div_indicator_tag_[% innerloo.tag | uri %]_[% innerloo.index | uri %][% innerloo.random | uri %]">[% innerloo.tag | uri %]</a>
508                                             </li>
509                                         [% END %]
510                                     [% END %]
511                                 [% END %]
512                             </ul>
513                         </div>
514                     </div> <!-- /#toolbar -->
515                     <div id="action">
516                         [% IF count %]
517                                 Used in <a href="/cgi-bin/koha/catalogue/search.pl?type=intranet&amp;op=do_search&amp;q=an:[% authid | uri %]">[% count | html %] record(s)</a>
518                         [% ELSE %]
519                                 This authority is not used in any records.
520                         [% END %]
521                     </div>
522
523                     [% WRAPPER tabs id= "authoritytabs" %]
524                         [% WRAPPER tab_panels %]
525                             [% FOREACH BIG_LOO IN BIG_LOOP %]
526                                 [% IF loop.first %]
527                                     [% SET bt_active = 1 %]
528                                 [% ELSE %]
529                                     [% SET bt_active = 0 %]
530                                 [% END %]
531                                 [% WRAPPER tab_panel tabname="tab${BIG_LOO.number}XX" bt_active= bt_active %]
532                                     [% IF ( BIG_LOOP.size > 1 ) %]
533                                         <h2>Section [% BIG_LOO.number | html %]</h2>
534                                     [% END %]
535                                     [% previous = "" %]
536                                     [% FOREACH innerloo IN BIG_LOO.innerloop %]
537                                         [% IF ( innerloo.tag ) %]
538                                             [% IF innerloo.tag != previous %]
539                                                 [% IF previous != "" %]
540                                                     </ul>
541                                                 [% END %]
542                                                 [% previous = innerloo.tag %]
543                                                 [% IF ( innerloo.repeatable ) %]
544                                                     <ul class="sortable_field">
545                                                 [% ELSE %]
546                                                     <ul>
547                                                 [% END %]
548                                             [% END %]
549
550                                             [% IF ( innerloo.repeatable ) %]
551                                                 <li class="tag sortable_tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
552                                             [% ELSE %]
553                                                 <li class="tag clearfix" id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
554                                             [% END %]
555
556                                                 <div class="tag_title" id="div_indicator_tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]">
557                                                     [% UNLESS hide_marc %]
558                                                         [% IF advancedMARCEditor %]
559                                                             <a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib | html %] - Click to expand this tag" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'">[% innerloo.tag | html %]</a>
560                                                         [% ELSE %]
561                                                             <span class="tagnum" title="[% innerloo.tag_lib | html %]">[% innerloo.tag | html %]</span>
562                                                         [% END %]
563                                                         [% IF ( innerloo.fixedfield ) %]
564                                                             <input type="text"
565                                                                 tabindex="1"
566                                                                 class="indicator flat"
567                                                                 style="display:none;"
568                                                                 name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
569                                                                 size="1"
570                                                                 maxlength="1"
571                                                                 value="[% innerloo.indicator1 | html %]" />
572                                                             <input type="text"
573                                                                 tabindex="1"
574                                                                 class="indicator flat"
575                                                                 style="display:none;"
576                                                                 name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
577                                                                 size="1"
578                                                                 maxlength="1"
579                                                                 value="[% innerloo.indicator2 | html %]" />
580                                                         [% ELSE %]
581                                                             <input type="text"
582                                                                 tabindex="1"
583                                                                 class="indicator flat"
584                                                                 name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
585                                                                 size="1"
586                                                                 maxlength="1"
587                                                                 value="[% innerloo.indicator1 | html %]" />
588                                                             <input type="text"
589                                                                 tabindex="1"
590                                                                 class="indicator flat"
591                                                                 name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
592                                                                 size="1"
593                                                                 maxlength="1"
594                                                                 value="[% innerloo.indicator2 | html %]" />
595                                                         [% END # /IF ( innerloo.fixedfield ) %] -
596                                                     [% ELSE %]
597                                                         [% IF ( innerloo.fixedfield ) %]
598                                                             <input type="hidden"
599                                                                 tabindex="1"
600                                                                 name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
601                                                                 value="[% innerloo.indicator1 | html %]" />
602                                                             <input type="hidden"
603                                                                 tabindex="1"
604                                                                 name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
605                                                                 value="[% innerloo.indicator2 | html %]" />
606                                                         [% ELSE %]
607                                                             <input type="hidden"
608                                                                 tabindex="1"
609                                                                 name="tag_[% innerloo.tag | html %]_indicator1_[% innerloo.index | html %][% innerloo.random | html %]"
610                                                                 value="[% innerloo.indicator1 | html %]" />
611                                                             <input type="hidden"
612                                                                 tabindex="1"
613                                                                 name="tag_[% innerloo.tag | html %]_indicator2_[% innerloo.index | html %][% innerloo.random | html %]"
614                                                                 value="[% innerloo.indicator2 | html %]" />
615                                                         [% END # /IF ( innerloo.fixedfield ) %]
616                                                     [% END # /UNLESS hide_marc %]
617
618                                                     [% UNLESS advancedMARCEditor %]
619                                                         <a href="#" tabindex="1" class="expandfield" data-field_id="tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]" title="Click to expand this tag">[% innerloo.tag_lib | html %]</a>
620                                                     [% END %]
621                                                     <span class="field_controls">
622                                                         [% IF ( innerloo.repeatable ) %]
623                                                             <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]','[% hide_marc | html %]','[% advancedMARCEditor | html %]'); return false;" title="Repeat this tag">
624                                                                 <img src="[% interface | html %]/[% theme | html %]/img/repeat-tag.png" alt="Repeat this tag" />
625                                                             </a>
626                                                         [% END %]
627                                                         <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag | html %]_[% innerloo.index | html %][% innerloo.random | html %]'); return false;" title="Delete this tag">
628                                                             <img src="[% interface | html %]/[% theme | html %]/img/delete-tag.png" alt="Delete this tag" />
629                                                         </a>
630                                                     </span> <!-- /.field_controls -->
631                                                 </div> <!-- /div.tag_title -->
632
633                                                 <ul class="sortable_subfield">
634                                                     [% FOREACH subfield_loo IN innerloo.subfield_loop %]
635                                                         <!--  One line on the marc editor -->
636                                                         <li class="subfield_line" style="[% subfield_loo.visibility | html %]" id="subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]">
637
638                                                             [% UNLESS hide_marc %]
639                                                                 <div class="subfieldcode">
640                                                                     <input type="text"
641                                                                         title="[% subfield_loo.marc_lib | $raw %]"
642                                                                         style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
643                                                                         name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
644                                                                         value="[% subfield_loo.subfield | html %]"
645                                                                         size="1"
646                                                                         maxlength="1"
647                                                                         class="flat"
648                                                                         tabindex="0" />
649                                                                 </div>
650                                                             [% ELSE %]
651                                                                 <input type="hidden"
652                                                                     name="tag_[% subfield_loo.tag | html %]_code_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]"
653                                                                     value="[% subfield_loo.subfield | html %]" />
654                                                             [% END # /UNLESS hide_marc %]
655
656                                                             [% UNLESS advancedMARCEditor %]
657                                                                 [% IF ( subfield_loo.mandatory ) %]
658                                                                     <div class="subfield subfield_mandatory">
659                                                                 [% ELSE %]
660                                                                     <div class="subfield">
661                                                                 [% END %]
662                                                                     [% IF ( subfield_loo.fixedfield ) %]
663                                                                         <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" style="display:none;" class="labelsubfield">
664                                                                     [% ELSE %]
665                                                                         <label for="tag_[% subfield_loo.tag | html %]_subfield_[% subfield_loo.subfield | html %]_[% subfield_loo.index | html %]_[% subfield_loo.index_subfield | html %]" class="labelsubfield">
666                                                                     [% END %]
667                                                                         [% subfield_loo.marc_lib | $raw %]
668                                                                     </label>
669                                                                 </div> <!-- /.subfield -->
670                                                             [% END # UNLESS advancedMARCEditor %]
671
672                                                             [% SET mv = subfield_loo.marc_value %]
673                                                             <div id="field_marceditor[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]" class="field_marceditor">
674                                                                 [% IF ( mv.type == 'select' ) %]
675                                                                     [% IF mv.category AND CAN_user_parameters_manage_auth_values %]
676                                                                         <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor" id="[%- mv.id | html -%]" data-category="[% mv.category | html %]">
677                                                                     [% ELSE %]
678                                                                         <select name="[%- mv.name | html -%]" tabindex="1" class="input_marceditor select2" id="[%- mv.id | html -%]">
679                                                                     [% END %]
680                                                                         [% FOREACH aval IN mv.values %]
681                                                                             [% IF aval == mv.default %]
682                                                                                 <option value="[%- aval | html -%]" selected="selected">[%- mv.labels.$aval | html -%]</option>
683                                                                             [% ELSE %]
684                                                                                 <option value="[%- aval | html -%]">[%- mv.labels.$aval | html -%]</option>
685                                                                             [% END %]
686                                                                         [% END %]
687                                                                     </select>
688                                                                 [% ELSIF ( mv.type == 'text1' ) %]
689                                                                     <input type="text" id="[%- mv.id | html -%]" name="[%- mv.id | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" />
690                                                                 [% ELSIF ( mv.type == 'text2' ) %]
691                                                                     <input type="text" id="[%- mv.id | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" />
692                                                                 [% ELSIF ( mv.type == 'text' ) %]
693                                                                     <input type="text" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" value="[%- mv.value | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]" />
694                                                                 [% ELSIF ( mv.type == 'textarea' ) %]
695                                                                     <textarea cols="70" rows="4" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength | html -%]">[%- mv.value | html -%]</textarea>
696                                                                 [% ELSIF ( mv.type == 'hidden' ) %]
697                                                                     <input tabindex="1" type="hidden" id="[%- mv.id | html -%]" name="[%- mv.name | html -%]" size="67" maxlength="[%- mv.maxlength | html -%]" value="[%- mv.value | html -%]" />
698                                                                 [% ELSIF ( mv.type == 'hidden_simple' ) %]
699                                                                     <input type="hidden" name="[%- mv.name | html -%]" />
700                                                                 [% END # /IF mv.type %]
701                                                             </div> <!-- /.field_marceditor -->
702
703                                                             [% IF ( subfield_loo.mandatory ) %]
704                                                                 <div class="subfield_loop_mandatory">
705                                                                     <span class="required">Required</span>
706                                                                 </div>
707                                                             [% END %]
708
709                                                             <div class="subfield_controls">
710                                                                 [% IF ( mv.type == 'text1' ) %]
711                                                                     <a href="#" class="buttonDot tag_editor" onclick="openAuth(this.parentNode.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtypecode | html -%]','auth'); return false;" tabindex="1" title="Tag editor">Tag editor</a>
712                                                                 [% ELSIF ( mv.type == 'text2' ) %]
713                                                                     [% IF mv.noclick %]
714                                                                         <a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup">...</a>
715                                                                     [% ELSE %]
716                                                                         <a href="#" id="buttonDot_[% mv.id | html %]" class="buttonDot tag_editor" title="Tag editor">...</a>
717                                                                     [% END %]
718                                                                     [% mv.javascript | $raw %]
719                                                                 [% END #/IF ( mv.type == 'text1' ) %]
720                                                                 [% IF ( subfield_loo.repeatable ) %]
721                                                                     <a href="#" class="buttonPlus" tabindex="1" onclick="CloneSubfield('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]','[% advancedMARCEditor | html %]'); return false;">
722                                                                         <img src="[% interface | html %]/[% theme | html %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
723                                                                     </a>
724                                                                     <a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag | html %][% subfield_loo.subfield | html %][% subfield_loo.random | html %]'); return false;">
725                                                                         <img src="[% interface | html %]/[% theme | html %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
726                                                                     </a>
727                                                                 [% END # /IF ( subfield_loo.repeatable ) %]
728                                                             </div> <!-- /.subfield_controls -->
729                                                         </li> <!-- /.subfield_line -->
730                                                     [% END # /FOREACH subfield_loo %]
731                                                 </ul> <!-- /.sortable_subfield -->
732                                             </li> <!-- /.tag -->
733                                         [% END # /IF ( innerloo.tag ) %]
734                                     [% END # /FOREACH innerloo %]
735                                     </ul> <!-- /.sortable_field -->
736                                 [% END # /tab_panel#tabXXX %]
737                             [% END #/FOREACH BIG_LOO %]
738                         [% END # /WRAPPER tab_panels %]
739                     [% END # /WRAPPER tabs %]
740
741                     <div name="hidden" id="hidden" class="tab">
742                         [% FOREACH hidden_loo IN hidden_loop %]
743                             <input type="hidden" name="tag" value="[% hidden_loo.tag | html %]" />
744                             <input type="hidden" name="subfield" value="[% hidden_loo.subfield | html %]" />
745                             <input type="hidden" name="mandatory" value="[% hidden_loo.mandatory | html %]" />
746                             <input type="hidden" name="kohafield" value="[% hidden_loo.kohafield | html %]" />
747                             <input type="hidden" name="tag_mandatory" value="[% hidden_loo.tag_mandatory | html %]" />
748                         [% END %]
749                     </div> <!-- /.tab -->
750                     [% IF ( oldauthnumtagfield ) %]
751                         <input type="hidden" name="tag" value="[% oldauthnumtagfield | html %]" />
752                         <input type="hidden" name="subfield" value="[% oldauthnumtagsubfield | html %]" />
753                         <input type="hidden" name="field_value" value="[% authid | html %]" />
754                         <input type="hidden" name="mandatory" value="0" />
755                         <input type="hidden" name="kohafield" value="[% kohafield | html %]" />
756                         <input type="hidden" name="tag_mandatory" value="[% tag_mandatory | html %]" />
757                         <input type="hidden" name="tag" value="[% oldauthtypetagfield | html %]" />
758                         <input type="hidden" name="subfield" value="[% oldauthtypetagsubfield | html %]" />
759                         <input type="hidden" name="field_value" value="[% authtypecode | html %]" />
760                     [% END %]
761
762                 </form>
763
764                 [% INCLUDE 'modals/cataloguing_create_av.inc' %]
765
766             </div>
767         </div>
768     </div>
769
770 [% INCLUDE 'intranet-bottom.inc' %]