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