Koha/koha-tmpl/intranet-tmpl/prog/en/modules/cataloguing/merge.tt
Owen Leonard 83b7d6e0d3 Bug 15314: Use Bootstrap modal for cataloging merge MARC preview
In order to reduce the number of dependencies for common interactions we
should attempt to use Bootstrap modals in place of Greybox ones.

This patch modifies the cataloging merge selection page so that the
MARC preview is shown in a Boostrap modal. This patch also changes the
preview link to be the text "View MARC" so that it is clear what it
does.

To test:

1. Apply the patch and navigate to Cataloging.
2. Perform a search which will return results from the catalog.
3. Select two records and click the "Merge selected" button to begin the
   merge process.
4. Test the "View MARC" link for both merge choices and confirm that the
   correct data is shown each time.

Signed-off-by: Hector Castro <hector.hecaxmmx@gmail.com>
Works as advertised

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>

Signed-off-by: Brendan A Gallagher <brendan@bywatersolutions.com>
2015-12-30 03:38:15 +00:00

303 lines
11 KiB
Text
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

[% PROCESS 'merge-record.inc' %]
[% INCLUDE 'doc-head-open.inc' %]
<title>Koha &rsaquo; Cataloging &rsaquo; Merging records</title>
[% INCLUDE 'doc-head-close.inc' %]
<script type="text/javascript" src="[% themelang %]/js/merge-record.js"></script>
[% INCLUDE 'merge-record-strings.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 */
#dataPreview { width : 80%; margin-left : -40%; } @media (max-width: 767px) { #dataPreview { margin: 0; width : auto; } }
</style>
<script type="text/javascript">
//<![CDATA[
[% UNLESS (result) %]
[% IF (choosereference) %]
function changeFramework(fw) {
$("#frameworkcode").val(fw);
}
$(document).ready(function(){
$(".previewData").on("click", function(e){
e.preventDefault();
var ltitle = $(this).text();
var page = $(this).attr("href");
$("#dataPreviewLabel").text(ltitle);
$("#dataPreview .modal-body").load(page + " div");
$('#dataPreview').modal({show:true});
});
$("#dataPreview").on("hidden", function(){
$("#dataPreviewLabel").html("");
$("#dataPreview .modal-body").html("<div id=\"loading\"><img src=\"[% interface %]/[% theme %]/img/loading-small.gif\" alt=\"\" /> "+_("Loading")+"</div>");
});
});
[% ELSE %]
function check_mandatory () {
var missing = {
'fields': [],
'subfields': []
};
for (tag in tagslib) {
if (tag == '000' || tag == '001')
continue;
if (tagslib[tag].mandatory == 1) {
if ($("#resultul span.field:contains("+ tag +")").length == 0) {
missing.fields.push(tag);
}
}
for (subfieldcode in tagslib[tag]) {
if (subfieldcode == 'lib' || subfieldcode == 'mandatory'
|| subfieldcode == 'repeatable' || subfieldcode == 'tab'
|| subfieldcode == '@') {
continue;
}
if (tagslib[tag][subfieldcode].mandatory == 1 && tagslib[tag][subfieldcode].tab >= 0) {
var fields = $("#resultul span.field:contains("+ tag +")");
$(fields).each(function() {
var subfields = $(this).parents('li').find("span.subfield:contains("+ subfieldcode +")");
if (subfields.length == 0) {
missing.subfields.push( {
'tag': tag,
'subfieldcode': subfieldcode
} );
}
});
}
}
}
return missing;
}
// When submiting the form
function mergeformsubmit() {
var missing = check_mandatory();
var alert_msg = '';
var error = 0;
if (missing.fields.length > 0) {
alert_msg += _("Following required fields are missing:") + "\n";
for (var i in missing.fields) {
alert_msg += "\t- " + missing.fields[i] + "\n";
error ++;
}
alert_msg += "\n";
}
if (missing.subfields.length > 0) {
alert_msg += _("Following required subfields are missing:") + "\n";
for (var i in missing.subfields) {
var subfield = missing.subfields[i];
alert_msg += "\t- " + subfield.tag + "$" + subfield.subfieldcode + "\n";
error ++;
}
}
if (error != 0) {
alert(alert_msg);
return false;
} else {
$("#tabs").remove();
}
}
$(document).ready(function(){
tagslib = [];
$.getJSON("/cgi-bin/koha/cataloguing/merge_ajax.pl", {frameworkcode : "[% framework %]" }, function(json) {
tagslib = json;
rebuild_target($("#tabs"), $("#resultul"));
});
// Creating tabs
$("#tabs").tabs();
// Check all checkboxes in first tab, and uncheck all others to avoid
// inconsistencies from a page refresh.
$('#tabs div#tabrecord[% ref_biblionumber %]').find('input[type="checkbox"]').attr('checked', true);
$('#tabs > div:not("#tabrecord[% ref_biblionumber %]")').find('input[type="checkbox"]').removeAttr('checked');
//Set focus to cataloging search
$("input[name=q]:eq(0)").focus();
});
[% END %]
[% END %]
//]]>
</script>
</head>
<body id="cat_merge" class="cat">
[% INCLUDE 'header.inc' %]
[% INCLUDE '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; Merging records</div>
<div id="doc" class="yui-t7">
<div id="bd">
<div id="yui-main">
<h1>Merging records</h1>
[% IF ( result ) %]
[% IF ( errors.size ) %]
[% FOREACH error IN errors %]
<div class="dialog alert">
[% IF error.code == 'CANNOT_MOVE' %]
The following items could not be moved from the old record to the new one: [% error.value %]
[% ELSE %]
[% error %]
[% END %]
<br />
Therefore, the record to be merged has not been deleted.
</div>
[% END %]
[% ELSE %]
<p>The merge was successful. <a href="/cgi-bin/koha/catalogue/MARCdetail.pl?biblionumber=[% ref_biblionumber %]">Click here to see the merged record.</a></p>
<h3>Report</h3>
<table>
<thead>
<tr>
<th>Biblionumber</th>
[% FOREACH key IN report_header.keys.sort %]
[% tag = key.substr(0, 3) %]
[% code = key.substr(3, 1) %]
[% IF code == '@' %]
[% header = tag %]
[% ELSE %]
[% header = tag _ '$' _ code %]
[% END %]
<th>[% header %]</th>
[% END %]
</tr>
</thead>
<tbody>
[% FOREACH record IN report_records %]
<tr>
<td>
[% record.biblionumber %]
[% IF loop.first %]
(record kept)
[% END %]
</td>
[% FOREACH key IN report_header.keys.sort %]
<td>
[% values = record.fields.$key %]
[% IF values %]
[% FOREACH value IN record.fields.$key %]
[% value %]
[% UNLESS loop.last %]<br />[% END %]
[% END %]
[% END %]
</td>
[% END %]
</tr>
[% END %]
</tbody>
</table>
[% END %]
[% ELSE %]
[% IF ( 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>
[% FOREACH record IN records %]
<li class="radio">
[% IF loop.first %]
<input type="radio" value="[% record.biblionumber %]" checked="checked" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
[% ELSE %]
<input type="radio" value="[% record.biblionumber %]" id="ref_biblionumber[% record.biblionumber %]" name="ref_biblionumber" onclick="changeFramework('[% record.frameworkcode %]')" />
[% END %]
<label for="ref_biblionumber[% record.biblionumber %]">
[% record.data.title %]
[% FOREACH subtitle IN record.subtitles %]
[% subtitle.subfield %]
[% END %]
([% record.biblionumber %]) <a href="/cgi-bin/koha/catalogue/showmarc.pl?id=[% record.biblionumber %]" class="previewData">View MARC</a>
</label>
</li>
[% END %]
[% IF frameworkselect.size %]
<li>
<label for="frameworkcode">Using framework:</label>
<select name="frameworkcode" id="frameworkcode">
<option value="">Default</option>
[% FOREACH frameworkcode IN frameworkselect %]
[% IF ( frameworkcode.selected ) %]
<option value="[% frameworkcode.value %]" selected="selected">
[% ELSE %]
<option value="[% frameworkcode.value %]">
[% END %]
[% frameworkcode.frameworktext %]
</option>
[% END %]
</select>
</li>
[% END %]
</ol>
[% FOREACH record IN records %]
<input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
[% END %]
<fieldset class="action">
<input type="submit" value="Next" />
</fieldset>
</fieldset>
</form>
<div id="dataPreview" class="modal hide" tabindex="-1" role="dialog" aria-labelledby="dataPreviewLabel" aria-hidden="true">
<div class="modal-header">
<button type="button" class="closebtn" data-dismiss="modal" aria-hidden="true">×</button>
<h3 id="dataPreviewLabel">Preview</h3>
</div>
<div class="modal-body">
<div id="loading"> <img src="[% interface %]/[% theme %]/img/loading-small.gif" alt="" /> Loading </div>
</div>
<div class="modal-footer">
<button class="btn" data-dismiss="modal" aria-hidden="true">Close</button>
</div>
</div>
[% ELSE %]
[% IF ( errors.size ) %]
<div class="dialog alert">
[% FOREACH error IN errors %]
<p>[% error %]</p>
[% END %]
</div>
[% 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">
[% PROCESS mergesource sourcerecords=records %]
</div>
<div class="yui-u">
[% PROCESS mergetarget %]
</div> <!-- .yui-u -->
<input type="hidden" name="ref_biblionumber" value="[% ref_biblionumber %]" />
[% FOREACH record IN records %]
<input type="hidden" name="biblionumber" value="[% record.biblionumber %]" />
[% END %]
<input type="hidden" name="frameworkcode" value="[% framework %]" />
<fieldset class="action">
<input type="submit" name="merge" value="Merge" />
<label for="report_fields">Fields to display in report:</label>
<input type="text" name="report_fields" id="report_fields" value="[% MergeReportFields %]" />
<span class="hint">(Example: "001,245ab,600")
</fieldset>
</div>
</form>
[% END %]
[% END %]
[% END %]
</div>
</div>
</div>
[% INCLUDE 'intranet-bottom.inc' %]