From cf425f39c3591114f48ec12ca90504c0613d9a67 Mon Sep 17 00:00:00 2001 From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> 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. --- 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 @@ <div class="col-md-4"> <ul class="thumbnails"> [% FOREACH image IN images %] - <li id="imagenumber-[% image.imagenumber | html %]" class="thumbnail"> + <li id="imagenumber-[% image.imagenumber | html %]" data-itemnumber="[% image.itemnumber %]" data-biblionumber="[% image.biblionumber %]" class="thumbnail"> <a class="show_cover" data-coverimg="[% image.imagenumber | html %]" href="/cgi-bin/koha/catalogue/imageviewer.pl?biblionumber=[% biblionumber | html %]&imagenumber=[% image.imagenumber | html %]"> [% IF loop.first %] <img class="selected" id="thumbnail_[% image.imagenumber | html %]" src="/cgi-bin/koha/catalogue/image.pl?imagenumber=[% image.imagenumber | html %]&thumbnail=1" alt="Thumbnail" /> @@ -73,10 +73,21 @@ </div> <!-- /.col-md-4 --> </div> <!-- /.row --> [% ELSE %] - <div class="dialog message">There are no images for this record.</div> + [% IF itemnumber %] + <div class="dialog message">There are no images for this item.</div> + [% ELSE %] + <div class="dialog message">There are no images for this record.</div> + [% END %] [% IF ( CAN_user_tools_upload_local_cover_images ) %] <hr /> - <p>Upload an image file: <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber | uri %]&filetype=image"><i class="fa fa-upload" aria-hidden="true"></i> Upload</a> + <p> + Upload an image file: + [% IF itemnumber %] + <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/upload-cover-image.pl?itemnumber=[% itemnumber | uri %]&filetype=image"> + [% ELSE %] + <a class="btn btn-default btn-xs" href="/cgi-bin/koha/tools/upload-cover-image.pl?biblionumber=[% biblionumber | uri %]&filetype=image"> + [% END %] + <i class="fa fa-upload" aria-hidden="true"></i> Upload</a> </p> [% 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("<img style='display:inline-block' src='" + interface + "/" + theme + "/img/spinner-small.gif' alt='' />"); @@ -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.20.1