From c05fb34e91833caedce447377c886be951a872c6 Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Fri, 21 Aug 2020 18:14:50 +0200 Subject: [PATCH] Bug 26145: Correctly preserve itemnumber value In order to know we are dealing with the cover images of a specific item we need to pass it though the different forms. Signed-off-by: Heather Hernandez --- catalogue/imageviewer.pl | 6 +++++- .../prog/en/modules/catalogue/imageviewer.tt | 25 ++++++++++++++++++---- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/catalogue/imageviewer.pl b/catalogue/imageviewer.pl index b71a3c2e75..df76644392 100755 --- a/catalogue/imageviewer.pl +++ b/catalogue/imageviewer.pl @@ -81,10 +81,14 @@ if ( C4::Context->preference("LocalCoverImages") ) { ); } $template->{VARS}->{'count'} = $itemcount; -$template->{VARS}->{'biblionumber'} = $biblionumber; $template->param(C4::Search::enabled_staff_search_views); $template->{VARS}->{'biblio'} = $biblio; +$template->param( + biblionumber => $biblionumber, + itemnumber => $itemnumber, +); + my $hold_count = $biblio ? $biblio->holds->count : 0; $template->param( holdcount => $hold_count ); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt index 5477ec6544..1e887ff9ad 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/imageviewer.tt @@ -56,7 +56,7 @@
[% ELSE %] -
There are no images for this record.
+ [% IF itemnumber %] +
There are no images for this item.
+ [% ELSE %] +
There are no images for this record.
+ [% END %] [% IF ( CAN_user_tools_upload_local_cover_images ) %]
-

Upload an image file: Upload +

+ Upload an image file: + [% IF itemnumber %] + + [% ELSE %] + + [% END %] + Upload

[% END %] [% END %] @@ -126,6 +137,8 @@ function removeLocalImage(imagenumber) { var thumbnail = $("#imagenumber-" + imagenumber ); + var itemnumber = $(thumbnail).data("itemnumber"); + var biblionumber = $(thumbnail).data("biblionumber"); var copy = thumbnail.html(); thumbnail.find("img").css("opacity", ".2"); thumbnail.find("a.remove").html(""); @@ -135,7 +148,11 @@ success: function(data) { $(data).each( function() { if ( this.deleted == 1 ) { - location.href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=" + biblionumber; + if( itemnumber ) { + location.href="/cgi-bin/koha/catalogue/imageviewer.pl?itemnumber=" + itemnumber; + } else { + location.href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=" + biblionumber; + } } else { thumbnail.html( copy ); alert(_("An error occurred on deleting this image")); -- 2.11.0