Bugzilla – Attachment 144142 Details for
Bug 32307
Chocolat image viewer broken in the staff interface when Coce is enabled
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 32307: Fix gallery when Coce is enabled
Bug-32307-Fix-gallery-when-Coce-is-enabled.patch (text/plain), 4.89 KB, created by
Jonathan Druart
on 2022-11-22 07:16:00 UTC
(
hide
)
Description:
Bug 32307: Fix gallery when Coce is enabled
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2022-11-22 07:16:00 UTC
Size:
4.89 KB
patch
obsolete
>From 1e41862c57c8a219912cc4a1969446bd9fea0d3b Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 22 Nov 2022 07:52:49 +0100 >Subject: [PATCH] Bug 32307: Fix gallery when Coce is enabled > >Bug 28179 added the gallery in the staff interface, and bug 28180 in the >OPAC. > >OPAC and staff have different code, because the cover image providers >are different. >On bug 28180 we noticed that the OPAC needed additional code to handle >OpenLibrary, Google Jacket and Coce, to differ the creation of the >gallery to prevent Chocolat to be instantiated before the links (img src) >are effectively in the DOM. > >To acchieve that we introduced a wait_for_images function, and added a >"done" flag to the 3 "JS modules". > >However we haven't ported this code for the staff interface, which is >also using Coce. > >Note that there was a bug at the OPAC as well for COCE, the ajax jQuery >function is async, and so 'done' was set even if the call was not >finished. > >Test plan: >0. Do not apply this patch >1. Enable LocalCoverImages and IntranetCoce >2. Pick a bibliographic record with an image returned from Coce >3. Add a local cover image >4. Go to the detail page >5. Open the gallery >=> Notice that you can notice a JS error and a loading icon on the >second image. This behaviour is not always broken, it depends on the >speed of the Coce server. If you don't see the problem reload the page. >6. Apply the patch and repeat >=> Notice that the cover slider block is longer to display the icon, but >that the error is gone. >7. Confirm that there is no regression at the OPAC > >We could improve the situation here, and we could display the images >in the slider, especially if the first image is a local image. But >that's for another bug... >--- > koha-tmpl/intranet-tmpl/js/coce.js | 6 ++-- > .../prog/en/modules/catalogue/detail.tt | 33 +++++++++++++++++-- > koha-tmpl/opac-tmpl/bootstrap/js/coce.js | 5 +-- > 3 files changed, 37 insertions(+), 7 deletions(-) > >diff --git a/koha-tmpl/intranet-tmpl/js/coce.js b/koha-tmpl/intranet-tmpl/js/coce.js >index a56ca61fefc..c8829aeb98d 100644 >--- a/koha-tmpl/intranet-tmpl/js/coce.js >+++ b/koha-tmpl/intranet-tmpl/js/coce.js >@@ -20,7 +20,7 @@ KOHA.coce = { > var id = $(this).attr("class"); // id=isbn > if (id !== '') { ids.push(id); } > }); >- if (ids.length == 0) return; >+ if (ids.length == 0) { this.done = 1; return; } > ids = ids.join(','); > var coceURL = host + '/cover?id=' + ids + '&provider=' + provider; > $.ajax({ >@@ -44,7 +44,9 @@ KOHA.coce = { > }); > } > }, >- >+ }).then(function(){ >+ // Cannot access 'this' from here >+ KOHA.coce.done = 1; > }); > } > >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 5db107ef270..c4176a7d85d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1600,9 +1600,36 @@ Note that permanent location is a code, and location may be an authval. > }); > }); > >- $(window).load(function() { >- verify_cover_images(); >- }); >+ >+ [% IF ( IntranetCoce && CoceProviders ) %] >+ let counter_wait = 0; >+ function wait_for_images(cb){ >+ >+ var loaded = 1; >+ counter_wait++; >+ >+ if ( loaded ) { >+ loaded = KOHA.coce.done; >+ } >+ >+ if (!loaded && counter_wait < 50) {// Do not wait more than 5 seconds >+ window.setTimeout(function(){wait_for_images(cb);}, 100); >+ } else { >+ if (counter_wait >= 50 ) { >+ console.log("Could not retrieve the images") >+ } >+ cb(); >+ } >+ } >+ >+ $(window).load(function() { >+ wait_for_images(verify_cover_images); >+ }); >+ [% ELSE %] >+ $(window).load(function() { >+ verify_cover_images; >+ }); >+ [% END %] > </script> > [% IF ( Koha.Preference('NovelistSelectStaffEnabled') && Koha.Preference('NovelistSelectStaffProfile') && ( normalized_isbn || normalized_upc ) ) %] > <script src="https://imageserver.ebscohost.com/novelistselect/ns2init.js"></script> >diff --git a/koha-tmpl/opac-tmpl/bootstrap/js/coce.js b/koha-tmpl/opac-tmpl/bootstrap/js/coce.js >index 090059ba92f..c8829aeb98d 100644 >--- a/koha-tmpl/opac-tmpl/bootstrap/js/coce.js >+++ b/koha-tmpl/opac-tmpl/bootstrap/js/coce.js >@@ -44,9 +44,10 @@ KOHA.coce = { > }); > } > }, >- >+ }).then(function(){ >+ // Cannot access 'this' from here >+ KOHA.coce.done = 1; > }); >- this.done = 1; > } > > }; >-- >2.25.1
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 32307
:
144142
|
144220
|
144222
|
144237
|
144238
|
146811
|
146812
|
147226