Bug 33568: Cover images

Signed-off-by: Owen Leonard <oleonard@myacpl.org>

Signed-off-by: Laurence Rault <laurence.rault@biblibre.com>
Signed-off-by: Emily Lamancusa <emily.lamancusa@montgomerycountymd.gov>
Signed-off-by: Tomás Cohen Arazi <tomascohen@theke.io>
Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
Jonathan Druart 2023-04-13 15:26:00 +02:00 committed by Katrin Fischer
parent 1c181f9844
commit b1973b3abd
No known key found for this signature in database
GPG Key ID: 0EF6E2C03357A834
4 changed files with 40 additions and 7 deletions

View File

@ -1214,9 +1214,19 @@ Return the cover images associated with this item.
sub cover_images {
my ( $self ) = @_;
my $cover_image_rs = $self->_result->cover_images;
return unless $cover_image_rs;
return Koha::CoverImages->_new_from_dbic($cover_image_rs);
my $cover_images_rs = $self->_result->cover_images;
return Koha::CoverImages->_new_from_dbic($cover_images_rs);
}
=head3 cover_image_ids
Return the cover image ids associated with this item.
=cut
sub cover_image_ids {
my ($self) = @_;
return [ $self->cover_images->get_column('imagenumber') ];
}
=head3 columns_to_str

View File

@ -230,6 +230,10 @@ properties:
type:
- object
- "null"
cover_image_ids:
type:
- array
- "null"
_strings:
type:
- object

View File

@ -423,6 +423,7 @@
type: string
enum:
- +strings
- cover_image_ids
collectionFormat: csv
- $ref: "../swagger.yaml#/parameters/match"
- $ref: "../swagger.yaml#/parameters/order_by"

View File

@ -2495,10 +2495,14 @@
const can_edit_items_from = [% To.json(can_edit_items_from) | $raw %];
const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %];
let table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?";
let embed = ["+strings"];
[% IF Koha.Preference('LocalCoverImages') %]
embed.push('cover_image_ids');
[% END %]
var items_table = $("#table_items").kohaTable({
ajax: { url: table_url },
order: [[ 0, "asc" ]],
embed: ["+strings"],
embed,
bAutoWidth: false,
columns: [
[% IF (StaffDetailItemSelection) %]
@ -2519,10 +2523,24 @@
{
data: "",
className: "cover",
searchable: true,
orderable: true,
searchable: false,
orderable: false,
render: function (data, type, row, meta) {
return ""; // FIXME Build cover images
if ( !row.cover_image_ids.length > 0 ) {
return '';
}
let node = '<div class="bookcoverimg">';
node += '<div class="cover-slider">';
row.cover_image_ids.forEach(id => {
node += '<div class="cover-image local-coverimg">';
node += '<a href="/cgi-bin/koha/catalogue/image.pl?itemnumber=%s&amp;imagenumber=%s" title="Local cover image">'.format(id, id);
node += '<img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&amp;imagenumber=%s" alt="Local cover image" data-link="/cgi-bin/koha/catalogue/imageviewer.pl?itemnumber=[% item.itemnumber | uri %]&amp;imagenumber=%s" />'.format(id, id);
node += '</a>';
node += '</div>';
});
node += '</div>';
node += '</div>';
return node;
}
},
[% END %]