Bugzilla – Attachment 164343 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: Restore bundle items
Bug-33568-Restore-bundle-items.patch (text/plain), 6.08 KB, created by
Jonathan Druart
on 2024-04-03 07:39:58 UTC
(
hide
)
Description:
Bug 33568: Restore bundle items
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-03 07:39:58 UTC
Size:
6.08 KB
patch
obsolete
>From 349d86a267b1626ae26bfc6d2f45403e5f481b15 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Wed, 24 May 2023 10:05:50 +0200 >Subject: [PATCH] Bug 33568: Restore bundle items >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 | 27 +++++++++++++++++++ > api/v1/swagger/definitions/item.yaml | 10 +++++++ > api/v1/swagger/paths/biblios.yaml | 2 ++ > .../prog/en/modules/catalogue/detail.tt | 23 +++++++++------- > 4 files changed, 53 insertions(+), 9 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index 42897cfb1c0..ea99889e696 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -1888,6 +1888,33 @@ sub bundle_items { > return Koha::Items->_new_from_dbic($rs); > } > >+ >+=head3 bundle_items_not_lost >+ >+ my $bundle_items = $item->bundle_items_not_lost; >+ >+Returns the items associated with this bundle that are not lost >+ >+=cut >+ >+sub bundle_items_not_lost { >+ my ($self) = @_; >+ return $self->bundle_items->search( { itemlost => { '!=' => 0 } } ); >+} >+ >+=head3 bundle_items_lost >+ >+ my $bundle_items = $item->bundle_items_lost; >+ >+Returns the items associated with this bundle that are lost >+ >+=cut >+ >+sub bundle_items_lost { >+ my ($self) = @_; >+ return $self->bundle_items->search( { itemlost => 0 } ); >+} >+ > =head3 is_bundle > > my $is_bundle = $item->is_bundle; >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index d3a035b514e..cb7894a899c 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -270,6 +270,16 @@ properties: > type: > - object > - "null" >+ bundle_items_lost_count: >+ type: >+ - integer >+ - "null" >+ description: Number of lost items in the bundle >+ bundle_items_not_lost_count: >+ type: >+ - integer >+ - "null" >+ description: Number of items not lost in the bundle > course_item: > type: > - object >diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml >index 8e666251237..a0f83fd9c23 100644 >--- a/api/v1/swagger/paths/biblios.yaml >+++ b/api/v1/swagger/paths/biblios.yaml >@@ -437,6 +437,8 @@ > - item_type > - in_bundle > - bundle_host >+ - bundle_items_lost+count >+ - bundle_items_not_lost+count > - course_item.course_reserves.course > - cover_image_ids > - item_group_item.item_group.description >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 b4632ecda80..287493fef8d 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -1857,14 +1857,15 @@ > > [% IF bundlesEnabled %] > // Add event listener for opening and closing bundle details >- $('#' + table_name + ' tbody').on('click', 'button.details-control', function () { >+ $('#' + tab_id + '_table tbody').on('click', 'button.details-control', function () { > var button = $(this); > var tr = button.closest('tr'); > var dTable = button.closest('table').DataTable({ 'retrieve': true }); > >- var itemnumber = tr.data('itemnumber'); >- var duedate = tr.data('duedate'); >- var row = dTable.row( tr ); >+ let row = dTable.row( tr ); >+ let data = row.data(); >+ let itemnumber = data.item_id; >+ let duedate = (data.checkout&&data.checkout.due_date) || null; > > if ( row.child.isShown() ) { > // This row is already open - close it >@@ -2186,7 +2187,9 @@ > [% IF Koha.Preference('UseRecalls') %] > embed.push('recall', 'recall+strings', 'recall.patron') > [% END %] >- embed.push('in_bundle', 'bundle_host'); >+ [% IF bundlesEnabled %] >+ embed.push('in_bundle', 'bundle_host', 'bundle_items_lost+count', 'bundle_items_not_lost+count'); >+ [% END %] > [% IF Koha.Preference('UseCourseReserves') %] > embed.push('course_item.course_reserves.course'); > [% END %] >@@ -2460,9 +2463,11 @@ > nodes += '<span class="restricted">(%s)</span>'.format(escape_str(av_restricted.get(row.restricted_status.toString()))); > } > >- if ( row.in_bundle ) { >- nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true }))); >- } >+ [% IF bundlesEnabled %] >+ if ( row.in_bundle ) { >+ nodes += '<span class="bundled">%s</span>'.format(_("In bundle: %s").format($biblio_to_html(row.bundle_host.biblio, { link: true }))); >+ } >+ [% END %] > return nodes; > } > }, >@@ -2659,7 +2664,7 @@ > } > [% IF bundlesEnabled %] > // FIXME How do we handle that correctly? >- //nodes += '<button class="btn btn-default btn-xs details-control"><i class="fa fa-folder"></i> Manage bundle (%s|%s)</button>'.format(escape_str(row.bundled), escape_str(row.bundled_lost)); >+ nodes += '<button class="btn btn-default btn-xs details-control"><i class="fa fa-folder"></i> Manage bundle (%s|%s)</button>'.format(escape_str(row.bundle_items_not_lost_count), escape_str(row.bundle_items_lost_count)); > [% END %] > > return nodes; >-- >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