From 94fb475e28e0b3e20bd6ba3215bd6ea822f2f53e Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Thu, 13 Nov 2014 12:49:42 -0500 Subject: [PATCH] Bug 13151 - staff marc preview not wrapping The MARC preview available on the staff client detail page doesn't wrap long lines of text because it uses a huge block of whitespace-formatted text in a
 tag. The OPAC doesn't have this problem because the MARC
preview is formated in a table.

This patch copies the OPAC's "plainMARC.xsl" file for use in the staff
client. The preview modal has been converted to use Bootstrap following
the method used in Bug 12755

To test, apply the patch and clear your browser cache. View the
detail page for a bibliographic record in the staff client. Click the
link to show the MARC preview. Confirm that the modal looks correct,
works correctly, and adapts gracefully to different browser widths.

Confirm that the MARC preview and Card links still work from Z39.50
searches.

Note: This patch assumes that UNIMARC records display correctly using
xslt/plainMARC.xsl. Please let me know if that is wrong.

Signed-off-by: Frederic Demians 

I confirm it works: nice modal dialog box; display aligned on opac display;
works also with Unimarc biblios.
---
 catalogue/showmarc.pl                              | 10 +++-
 .../intranet-tmpl/prog/en/css/staff-global.css     |  7 +++
 .../prog/en/modules/catalogue/detail.tt            | 24 ++++++++-
 koha-tmpl/intranet-tmpl/prog/en/xslt/plainMARC.xsl | 59 ++++++++++++++++++++++
 4 files changed, 96 insertions(+), 4 deletions(-)
 create mode 100644 koha-tmpl/intranet-tmpl/prog/en/xslt/plainMARC.xsl

diff --git a/catalogue/showmarc.pl b/catalogue/showmarc.pl
index 97bc6fe..1954ce8 100755
--- a/catalogue/showmarc.pl
+++ b/catalogue/showmarc.pl
@@ -54,10 +54,16 @@ if(!ref $record) {
     exit;
 }
 
-if($view eq 'card') {
+if($view eq 'card' || $view eq 'html') {
     my $xml = $importid ? $record->as_xml(): GetXmlBiblio($biblionumber);
-    my $xsl = C4::Context->preference('marcflavour') eq 'UNIMARC'
+    my $xsl;
+    if ( $view eq 'card' ){
+        $xsl = C4::Context->preference('marcflavour') eq 'UNIMARC'
               ? 'UNIMARC_compact.xsl' : 'compact.xsl';
+    }
+    else {
+        $xsl = 'plainMARC.xsl';
+    }
     my $htdocs = C4::Context->config('intrahtdocs');
     my ($theme, $lang) = C4::Templates::themelanguage($htdocs, $xsl, 'intranet', $input);
     $xsl = "$htdocs/$theme/$lang/xslt/$xsl";
diff --git a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
index dc557c3..cc1fdfa 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
+++ b/koha-tmpl/intranet-tmpl/prog/en/css/staff-global.css
@@ -1721,6 +1721,13 @@ span.permissiondesc {
 	color: black;
 }
 
+#marcPreview table { border: 0; margin: .7em 0 0 0; font-family: monospace; font-size: 95%; }
+#marcPreview th { background-color : #FFF; border: 0; white-space: nowrap; text-align:left; vertical-align: top; padding: 2px; }
+#marcPreview td { border: 0; padding : 2px; vertical-align: top; }
+#marcPreview tbody tr:nth-child(2n+1) td { background-color: #FFF; }
+#marcPreview { width : 80%; margin-left : -40%; }
+@media (max-width: 767px) { #marcPreview { margin: 0; width : auto; } }
+
 #cartDetails {
 	background-color : #FFF;
 	border: 1px solid #739acf;
diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
index efd1dc4..89ddb87 100644
--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt
@@ -175,6 +175,15 @@ function verify_images() {
     [% IF ( LocalCoverImages && ! localimages.0 ) %]
         showNoImageMessage();
     [% END %]
+        $("body").on("click",".previewMARC", function(e){
+            e.preventDefault();
+            var page = $(this).attr("href");
+            $("#marcPreview .modal-body").load(page + " table");
+            $('#marcPreview').modal({show:true});
+        });
+        $("#marcPreview").on("hidden", function(){
+            $("#marcPreview .modal-body").html("
\"\" "+_("Loading")+"
"); + }); }); [% IF ( AmazonCoverImages ) %]$(window).load(function() { @@ -363,7 +372,7 @@ function verify_images() { [% END %] [% END %] - MARC Preview: Show + MARC Preview: Show [% IF ( holdcount ) %]Holds: [% holdcount %][% ELSE %][% END %] [% IF ( AmazonCoverImages ) %]
@@ -1009,7 +1018,18 @@ function verify_images() {
- + diff --git a/koha-tmpl/intranet-tmpl/prog/en/xslt/plainMARC.xsl b/koha-tmpl/intranet-tmpl/prog/en/xslt/plainMARC.xsl new file mode 100644 index 0000000..84c2753 --- /dev/null +++ b/koha-tmpl/intranet-tmpl/prog/en/xslt/plainMARC.xsl @@ -0,0 +1,59 @@ + +]> + + + + + + MARC View + + + + + + + + + + + + + + +
+ 000 + + +
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + _ + +
+
+ +
-- 2.1.2