(bug #3728) fix mandatory select fields
[koha.git] / koha-tmpl / intranet-tmpl / prog / en / modules / cataloguing / addbiblio.tmpl
index 7bd2901..dbfa0f0 100644 (file)
@@ -1,14 +1,31 @@
 <!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
-<title>Koha &rsaquo; Cataloging &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Edit MARC Record Number <!-- TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></title>
+<title>Koha &rsaquo; Cataloging &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Editing <!-- TMPL_VAR NAME="title" escape="html" --> (Record Number <!-- TMPL_VAR name="biblionumber" -->)<!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></title>
 <!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
 <script type="text/javascript" src="<!-- TMPL_VAR name="themelang" -->/lib/yui/plugins/bubbling-min.js"></script>
 <script type="text/javascript">
 //<![CDATA[
 
+     var fields_in_use = {};
         $(document).ready(function() {
                $('#addbibliotabs > ul').tabs().bind('show.ui-tabs', function(e, ui) {
                        $("#"+ui.panel.id+" input:eq(0)").focus();
                });
+        $('.tag').each(function() {
+            var field_id = this.getAttribute('id').substring(0, 7);
+            if (field_id in fields_in_use) {
+                fields_in_use[field_id]++;
+            } else {
+                fields_in_use[field_id] = 1;
+            }
+        });
+        $('.subfield_line').each(function() {
+            var field_id = this.getAttribute('id').substring(0, 12);
+            if (field_id in fields_in_use) {
+                fields_in_use[field_id]++;
+            } else {
+                fields_in_use[field_id] = 1;
+            }
+        });
         });
         
         $('#header_search > ul').tabs().bind('show.ui-tabs', function(e, ui) { $('#header_search > div:not(.ui-tabs-hide)').find('input').eq(0).focus(); });
@@ -37,20 +54,17 @@ function Check(){
 
 function Dopop(link,i) {
     defaultvalue = document.getElementById(i).value;
-    window.open(link+"&result="+defaultvalue,"value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
+    window.open(link+"&result="+defaultvalue,"valuebuilder",'width=700,height=550,toolbar=false,scrollbars=yes');
 }
 
 /**
  * this function open a popup to search on z3950 server.
  */
 function PopupZ3950() {
-    var strQuery = AreZ3950MandoriesOk();
-    if(strQuery){
-        window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->&frameworkcode=<!-- TMPL_VAR NAME="frameworkcode" -->"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
-    } else {
-        var strAlert = _("To perform a z39.50 search, you must enter at least one of the following: \n\n ISBN\n ISSN\n Title\n Author\n LCCN\n");    
-        alert(strAlert);
-    }
+    var strQuery = GetZ3950Terms();
+       if(strQuery){
+        window.open("/cgi-bin/koha/cataloguing/z3950_search.pl?biblionumber=<!-- TMPL_VAR NAME="biblionumber" -->"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
+    } 
 }
 
 /**
@@ -58,14 +72,24 @@ function PopupZ3950() {
  */
 function AreMandatoriesNotOk(){
     var mandatories = new Array();
+    var mandatoriesfields = new Array();
     var tab = new Array();
     var label = new Array();
     var flag=0;
     var tabflag= new Array();  
-    <!-- TMPL_LOOP NAME='BIG_LOOP' --><!-- TMPL_LOOP NAME='innerloop' --><!-- TMPL_LOOP NAME='subfield_loop'--><!-- TMPL_IF NAME='mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
+    <!-- TMPL_LOOP NAME='BIG_LOOP' -->
+       <!-- TMPL_LOOP NAME='innerloop' -->
+               <!-- TMPL_IF NAME="mandatory" -->
+               mandatoriesfields.push(new Array("<!-- TMPL_VAR NAME="tag" -->","<!-- TMPL_VAR NAME="index" --><!-- TMPL_VAR NAME="random" -->","<!-- TMPL_VAR NAME="index" -->"));
+               <!-- /TMPL_IF -->
+               <!-- TMPL_LOOP NAME='subfield_loop'-->
+                       <!-- TMPL_IF NAME='mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
                        tab.push("<!-- TMPL_VAR NAME='number' -->");
                        label.push("<!-- TMPL_VAR NAME='marc_lib' -->");
-                <!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
+                <!-- /TMPL_IF -->
+            <!-- /TMPL_LOOP -->
+        <!-- /TMPL_LOOP -->
+    <!-- /TMPL_LOOP -->
     var StrAlert = _("Can't save this record because the following field aren't filled :\n\n");
     for(var i=0,len=mandatories.length; i<len ; i++){
         var tag=mandatories[i].substr(4,3);
@@ -92,6 +116,48 @@ function AreMandatoriesNotOk(){
         flag=1;    
       }   
     }   
+    
+    /* Check for mandatories field(not subfields) */
+    for(var i=0,len=mandatoriesfields.length; i<len; i++){
+           isempty  = true;
+               arr      = mandatoriesfields[i];
+       divid    = "tag_" + arr[0] + "_" + arr[1];
+       varegexp = new RegExp("^tag_" + arr[0] + "_code_");
+       
+               if(parseInt(arr[0]) >= 10){
+               elem = document.getElementById(divid);
+               eleminputs = elem.getElementsByTagName('input');
+               
+               for(var j=0,len2=eleminputs.length; j<len2; j++){
+       
+                       if(eleminputs[j].name.match(varegexp) && eleminputs[j].value){
+                                       inputregexp = new RegExp("^tag_" + arr[0] + "_subfield_" + eleminputs[j].value + "_" + arr[2]);
+                                       
+                                       for( var k=0; k<len2; k++){
+                                               if(eleminputs[k].id.match(inputregexp) && eleminputs[k].value){
+                                                       isempty = false
+                                               }
+                                       }
+                                       
+                                       elemselect = elem.getElementsByTagName('select');
+                                       for( var k=0; k<elemselect.length; k++){
+                                               if(elemselect[k].id.match(inputregexp) && elemselect[k].value){
+                                                       isempty = false
+                                               }
+                                       }
+                       }
+               }
+       }else{
+               isempty = false;
+       }
+       
+       if(isempty){
+               flag = 1;
+               StrAlert += "\t* Field " + arr[0] + " is mandatory, at least one of its subfields must be filled.\n";
+       }
+       
+    }
+    
     if(flag){
            return StrAlert;
        } else {
@@ -102,27 +168,20 @@ function AreMandatoriesNotOk(){
 /** 
  * check if z3950 mandatories are set or not
  */
-function AreZ3950MandoriesOk(){
+function GetZ3950Terms(){
+ var strQuery="&frameworkcode="+document.forms['f'].frameworkcode.value;
     var mandatories = new Array();
     var mandatories_label = new Array();
-       <!-- TMPL_LOOP NAME='BIG_LOOP' --><!-- TMPL_LOOP NAME='innerloop' --><!-- TMPL_LOOP NAME='subfield_loop'--><!-- TMPL_IF NAME='z3950_mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
+    <!-- TMPL_LOOP NAME='BIG_LOOP' --><!-- TMPL_LOOP NAME='innerloop' --><!-- TMPL_LOOP NAME='subfield_loop'--><!-- TMPL_IF NAME='z3950_mandatory'-->mandatories.push("<!-- TMPL_VAR NAME='id' -->");
         mandatories_label.push("<!-- TMPL_VAR NAME='z3950_mandatory' -->");<!-- /TMPL_IF --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP --><!-- /TMPL_LOOP -->
     
-    var error = 0;
-    var strQuery="";
     for(var i=0,len=mandatories.length; i<len ; i++){
         var field_value = document.getElementById(mandatories[i]).value;
-        if( ! field_value ){
-            error++;
-        } else {
+        if( field_value ){
             strQuery += "&"+mandatories_label[i]+"="+field_value;
         }
     }
-    if(error < 5){
-        return strQuery;
-    } else {
-        return false;
-    }
+    return strQuery;
 }
 
 function Changefwk(FwkList) {
@@ -131,12 +190,41 @@ function Changefwk(FwkList) {
 
 }
 
-function openAuth(tagid,authtype,X) {
-//     defaultid=document.getElementById(subfieldid);
-//     alert("X"+X);
-    Y=X.parentNode.getAttribute("id");
-//     alert("tagid"+Y);
-       newin=window.open("../authorities/auth_finder.pl?authtypecode="+  authtype+ "&tagid="+Y, "value builder",'width=700,height=550,toolbar=false,scrollbars=yes');
+// returns the subfieldcode based upon subfieldid writing
+function getSubfieldcode(tagsubfieldid){
+    // 3 : tag +3 : tagnumber +4 : number of _ +8 subfield -1 begins at 0  
+    return tagsubfieldid.substr(3+3+4+8-1,1);
+}
+
+// Take the base of tagsubfield information (removing the subfieldcodes and subfieldindexes)
+// returns the filter
+function getTagInputnameFilter(tagsubfieldid){
+    var tagsubfield=tagsubfieldid.substr(0,tagsubfieldid.lastIndexOf("_"));  
+    var tagcode=tagsubfield.substr(tagsubfield.lastIndexOf("_"));
+    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
+    tagsubfield=tagsubfield.substr(0,tagsubfield.lastIndexOf("_"));
+    tagsubfield=tagsubfield+"_."+tagcode;
+    return tagsubfield;  
+}
+
+function openAuth(tagsubfieldid,authtype) {
+    // let's take the base of tagsubfield information (removing the indexes and the codes
+    var element=document.getElementById(tagsubfieldid);
+    var tagsubfield=getTagInputnameFilter(tagsubfieldid);
+    var elementsubfcode=getSubfieldcode(element.name);
+    var mainmainstring=element.value;
+    var mainstring="";  
+    var inputs = element.parentNode.parentNode.getElementsByTagName("input");
+
+    for (var myindex =0; myindex<inputs.length;myindex++){
+        if (inputs[myindex].name && inputs[myindex].name.match(tagsubfield)){
+            var subfieldcode=getSubfieldcode(inputs[myindex].name);
+            if (isNaN(parseInt(subfieldcode)) && inputs[myindex].value != "" && subfieldcode!=elementsubfcode){
+                mainstring=inputs[myindex].value+" "+mainstring;
+            }      
+        }
+    }           
+       newin=window.open("../authorities/auth_finder.pl?authtypecode="+  authtype+ "&index="+tagsubfieldid+"&value_mainstr="+encodeURI(mainmainstring)+"&value_main="+encodeURI(mainstring), "_blank",'width=700,height=550,toolbar=false,scrollbars=yes');
 }
 
 
@@ -155,10 +243,11 @@ function ExpandField(index) {
 }
 
 /**
- * To clone a field or a subfield by clickink on '+' button
+ * To clone a field or a subfield by clicking on '+' button
  */ 
 function CloneField(index) {
     var original = document.getElementById(index); //original <div>
+    fields_in_use[index.substr(0, 7)]++;
     var clone = original.cloneNode(true);
     var new_key = CreateKey();
     var new_id  = original.getAttribute('id')+new_key;
@@ -169,8 +258,10 @@ function CloneField(index) {
     
     <!-- TMPL_UNLESS NAME='hide_marc'--> // No indicator if hide_marc
         // setting a new name for the new indicator
-        var indicator = clone.getElementsByTagName('input')[0];
-        indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
+        for(var i=0; i < 2; i++) {
+            var indicator = clone.getElementsByTagName('input')[i];
+            indicator.setAttribute('name',indicator.getAttribute('name')+new_key);
+        }
     <!-- /TMPL_UNLESS -->
         
     // settings all subfields
@@ -183,6 +274,12 @@ function CloneField(index) {
             var inputs   = divs[i].getElementsByTagName('input');
             var id_input = "";
             
+            for( j = 0 ; j < inputs.length ; j++ ) {
+               if(inputs[j].getAttribute("id") && inputs[j].getAttribute("id").match(/^tag_/) ){
+                       inputs[j].value = "";
+               }
+            }
+            
             inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
             inputs[0].setAttribute('name',inputs[0].getAttribute('name')+new_key);
             var id_input;
@@ -216,14 +313,15 @@ function CloneField(index) {
                 imgs[0].setAttribute('onclick',"upSubfield(\'"+divs[i].getAttribute('id')+"\');");
             <!-- /TMPL_UNLESS -->
             
-            // setting its '+' button
-            var CloneButtonPlus=0;
+            // setting its '+' and '-' buttons
             try {
-                CloneButtonPlus = divs[i].getElementsByTagName('span')[0];
-                if(CloneButtonPlus.getAttribute('class') == 'buttonPlus'){
-                    CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')");
-                } else {
-                    CloneButtonPlus = 0;
+                var spans = divs[i].getElementsByTagName('span');
+                for (var j = 0; j < spans.length; j++) {
+                    if(spans[j].getAttribute('class') == 'buttonPlus'){
+                        spans[j].setAttribute('onclick',"CloneSubfield('" + divs[i].getAttribute('id') + "')");
+                    } else if (spans[j].getAttribute('class') == 'buttonMinus') {
+                        spans[j].setAttribute('onclick',"UnCloneField('" + divs[i].getAttribute('id') + "')");
+                    }
                 }
             }
             catch(e){
@@ -284,11 +382,18 @@ function CloneField(index) {
             if(divs[i].getAttribute('id').match(/^div_indicator/)){
                 var inputs = divs[i].getElementsByTagName('input');
                 inputs[0].setAttribute('id',inputs[0].getAttribute('id')+new_key);
+                inputs[1].setAttribute('id',inputs[1].getAttribute('id')+new_key);
                 
                 var CloneButtonPlus;
                 try {
-                    CloneButtonPlus = divs[i].getElementsByTagName('span')[1]; // 0 is the title
-                    CloneButtonPlus.setAttribute('onclick',"CloneField('" + divs[i].parentNode.getAttribute('id') + "')");
+                    var anchors = divs[i].getElementsByTagName('a');
+                    for (var j = 0; j < anchors.length; j++) {
+                        if (anchors[j].getAttribute('class') == 'buttonPlus') {
+                            anchors[j].setAttribute('onclick',"CloneField('" + new_id + "')");
+                        } else if (anchors[j].getAttribute('class') == 'buttonMinus') {
+                            anchors[j].setAttribute('onclick',"UnCloneField('" + new_id + "')");
+                        }
+                    }
                 }
                 catch(e){
                     // do nothig CloneButtonPlus doesn't exist.
@@ -313,6 +418,7 @@ function CloneField(index) {
 
 function CloneSubfield(index){
     var original = document.getElementById(index); //original <div>
+    fields_in_use[index.substr(0, 12)]++;
     var clone = original.cloneNode(true);
     var new_key = CreateKey();
     var new_id  = original.getAttribute('id')+new_key;
@@ -353,16 +459,16 @@ function CloneSubfield(index){
     // setting a new if for the parent div
     clone.setAttribute('id',new_id);
     
-    var CloneButtonPlus;
     try {
+        var buttonUp = clone.getElementsByTagName('img')[0];
+        buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
        var spans = clone.getElementsByTagName('span');
        if(spans.length){
                for(var i = 0 ,lenspans = spans.length ; i < lenspans ; i++){
                        if(spans[i].getAttribute('class') == 'buttonPlus'){
-                    CloneButtonPlus = spans[i];
-                    CloneButtonPlus.setAttribute('onclick',"CloneSubfield('" + new_id + "')");
-                    var buttonUp = clone.getElementsByTagName('img')[0];
-                    buttonUp.setAttribute('onclick',"upSubfield('" + new_id + "')");
+                    spans[i].setAttribute('onclick',"CloneSubfield('" + new_id + "')");
+                } else if (spans[i].getAttribute('class') == 'buttonMinus') {
+                    spans[i].setAttribute('onclick',"UnCloneField('" + new_id + "')");
                 }
             }
         }
@@ -374,6 +480,39 @@ function CloneSubfield(index){
     original.parentNode.insertBefore(clone,original.nextSibling);
 }
 
+ /**
+ * This function removes or clears unwanted subfields
+ */
+function UnCloneField(index) {
+    var original = document.getElementById(index);
+    var field_id;
+    if (index.match("tag")) {
+        field_id = index.substr(0, 7);
+    } else {
+        field_id = index.substr(0, 12);
+    }
+    if (1 == fields_in_use[field_id]) {
+        // clear inputs, but don't delete
+        $(":input.input_marceditor", original).each(function(){
+            // thanks to http://www.learningjquery.com/2007/08/clearing-form-data for
+            // hint about clearing selects correctly
+            var type = this.type;
+            var tag = this.tagName.toLowerCase();
+            if (type == 'text' || type == 'password' || tag == 'textarea') {
+                this.value = "";
+            } else if (type == 'checkbox' || type == 'radio') {
+                this.checked = false;
+            } else if (tag == 'select') {
+                this.selectedIndex = -1;
+            }
+        });
+        $(":input.indicator", original).val("");
+    } else {
+        original.parentNode.removeChild(original);
+        fields_in_use[field_id]--;
+    }
+}
+
 /**
  * This function create a random number
  */
@@ -421,7 +560,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
 }
 //]]>
 </script>
-<link rel="stylesheet" href="<!-- TMPL_VAR NAME="themelang" -->/css/addbiblio.css" />
+<link type="text/css" rel="stylesheet" href="<!-- TMPL_VAR NAME="themelang" -->/css/addbiblio.css" />
 </head>
 <body>
 <div id="yui-cms-loading">
@@ -441,7 +580,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
 //]]>
 </script>
 <!-- TMPL_INCLUDE NAME="header.inc" -->
-<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloguing</a>  &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Edit MARC Record Number <!-- TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></div>
+<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/cataloguing/addbooks.pl">Cataloging</a>  &rsaquo; <!-- TMPL_IF NAME="biblionumber" -->Editing <em><!-- TMPL_VAR NAME="title" escape="html" --></em> (Record Number <!-- TMPL_VAR name="biblionumber" -->)<!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></div>
 
 <div id="doc" class="yui-t7">
 
@@ -451,7 +590,7 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
 
 
 
-<h1><!-- TMPL_IF NAME="biblionumber" -->Edit MARC Record Number <!-- TMPL_VAR name="biblionumber" --><!-- TMPL_ELSE -->Add MARC Record<!-- /TMPL_IF --></h1>
+<h1><!-- TMPL_IF NAME="biblionumber" -->Editing <em><!-- TMPL_VAR NAME="title" escape="html" --></em> (Record Number <!-- TMPL_VAR name="biblionumber" -->)</h1><!-- TMPL_ELSE -->Add MARC Record</h1><!-- /TMPL_IF -->
 
 <!-- TMPL_UNLESS name="number" -->
     <!-- show duplicate warning on tab 0 only -->
@@ -555,52 +694,66 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
        <div class="tag" id="tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->">
         <div class="tag_title" id="div_indicator_tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->">
             <!-- TMPL_UNLESS name="hide_marc" -->
-                <span title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --></span>
+               <!-- TMPL_IF NAME="advancedMARCEditor" -->
+               <a href="#" tabindex="1" class="tagnum" title="<!-- TMPL_VAR NAME="tag_lib"--> - Click to Expand this Tag" onclick="ExpandField('tag_<!-- TMPL_VAR NAME="tag"-->_<!-- TMPL_VAR NAME='index' --><!-- TMPL_VAR NAME="random" -->'); return false;"><!-- TMPL_VAR NAME="tag" --></a>
+               <!-- TMPL_ELSE -->
+                       <span class="tagnum" title="<!-- TMPL_VAR NAME="tag_lib" -->"><!-- TMPL_VAR NAME="tag" --></span>
+               <!-- /TMPL_IF -->
                 <!-- TMPL_IF NAME="fixedfield" -->
-                       <input tabindex="1" class="indicator flat" type="text" style="display:none;" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="2" maxlength="2" value="<!-- TMPL_VAR NAME="indicator" -->" />
+                       <input tabindex="1" class="indicator flat" type="text" style="display:none;" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator1_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="1" maxlength="1" value="<!-- TMPL_VAR NAME="indicator1" -->" />
+                       <input tabindex="1" class="indicator flat" type="text" style="display:none;" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator2_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="1" maxlength="1" value="<!-- TMPL_VAR NAME="indicator2" -->" />
                 <!-- TMPL_ELSE -->
-                       <input tabindex="1" class="indicator flat" type="text" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="2" maxlength="2" value="<!-- TMPL_VAR NAME="indicator" -->" />
+                       <input tabindex="1" class="indicator flat" type="text" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator1_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="1" maxlength="1" value="<!-- TMPL_VAR NAME="indicator1" -->" />
+                       <input tabindex="1" class="indicator flat" type="text" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator2_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" size="1" maxlength="1" value="<!-- TMPL_VAR NAME="indicator2" -->" />
                 <!-- /TMPL_IF --> -
             <!-- TMPL_ELSE -->
                 <!-- TMPL_IF NAME="fixedfield" -->
-                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator" -->" />
+                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator1_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
+                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator2_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
                 <!-- TMPL_ELSE -->
-                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator" -->" />
+                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator1_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
+                    <input tabindex="1" type="hidden" name="tag_<!-- TMPL_VAR NAME="tag" -->_indicator2_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
                 <!-- /TMPL_IF -->
             <!-- /TMPL_UNLESS -->
 
             <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
-                   <a href="#" class="expandfield" onclick="ExpandField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->'); return false;" title="Click to Expand this Tag"><!-- TMPL_VAR NAME="tag_lib" --></a>
+                   <a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->'); return false;" title="Click to Expand this Tag"><!-- TMPL_VAR NAME="tag_lib" --></a>
             <!-- /TMPL_UNLESS -->
             <!-- TMPL_IF name="repeatable" -->
-                <a href="#" class="buttonPlus" onclick="CloneField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->'); return false;" title="Repeat this Tag">+</a>
+                <a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->'); return false;" title="Repeat this Tag">+</a>
             <!-- /TMPL_IF -->
+            <!-- TMPL_UNLESS name="mandatory" -->
+                <a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_<!-- TMPL_VAR name="tag"-->_<!-- TMPL_VAR NAME='index'--><!-- TMPL_VAR name="random" -->'); return false;" title="Delete this Tag">&#8722;</a>
+            <!-- /TMPL_UNLESS -->
             
         </div>
        
         <!-- TMPL_LOOP NAME="subfield_loop" -->
             <!--  One line on the marc editor -->
-            <div class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->;" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
+            <div class="subfield_line" style="<!-- TMPL_VAR NAME='visibility' -->; float: left; clear: left; width: 100%;" id="subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->">
             
                 <!--TMPL_UNLESS NAME="advancedMARCEditor" -->
                     <label for="tag_<!-- TMPL_VAR NAME='tag'-->_subfield_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->" <!-- TMPL_IF NAME="fixedfield" --> style="display:none;" <!-- /TMPL_IF --> class="labelsubfield">
                 <!-- /TMPL_UNLESS --> 
                 
                 <!-- TMPL_UNLESS name="hide_marc" -->
-                <!-- TMPL_IF NAME="fixedfield" --> 
+                <span class="subfieldcode"><!-- TMPL_IF NAME="fixedfield" --> 
                         <img class="buttonUp" style="display:none;" src="<!-- TMPL_VAR NAME="themelang" -->/../img/up.png" onclick="upSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')" alt="Move Up" title="Move Up" />
                     <!-- TMPL_ELSE -->
                         <img class="buttonUp" src="<!-- TMPL_VAR NAME="themelang" -->/../img/up.png" onclick="upSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')" alt="Move Up" title="Move Up" />
-                    <!-- /TMPL_IF --> 
-                        <input title="<!-- TMPL_VAR NAME='marc_lib_plain' -->" style=" <!-- TMPL_IF NAME="fixedfield" -->display:none; <!-- /TMPL_IF -->border:0;" type="text" name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->" value="<!-- TMPL_VAR NAME="subfield" -->" size="1" maxlength="1" class="flat" tabindex="-1" />
+                    <!-- /TMPL_IF -->
+                        <input title="<!-- TMPL_VAR NAME='marc_lib_plain' -->" style=" <!-- TMPL_IF NAME="fixedfield" -->display:none; <!-- /TMPL_IF -->border:0;" type="text" tabindex="0" name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->" value="<!-- TMPL_VAR NAME="subfield" -->" size="1" maxlength="1" class="flat" />
+ </span>
                 <!-- TMPL_ELSE -->
                     <input type="hidden" name="tag_<!-- TMPL_VAR NAME='tag'-->_code_<!--  TMPL_VAR NAME='subfield'-->_<!-- TMPL_VAR NAME='index'-->_<!-- TMPL_VAR NAME='index_subfield'-->" value="<!-- TMPL_VAR NAME="subfield" -->" />
+ </span>
                 <!-- /TMPL_UNLESS -->
             
                 <!-- TMPL_UNLESS NAME="advancedMARCEditor" -->
-                    <!-- TMPL_IF name="mandatory" --><span class="subfield_mandatory"><!-- /TMPL_IF -->
-                        <!-- TMPL_VAR NAME="marc_lib" -->
-                    <!-- TMPL_IF name="mandatory" --></span><!-- /TMPL_IF -->
+                    <!-- TMPL_IF name="mandatory" --><span class="subfield subfield_mandatory"><!-- TMPL_ELSE --><span class="subfield"><!-- /TMPL_IF -->
+                        <!-- TMPL_VAR NAME="marc_lib_plain" -->
+                        <!-- TMPL_IF NAME="mandatory" --><span class="mandatory_marker" title="This field is mandatory">*</span><!-- /TMPL_IF -->
+                    </span>
                     </label>
                 <!-- /TMPL_UNLESS -->
                 
@@ -609,6 +762,9 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
                 <!-- TMPL_IF NAME="repeatable" -->
                     <span class="buttonPlus" onclick="CloneSubfield('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">+</span>
                 <!-- /TMPL_IF -->
+                <!-- TMPL_UNLESS NAME="mandatory" -->
+                    <span class="buttonMinus" onclick="UnCloneField('subfield<!-- TMPL_VAR NAME='tag' --><!-- TMPL_VAR NAME='subfield' --><!-- TMPL_VAR name="random" -->')">&#8722;</span>
+                <!-- /TMPL_UNLESS -->
                 
             </div>
             <!-- End of the line -->
@@ -619,7 +775,6 @@ function unHideSubfield(index,labelindex) { // FIXME :: is it used ?
     <!-- /TMPL_LOOP -->
     </div>
 <!-- /TMPL_LOOP -->
-
 </div>
 </form>