Bugzilla – Attachment 164314 Details for
Bug 33568
Use the REST API to display items on the staff biblio detail view
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33568: Cover images
Bug-33568-Cover-images.patch (text/plain), 4.79 KB, created by
Jonathan Druart
on 2024-04-03 07:37:48 UTC
(
hide
)
Description:
Bug 33568: Cover images
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-03 07:37:48 UTC
Size:
4.79 KB
patch
obsolete
>From e02f41bb3881763348a9dafc3e640bd4e4ffcb49 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 13 Apr 2023 15:26:00 +0200 >Subject: [PATCH] Bug 33568: Cover images >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >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> >--- > Koha/Item.pm | 16 +++++++++--- > api/v1/swagger/definitions/item.yaml | 4 +++ > api/v1/swagger/paths/biblios.yaml | 1 + > .../prog/en/modules/catalogue/detail.tt | 26 ++++++++++++++++--- > 4 files changed, 40 insertions(+), 7 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 59edeb752d8..ba261bfa006 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -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 >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index 1d0ed7ac95f..6f4a9d12e80 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -230,6 +230,10 @@ properties: > type: > - object > - "null" >+ cover_image_ids: >+ type: >+ - array >+ - "null" > _strings: > type: > - object >diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml >index 30702535577..1277166a8b8 100644 >--- a/api/v1/swagger/paths/biblios.yaml >+++ b/api/v1/swagger/paths/biblios.yaml >@@ -423,6 +423,7 @@ > type: string > enum: > - +strings >+ - cover_image_ids > collectionFormat: csv > - $ref: "../swagger.yaml#/parameters/match" > - $ref: "../swagger.yaml#/parameters/order_by" >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 4f60d86bbe8..e605c8e12b5 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -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&imagenumber=%s" title="Local cover image">'.format(id, id); >+ node += '<img src="/cgi-bin/koha/catalogue/image.pl?thumbnail=1&imagenumber=%s" alt="Local cover image" data-link="/cgi-bin/koha/catalogue/imageviewer.pl?itemnumber=[% item.itemnumber | uri %]&imagenumber=%s" />'.format(id, id); >+ node += '</a>'; >+ node += '</div>'; >+ }); >+ node += '</div>'; >+ node += '</div>'; >+ return node; > } > }, > [% END %] >-- >2.34.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 33568
:
151339
|
153791
|
164308
|
164309
|
164310
|
164311
|
164312
|
164313
|
164314
|
164315
|
164316
|
164317
|
164318
|
164319
|
164320
|
164321
|
164322
|
164323
|
164324
|
164325
|
164326
|
164327
|
164328
|
164329
|
164330
|
164331
|
164332
|
164333
|
164334
|
164335
|
164336
|
164337
|
164338
|
164339
|
164340
|
164341
|
164342
|
164343
|
164344
|
164345
|
164346
|
164347
|
164348
|
164349
|
164350
|
164351
|
164352
|
164353
|
164354
|
164355
|
164356
|
164358
|
164359
|
164360
|
164361
|
164362
|
164363
|
164364
|
164365
|
164366
|
164367
|
164368
|
164369
|
164370
|
164371
|
164372
|
164373
|
164374
|
164472
|
164480
|
164482
|
164483
|
164485
|
164528