Koha/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tmpl
Paul Poulain 3a29f37dff Bug 5726 : MT1059 Follow-up : Fix merge reference selection presentation
A change in global-staff.css messed the merge reference selection presentation

    Signed-off-by: Henri-Damien LAURENT <henridamien.laurent@biblibre.com>

Signed-off-by: Chris Cormack <chrisc@catalyst.net.nz>
2011-02-09 13:47:00 +13:00

354 lines
14 KiB
Cheetah

<!-- TMPL_INCLUDE NAME="doc-head-open.inc" -->
<title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
<!-- TMPL_INCLUDE NAME="doc-head-close.inc" -->
<style type="text/css">
div.record ul, div.record li { float:none; display:block; }
div#result { margin-top: 1em; }
/* We use this style "against" the li ui-tabs-nav style automatically applied */
</style>
<script type="text/javascript">
//<![CDATA[
// When submiting the form
function mergeformsubmit() {
$("ul#ulrecord1").remove();
$("ul#ulrecord2").remove();
}
$(document).ready(function(){
// Creating tabs
$("#tabs > ul").tabs();
// Getting marc structure via ajax
tagslib = [];
$.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "<!-- TMPL_VAR name="framework" -->" }, function(json) {
tagslib = json;
});
// Toggle a field / subfield
function toggleField(pField) {
// Getting the key of the clicked checkbox
var ckid = $(pField).attr("id");
var tab = ckid.split('_');
var source = tab[1]; // From which record the click came from
var key = tab[2];
var type = $(pField).attr("class");
// Getting field/subfield
var field;
var subfield;
if (type == "subfieldpick") {
field = $(pField).parent().parent().parent().find("span.field").text();
subfield = $(pField).parent().find("span.subfield").text();
} else {
field = $(pField).parent().find("span.field").text();
}
// If the field has just been checked
if (pField.checked) {
// We check for repeatability
var canbeadded = true;
if (type == "subfieldpick") {
var repeatable = 1;
var alreadyexists = 0;
if (tagslib[field] && tagslib[field][subfield]) {
repeatable = tagslib[field][subfield].repeatable; // Note : we can't use the dot notation here (tagslib.021) because the key is a number
// TODO : Checking for subfields
}
} else {
if (tagslib[field]) {
repeatable = tagslib[field].repeatable;
alreadyexists = $("#resultul span.field:contains(" + field + ")");
if (repeatable == 0 && alreadyexists.length != 0) {
canbeadded = false;
}
}
}
// If the field is not repeatable, we check if it already exists in the result table
if (canbeadded == false) {
alert(_('The field is non-repeatable and already exists in the destination record. Therefore, you cannot add it.'));
pField.checked = 0;
} else {
// Cloning the field or subfield we picked
var clone = $(pField).parent().clone();
// Removing the checkboxes from it
$(clone).find("input.subfieldpick, input.fieldpick").each(function() {
$(this).remove();
});
// If we are a subfield
if (type == "subfieldpick") {
// then we need to find who is our parent field...
fieldkey = $(pField).parent().parent().parent().attr("id");
// Find where to add the subfield
// First, check if the field is not already in the destination record
if ($("#resultul li#" + fieldkey).length > 0) {
// If so, we add our field to it
$("#resultul li#" + fieldkey + " ul").append(clone);
} else {
// If not, we add the subfield to the first matching field
var where = 0;
$("#resultul li span.field").each(function() {
if (where == 0 && $(this).text() == field) {
where = this;
}
});
// If there is no matching field in the destination record
if (where == 0) {
// TODO:
// We select the whole field and removing non-selected subfields, instead of...
// Alerting the user
alert(_('This subfield cannot be added: there is no ' + field + ' field in the destination record.'));
pField.checked = false;
} else {
$(where).nextAll("ul").append(clone);
}
}
} else {
// If we are a field
var where = 0;
// Find where to add the field
$("#resultul li span.field").each(function() {
if (where == 0 && $(this).text() > field) {
where = this;
}
});
$(where).parent().before(clone);
}
}
} else {
// Else, we remove it from the results tab
$("ul#resultul li#k" + key).remove();
}
}
// When a field is checked / unchecked
$('input.fieldpick').click(function() {
toggleField(this);
// (un)check all subfields
var ischecked = this.checked;
$(this).parent().find("input.subfieldpick").each(function() {
this.checked = ischecked;
});
});
// When a field or subfield is checked / unchecked
$("input.subfieldpick").click(function() {
toggleField(this);
});
});
//]]>
</script>
</head>
<body>
<!-- TMPL_INCLUDE NAME="header.inc" -->
<!-- TMPL_INCLUDE NAME="cataloging-search.inc" -->
<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">
<div id="bd">
<div id="yui-main">
<h1>Merging records</h1>
<!-- TMPL_IF name="result" -->
<!-- TMPL_IF name="errors" -->
<!-- TMPL_LOOP name="errors" -->
<div class="dialog alert"><!-- TMPL_VAR name="error" -->.<br />Therefore, the record to be merged has not been deleted.</div>
<!-- /TMPL_LOOP -->
<!-- TMPL_ELSE -->
<script type="text/javascript">window.location.href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->"</script>
<p>The merging was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=<!-- TMPL_VAR NAME="biblio1" -->">Click here to see the merged record.</a></p>
<!-- /TMPL_IF -->
<!-- TMPL_ELSE -->
<!-- TMPL_IF NAME="choosereference" -->
<p>Please choose which record will be the reference for the merge. The record chosen as reference will be kept, and the other will be deleted.</p>
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post">
<fieldset class="rows">
<legend>Merge reference</legend>
<ol>
<li class="radio"><input type="radio" value="<!-- TMPL_VAR NAME="biblio1" -->" checked="checked" id="mergereference1" name="mergereference" /><label style="float:none" for="mergereference1"><!-- TMPL_VAR NAME="title1" --> (<!-- TMPL_VAR NAME="biblio1" -->)</label></li>
<li class="radio"><input type="radio" value="<!-- TMPL_VAR NAME="biblio2" -->" id="mergereference2" name="mergereference" /><label style="float:none" for="mergereference2"><!-- TMPL_VAR NAME="title2" --> (<!-- TMPL_VAR NAME="biblio2" -->)</label></li>
</ol>
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio1" -->" />
<input type="hidden" name="biblionumber" value="<!-- TMPL_VAR name="biblio2" -->" />
<fieldset class="action"><input type="submit" value="Next" /></fieldset>
</fieldset>
</form>
<!-- TMPL_ELSE -->
<!-- TMPL_IF name="errors" -->
<!-- TMPL_LOOP name="errors" -->
<div class="error"><!-- TMPL_VAR name="error" --></div>
<!-- /TMPL_LOOP -->
<!-- TMPL_ELSE -->
<form id="mergeform" action="/cgi-bin/koha/cataloguing/merge.pl" method="post" onsubmit="return mergeformsubmit()">
<div class="yui-g">
<div class="yui-u first">
<div id="tabs" class="toptabs">
<h2>Source records</h2>
<ul>
<li><a href="#tabrecord1"><!-- TMPL_VAR name="biblio1" --></a></li>
<li><a href="#tabrecord2"><!-- TMPL_VAR name="biblio2" --></a></li>
</ul>
<div id="tabrecord1">
<!-- TMPL_IF name="record1" -->
<div class="record">
<ul id="ulrecord1">
<!-- TMPL_LOOP NAME="record1" -->
<!-- TMPL_LOOP NAME="field" -->
<li id="k<!-- TMPL_VAR name="key" -->">
<input type="checkbox" checked="checked" class="fieldpick" id="rec_1_<!-- TMPL_VAR name="key" -->" />
<span class="field"><!-- TMPL_VAR NAME="tag" --></span>
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
<!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="subfield" -->
<ul>
<!-- TMPL_LOOP NAME="subfield" -->
<li id="k<!-- TMPL_VAR name="subkey" -->">
<input type="checkbox" checked="checked" class="subfieldpick" id="rec_1_<!-- TMPL_VAR name="subkey" -->" />
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
</li>
<!-- /TMPL_LOOP -->
</ul>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</li>
<!-- /TMPL_LOOP -->
</ul>
</div><!-- /div.record -->
<!-- /TMPL_IF -->
</div><!-- /div#tabrecord1 -->
<div id="tabrecord2">
<!-- TMPL_IF name="record2" -->
<div class="record">
<ul id="ulrecord2">
<!-- TMPL_LOOP NAME="record2" -->
<!-- TMPL_LOOP NAME="field" -->
<li id="k<!-- TMPL_VAR name="key" -->">
<input type="checkbox" class="fieldpick" id="rec_2_<!-- TMPL_VAR name="key" -->" />
<span class="field"><!-- TMPL_VAR NAME="tag" --></span>
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
<!-- TMPL_IF NAME="value" --> / <!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="subfield" -->
<ul>
<!-- TMPL_LOOP NAME="subfield" -->
<li id="k<!-- TMPL_VAR name="subkey" -->">
<input type="checkbox" class="subfieldpick" id="rec_2_<!-- TMPL_VAR name="subkey" -->" />
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
</li>
<!-- /TMPL_LOOP -->
</ul>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</li>
<!-- /TMPL_LOOP -->
</ul>
</div>
<!-- /div.record -->
<!-- /TMPL_IF -->
</div><!-- /div#tabrecord2 -->
</div> <!-- // #tabs -->
</div>
<div class="yui-u">
<div id="result">
<h2>Destination record</h2>
<div style="border:1px solid #E8E8E8;padding:1em;margin-top:2em;">
<ul id="resultul">
<!-- TMPL_LOOP NAME="record1" -->
<!-- TMPL_LOOP NAME="field" --><li id="k<!-- TMPL_VAR name="key" -->"><span class="field"><!-- TMPL_VAR NAME="tag" --></span>
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator1_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator1" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_indicator2_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="indicator2" -->" />
<!-- TMPL_IF NAME="value" --> /
<!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_00_<!-- TMPL_VAR NAME="key" -->" value="00" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_00_<!-- TMPL_VAR NAME="key" -->" value="<!-- TMPL_VAR NAME="value" -->" />
<!-- /TMPL_IF -->
<!-- TMPL_IF NAME="subfield" -->
<ul>
<!-- TMPL_LOOP NAME="subfield" -->
<li id="k<!-- TMPL_VAR name="subkey" -->">
<span class="subfield"><!-- TMPL_VAR NAME="subtag" --></span> / <!-- TMPL_VAR NAME="value" -->
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_code_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="subtag" -->" />
<input type="hidden" name="tag_<!-- TMPL_VAR name="tag" -->_subfield_<!-- TMPL_VAR NAME="subtag" -->_<!-- TMPL_VAR NAME="key" -->_<!-- TMPL_VAR NAME="subkey" -->" value="<!-- TMPL_VAR NAME="value" -->" />
</li>
<!-- /TMPL_LOOP -->
</ul>
<!-- /TMPL_IF -->
<!-- /TMPL_LOOP -->
</li>
<!-- /TMPL_LOOP -->
</ul>
<input type="hidden" name="biblio1" value="<!-- TMPL_VAR name="biblio1" -->" />
<input type="hidden" name="biblio2" value="<!-- TMPL_VAR name="biblio2" -->" />
<input type="hidden" name="mergereference" value="<!-- TMPL_VAR name="mergereference" -->" />
</div>
</div> <!-- // #result -->
</div> <!-- .yui-u -->
<fieldset class="action"><input type="submit" name="merge" value="Merge" /></fieldset>
</div>
</form>
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
<!-- /TMPL_IF -->
</div>
</div>
</div>
<!-- TMPL_INCLUDE NAME="intranet-bottom.inc" -->