Koha/koha-tmpl/intranet-tmpl/prog/en/modules/authorities/authorities.tt
Jonathan Druart 42f2d0b179 Bug 8399: Display tab number on the mandatory field alert (authority)
A wrong variable scope was used here, the number value is contained in
the BIG_LOOP (note for later: change this variable name...).

Test plan:
1/ Define 1+ mandatory fields for an authority type
2/ Create an authority and don't fill the mandatory fields
3/ Try to save: the popup alert should display the number of the tab.

Signed-off-by: Andreas Hedström Mace <andreas.hedstrom.mace@sub.su.se>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>
Signed-off-by: Tomas Cohen Arazi <tomascohen@gmail.com>
2015-05-18 12:11:23 -03:00

431 lines
21 KiB
Text

[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Authorities &rsaquo; [% IF ( authid ) %]Modify authority #[% authid %] ([% authtypetext %])[% ELSE %]Adding authority ([% authtypetext %])[% END %]</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript" src="[% interface %]/lib/jquery/plugins/jquery.fixFloat.js"></script>
<script type="text/javascript" src="[% themelang %]/js/cataloging.js"></script>
<script type="text/javascript">
//<![CDATA[
$(window).load(function(){
$("#loading").hide();
});
$(document).ready(function() {
$('#authoritytabs').tabs();
$('#toolbar').fixFloat();
$("#addauth").click(function(){
if(Check()){
$("#f").submit();
}
});
$("#z3950submit").click(function(){
if (confirm(_("Please note that this Z39.50 search could replace the current record."))){
var strQuery = GetZ3950Terms();
if(strQuery){
window.open("/cgi-bin/koha/cataloguing/z3950_auth_search.pl?authid=[% authid %]"+strQuery,"z3950search",'width=740,height=450,location=yes,toolbar=no,scrollbars=yes,resize=yes');
}
}
return false;
});
});
/**
* check if z3950 mandatories are set or not
*/
function GetZ3950Terms(){
var strQuery="&authtypecode="+document.forms['f'].authtypecode.value;
var mandatories = new Array();
var mandatories_label = new Array();
[% 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 %]");
mandatories_label.push("[% subfield_loo.z3950_mandatory %]");[% END %][% END %][% END %][% END %]
for(var i=0,len=mandatories.length; i<len ; i++){
var field_value = document.getElementById(mandatories[i]).value;
if( field_value ){
strQuery += "&"+mandatories_label[i]+"="+field_value;
}
}
return strQuery;
}
/**
* check if mandatory subfields are written
*/
function AreMandatoriesNotOk(){
var mandatories = new Array();
var mandatoriesfields = new Array();
var tab = new Array();
var label = new Array();
[% FOREACH BIG_LOO IN BIG_LOOP %]
[% FOREACH innerloo IN BIG_LOO.innerloop %]
[% IF ( innerloo.mandatory ) %]
mandatoriesfields.push(new Array("[% innerloo.tag %]","[% innerloo.index %][% innerloo.random %]","[% innerloo.index %]"));
[% END %]
[% FOREACH subfield_loo IN innerloo.subfield_loop %]
[% IF ( subfield_loo.mandatory ) %]mandatories.push("[% subfield_loo.id %]");
tab.push("[% BIG_LOO.number %]");
label.push("[% subfield_loo.marc_lib |replace("'", "\'") |replace('"', '\"') |replace('\n', '\\n') |replace('\r', '\\r') %]");
[% END %]
[% END %]
[% END %]
[% END %]
var StrAlert = "";
for(var i=0,len=mandatories.length; i<len ; i++){
var id_string = mandatories[i];
// alert (id_string);
if( ! $("#" + id_string).val() ){
$("#" + id_string).attr('class','subfield_not_filled').focus();
StrAlert += "\t* " + _("%s in tab %s").format(label[i], tab[i]) + "\n";
}
}
/* 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
}
}
}
}
}else{
isempty = false;
}
if(isempty){
flag = 1;
StrAlert += "\t* " + _("Field %s is mandatory, at least one of its subfields must be filled.").format(arr[0]) + "\n";
}
}
if(StrAlert){
return _("Can't save this record because the following field aren't filled :") + "\n\n" + StrAlert;
}
return false;
}
function Check(){
var StrAlert = AreMandatoriesNotOk();
if( ! StrAlert ){
document.f.submit();
return true;
} else {
alert(StrAlert);
return false;
}
}
function AddField(field,cntrepeatfield) {
document.forms['f'].op.value = "addfield";
document.forms['f'].addfield_field.value=field;
document.forms['f'].repeat_field.value=cntrepeatfield;
document.f.submit();
}
function addauthority() {
X = document.forms[0].authtype.value;
window.location="/cgi-bin/koha/authorities/authorities.pl?authtypecode="+X;
}
function searchauthority() {
X = document.forms[0].authtype2.value;
Y = document.forms[0].value.value;
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";
}
function confirmnotdup(redirect){
$("#confirm_not_duplicate").attr("value","1");
Check();
}
//]]>
</script>
<link type="text/css" rel="stylesheet" href="[% themelang %]/css/addbiblio.css" />
[% IF ( bidi ) %]
<link rel="stylesheet" type="text/css" href="[% themelang %]/css/right-to-left.css" />
[% END %]
</head>
<body id="auth_authorities" class="auth">
<div id="loading">
<div>Loading, please wait...</div>
</div>
[% INCLUDE 'header.inc' %]
<div id="breadcrumbs"><a href="/cgi-bin/koha/mainpage.pl">Home</a> &rsaquo; <a href="/cgi-bin/koha/authorities/authorities-home.pl">Authorities</a> &rsaquo; [% IF ( authid ) %]Modify authority #[% authid %] ([% authtypetext %])[% ELSE %]Adding authority [% authtypetext %][% END %] </div>
<div id="doc" class="yui-t7">
<div id="bd">
<div id="yui-main">
<div class="yui-g">
[% IF ( authid ) %]
<h1>Modify authority #[% authid %] [% authtypetext %]</h1>
[% ELSE %]
<h1>Adding authority [% authtypetext %]</h1>
[% END %]
[% IF ( duplicateauthid ) %]
<div class="dialog alert">
<h4>Duplicate record suspected</h4>
<p>Is this a duplicate of <a href="/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]" onclick="openWindow('/cgi-bin/koha/authorities/detail.pl?authid=[% duplicateauthid %]&amp;popup=1', 'DuplicateAuthority','800','600'); return false;" class="button">[% duplicateauthvalue %]</a>?</p>
<form action="authorities.pl" method="get">
<input type="hidden" name="authid" value="[% duplicateauthid %]" />
<input type="submit" class="edit" value="Yes: Edit existing authority" />
</form>
<form action="authorities.pl" method="get">
<input type="button" value="No: Save as new authority" class="save" accesskey="w" onclick="confirmnotdup('items'); return false;" />
</form>
</div>
[% END %]
<form method="post" name="f" action="/cgi-bin/koha/authorities/authorities.pl">
<input type="hidden" name="op" value="add" />
<input type="hidden" name="addfield_field" value="" />
<input type="hidden" name="repeat_field" value="" />
<input type="hidden" name="authtypecode" value="[% authtypecode %]" />
<input type="hidden" name="authid" value="[% authid %]" />
<input type="hidden" name="index" value="[% index %]" />
<input type="hidden" value="0" id="confirm_not_duplicate" name="confirm_not_duplicate" />
<div id="toolbar" class="btn-toolbar">
<div class="btn-group"><a href="#" id="addauth" class="btn btn-small" accesskey="w"><i class="icon-hdd"></i> Save</a></div>
<div class="btn-group">
<a class="btn btn-small" id="z3950submit" href="#"><i class="icon-search"></i> Z39.50 search</a>
</div>
</div>
<div id="authoritytabs" class="toptabs numbered">
<ul>
[% FOREACH BIG_LOO IN BIG_LOOP %]
<li><a href="#tab[% BIG_LOO.number %]XX">[% BIG_LOO.number %]</a></li>
[% END %]
</ul>
[% FOREACH BIG_LOO IN BIG_LOOP %]
<div id="tab[% BIG_LOO.number %]XX">
[% FOREACH innerloo IN BIG_LOO.innerloop %]
[% IF ( innerloo.tag ) %]
<div class="tag clearfix" id="tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
<div class="tag_title" id="div_indicator_tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]">
[% UNLESS hide_marc %]
[% IF advancedMARCEditor %]
<a href="#" tabindex="1" class="tagnum" title="[% innerloo.tag_lib %] - Click to Expand this Tag" onclick="ExpandField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]'); return false;">[% innerloo.tag %]</a>
[% ELSE %]
<span title="[% innerloo.tag_lib %]">[% innerloo.tag %]</span>
[% END %]
[% IF ( innerloo.fixedfield ) %]
<input type="text"
tabindex="1"
class="indicator flat"
style="display:none;"
name="tag_[% innerloo.tag %]_indicator1_[% innerloo.index %][% innerloo.random %]"
size="1"
maxlength="1"
value="[% innerloo.indicator1 %]" />
<input type="text"
tabindex="1"
class="indicator flat"
style="display:none;"
name="tag_[% innerloo.tag %]_indicator2_[% innerloo.index %][% innerloo.random %]"
size="1"
maxlength="1"
value="[% innerloo.indicator2 %]" />
[% ELSE %]
<input type="text"
tabindex="1"
class="indicator flat"
name="tag_[% innerloo.tag %]_indicator1_[% innerloo.index %][% innerloo.random %]"
size="1"
maxlength="1"
value="[% innerloo.indicator1 %]" />
<input type="text"
tabindex="1"
class="indicator flat"
name="tag_[% innerloo.tag %]_indicator2_[% innerloo.index %][% innerloo.random %]"
size="1"
maxlength="1"
value="[% innerloo.indicator2 %]" />
[% END %] -
[% ELSE %]
[% IF ( innerloo.fixedfield ) %]
<input type="hidden"
tabindex="1"
name="tag_[% innerloo.tag %]_indicator1_[% innerloo.index %][% innerloo.random %]"
value="[% innerloo.indicator1 %]" />
<input type="hidden"
tabindex="1"
name="tag_[% innerloo.tag %]_indicator2_[% innerloo.index %][% innerloo.random %]"
value="[% innerloo.indicator2 %]" />
[% ELSE %]
<input type="hidden"
tabindex="1"
name="tag_[% innerloo.tag %]_indicator1_[% innerloo.index %][% innerloo.random %]"
value="[% innerloo.indicator1 %]" />
<input type="hidden"
tabindex="1"
name="tag_[% innerloo.tag %]_indicator2_[% innerloo.index %][% innerloo.random %]"
value="[% innerloo.indicator2 %]" />
[% END %]
[% END %]
[% UNLESS advancedMARCEditor %]
<a href="#" tabindex="1" class="expandfield" onclick="ExpandField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]'); return false;" title="Click to Expand this Tag">[% innerloo.tag_lib %]</a>
[% END %]
<span class="field_controls">
[% IF ( innerloo.repeatable ) %]
<a href="#" tabindex="1" class="buttonPlus" onclick="CloneField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]','[% hide_marc %]','[% advancedMARCEditor %]'); return false;" title="Repeat this Tag">
<img src="[% interface %]/[% theme %]/img/repeat-tag.png" alt="Repeat this Tag" />
</a>
[% END %]
<a href="#" tabindex="1" class="buttonMinus" onclick="UnCloneField('tag_[% innerloo.tag %]_[% innerloo.index %][% innerloo.random %]'); return false;" title="Delete this Tag">
<img src="[% interface %]/[% theme %]/img/delete-tag.png" alt="Delete this Tag" />
</a>
</span>
</div>
[% FOREACH subfield_loo IN innerloo.subfield_loop %]
<!-- One line on the marc editor -->
<div class="subfield_line" style="[% subfield_loo.visibility %]" id="subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]">
[% UNLESS advancedMARCEditor %]
[% IF ( subfield_loo.fixedfield ) %]<label for="tag_[% subfield_loo.tag %]_subfield_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]" style="display:none;" class="labelsubfield">
[% ELSE %]<label for="tag_[% subfield_loo.tag %]_subfield_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]" class="labelsubfield">
[% END %]
[% END %]
[% UNLESS hide_marc %]
<span class="subfieldcode">
[% IF ( subfield_loo.fixedfield ) %]
<img class="buttonUp" style="display:none;" src="[% interface %]/[% theme %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
[% ELSE %]
<img class="buttonUp" src="[% interface %]/[% theme %]/img/up.png" onclick="upSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]')" alt="Move Up" title="Move Up" />
[% END %]
<input type="text"
title="[% subfield_loo.marc_lib %]"
style=" [% IF ( subfield_loo.fixedfield ) %]display:none; [% END %]border:0;"
name="tag_[% subfield_loo.tag %]_code_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]"
value="[% subfield_loo.subfield %]"
size="1"
maxlength="1"
class="flat"
tabindex="0" />
</span>
[% ELSE %]
<input type="hidden"
name="tag_[% subfield_loo.tag %]_code_[% subfield_loo.subfield %]_[% subfield_loo.index %]_[% subfield_loo.index_subfield %]"
value="[% subfield_loo.subfield %]" />
[% END %]
[% UNLESS advancedMARCEditor %]
[% IF ( subfield_loo.mandatory ) %]<span class="subfield subfield_mandatory">[% ELSE %]<span class="subfield">[% END %]
[% subfield_loo.marc_lib %]
[% IF ( subfield_loo.mandatory ) %]<span class="mandatory_marker" title="This field is mandatory">*</span>[% END %]
</span>
</label>
[% END %]
[% SET mv = subfield_loo.marc_value %]
[% IF ( mv.type == 'select' ) %]
<select name="[%- mv.name -%]" tabindex="1" size="1" class="input_marceditor" id="[%- mv.id -%]">
[% FOREACH aval IN mv.values %]
[% IF aval == mv.default %]
<option value="[%- aval -%]" selected="selected">[%- mv.labels.$aval -%]</option>
[% ELSE %]
<option value="[%- aval -%]">[%- mv.labels.$aval -%]</option>
[% END %]
[% END %]
</select>
[% ELSIF ( mv.type == 'text1' ) %]
<input type="text" id="[%- mv.id -%]" name="[%- mv.id -%]" value="[%- mv.value -%]" class="input_marceditor" tabindex="1" />
<a href="#" class="buttonDot" onclick="openAuth(this.parentNode.getElementsByTagName('input')[1].id,'[%- mv.authtypecode -%]','auth'); return false;" tabindex="1" title="Tag editor">...</a>
[% ELSIF ( mv.type == 'text2' ) %]
<input type="text" id="[%- mv.id -%]" size="67" maxlength="[%- mv.maxlength -%]" name="[%- mv.name -%]" value="[%- mv.value -%]" class="input_marceditor" />
[% IF mv.noclick %]
<a href="#" class="buttonDot tag_editor disabled" tabindex="-1" title="No popup">...</a>
[% ELSE %]
<a href="#" id="buttonDot_[% mv.id %]" class="buttonDot tag_editor" title="Tag editor">...</a>
[% END %]
[% mv.javascript %]
[% ELSIF ( mv.type == 'text' ) %]
<input type="text" id="[%- mv.id -%]" name="[%- mv.name -%]" value="[%- mv.value -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength -%]" />
[% ELSIF ( mv.type == 'textarea' ) %]
<textarea cols="70" rows="4" id="[%- mv.id -%]" name="[%- mv.name -%]" class="input_marceditor" tabindex="1" size="67" maxlength="[%- mv.maxlength -%]">[%- mv.value -%]</textarea>
[% ELSIF ( mv.type == 'hidden' ) %]
<input tabindex="1" type="hidden" id="[%- mv.id -%]" name="[%- mv.name -%]" size="67" maxlength="[%- mv.maxlength -%]" value="[%- mv.value -%]" />
[% ELSIF ( mv.type == 'hidden_simple' ) %]
<input type="hidden" name="[%- mv.name -%]" />
[% END %]
<span class="subfield_controls">
[% IF ( subfield_loo.repeatable ) %]
<a href="#" class="buttonPlus" tabindex="1" onclick="CloneSubfield('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]','[% advancedMARCEditor %]'); return false;">
<img src="[% interface %]/[% theme %]/img/clone-subfield.png" alt="Clone" title="Clone this subfield" />
</a>
<a href="#" class="buttonMinus" tabindex="1" onclick="UnCloneField('subfield[% subfield_loo.tag %][% subfield_loo.subfield %][% subfield_loo.random %]'); return false;">
<img src="[% interface %]/[% theme %]/img/delete-subfield.png" alt="Delete" title="Delete this subfield" />
</a>
[% END %]
</span>
</div>
<!-- End of the line -->
[% END %]
</div>
[% END %]<!-- if innerloo.tag -->
[% END %]<!-- BIG_LOO.innerloop -->
</div>
[% END %]<!-- BIG_LOOP -->
</div><!-- tabs -->
<div name="hidden" id="hidden" class="tab">
[% FOREACH hidden_loo IN hidden_loop %]
<input type="hidden" name="tag" value="[% hidden_loo.tag %]" />
<input type="hidden" name="subfield" value="[% hidden_loo.subfield %]" />
<input type="hidden" name="mandatory" value="[% hidden_loo.mandatory %]" />
<input type="hidden" name="kohafield" value="[% hidden_loo.kohafield %]" />
<input type="hidden" name="tag_mandatory" value="[% hidden_loo.tag_mandatory %]" />
[% END %]
</div>
[% IF ( oldauthnumtagfield ) %]
<input type="hidden" name="tag" value="[% oldauthnumtagfield %]" />
<input type="hidden" name="subfield" value="[% oldauthnumtagsubfield %]" />
<input type="hidden" name="field_value" value="[% authid %]" />
<input type="hidden" name="mandatory" value="0" />
<input type="hidden" name="kohafield" value="[% kohafield %]" />
<input type="hidden" name="tag_mandatory" value="[% tag_mandatory %]" />
<input type="hidden" name="tag" value="[% oldauthtypetagfield %]" />
<input type="hidden" name="subfield" value="[% oldauthtypetagsubfield %]" />
<input type="hidden" name="field_value" value="[% authtypecode %]" />
[% END %]
<fieldset class="action">
<input type="button" id="addauth2" value="Save" onclick="Check(this.form)" accesskey="w" />
</fieldset>
</form>
</div>
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]