Bugzilla – Attachment 95749 Details for
Bug 24084
PlainMARC view broken on OPAC if other $.ajax calls produce errors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors
Bug-24084-PlainMARC-view-broken-on-OPAC-if-other-a.patch (text/plain), 4.34 KB, created by
Katrin Fischer
on 2019-11-22 21:43:42 UTC
(
hide
)
Description:
Bug 24084: PlainMARC view broken on OPAC if other $.ajax calls produce errors
Filename:
MIME Type:
Creator:
Katrin Fischer
Created:
2019-11-22 21:43:42 UTC
Size:
4.34 KB
patch
obsolete
>From 46954587fda382ec3c156893b65d49f13d0aaf71 Mon Sep 17 00:00:00 2001 >From: Owen Leonard <oleonard@myacpl.org> >Date: Thu, 21 Nov 2019 18:08:48 +0000 >Subject: [PATCH] Bug 24084: PlainMARC view broken on OPAC if other $.ajax > calls produce errors > >This patch removes the use of jQuery's ajaxSetup() and load() to get the >"plain" MARC view and replaces it with $.get(). This allows for >error-handling on this specific AJAX request rather than all on the >page. > >To test, apply the patch and view a bibliographic record in the OPAC. > > - Click the "MARC view" tab. > - Click the "view plain" link. > - The plain-text MARC view should load. > - Clicking "view labeled" should return you to the original view. > >To test error handling, edit opac-MARCdetail.tt line 185 and add a typo >to the URL, e.g. "opac-showmark.pl." Repeat the above steps. Clicking >the "view plain" link should trigger an error message: "Sorry, plain >view is temporarily unavailable." > >Signed-off-by: Lucas Gass <lucas@bywatersolutions.com> > >Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de> >--- > .../bootstrap/en/modules/opac-MARCdetail.tt | 62 ++++++++++------------ > 1 file changed, 29 insertions(+), 33 deletions(-) > >diff --git a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt >index 319a5aceb6..5954259186 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt >+++ b/koha-tmpl/opac-tmpl/bootstrap/en/modules/opac-MARCdetail.tt >@@ -172,42 +172,38 @@ > [% BLOCK jsinclude %] > <script> > [% IF ( OPACXSLTDetailsDisplay ) %] >-$(document).ready(function(){ >- $.ajaxSetup({ >- error:function(x,e){ >- switch (x.status) { >- case 200: break; >- default: >- $('#switchview').parent().html("<div class=\"dialog alert\">"+_("Sorry, plain view is temporarily unavailable")+".</div>"); >- $("#plainmarc").hide(); >- $("#labeledmarc").show(); >- break; >- } >- } >- }); >- >- var loaded = 0; >- var toggle = 0; >- $("#switchview").on("click",function(e){ >- e.preventDefault(); >- if( toggle == 0){ >- $(this).text(_("view labeled")); >- $("#labeledmarc").hide(); >- if(!loaded){ >- $("#plainmarc").show().html("<div style=\"margin:1em;padding:1em;border:1px solid #EEE;font-size:150%;\"><img src=\"[% interface | html %]/[% theme | html %]/images/loading.gif\" /> "+_("Loading")+"...</div>").load("/cgi-bin/koha/opac-showmarc.pl","id=[% biblio.biblionumber | html %]&viewas=html"); >- loaded = 1; >+ $(document).ready(function(){ >+ var loaded = 0; >+ var toggle = 0; >+ $("#switchview").on("click",function(e){ >+ e.preventDefault(); >+ if( toggle == 0){ >+ $(this).text(_("view labeled")); >+ $("#labeledmarc").hide(); >+ if(!loaded){ >+ $("#plainmarc").show().html("<div style=\"margin:1em;padding:1em;border:1px solid #EEE;font-size:150%;\"><img src=\"[% interface | html %]/[% theme | html %]/images/loading.gif\" /> "+_("Loading")+"...</div>"); >+ var plain_marc = $.get( "/cgi-bin/koha/opac-showmarc.pl", { id: "[% biblio.biblionumber | html %]", viewas: "html" }) >+ .done(function( data ) { >+ $("#plainmarc").html( data ); >+ loaded = 1; >+ }) >+ .fail(function() { >+ $('#switchview').parent().html("<div class=\"dialog alert\">"+_("Sorry, plain view is temporarily unavailable")+".</div>"); >+ $("#plainmarc").hide(); >+ $("#labeledmarc").show(); >+ }); >+ } else { >+ $("#plainmarc").show(); >+ } >+ toggle = 1; > } else { >- $("#plainmarc").show(); >+ $(this).text(_("view plain")); >+ $("#labeledmarc").show(); >+ $("#plainmarc").hide(); >+ toggle = 0; > } >- toggle = 1; >- } else { >- $(this).text(_("view plain")); >- $("#labeledmarc").show(); >- $("#plainmarc").hide(); >- toggle = 0; >- } >+ }); > }); >-}); > [% END %] > </script> > [% END %] >-- >2.11.0
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 24084
:
95704
|
95705
| 95749