Bugzilla – Attachment 164324 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: Status
Bug-33568-Status.patch (text/plain), 12.88 KB, created by
Jonathan Druart
on 2024-04-03 07:38:32 UTC
(
hide
)
Description:
Bug 33568: Status
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-03 07:38:32 UTC
Size:
12.88 KB
patch
obsolete
>From 1c4ea60e0e446dcdc5a6524a8c1cb1c0c9bf9537 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Tue, 18 Apr 2023 14:09:47 +0200 >Subject: [PATCH] Bug 33568: Status >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >FIXME We need tests here! > >See the FIXME in the code, we are losing the ability to search on the status, >but this is really impossible to implement if we are not storing the >status (DB or search engine). > >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 | 12 ++ > Koha/Template/Plugin/AuthorisedValues.pm | 4 +- > api/v1/swagger/definitions/item.yaml | 28 +++++ > api/v1/swagger/paths/biblios.yaml | 10 ++ > .../prog/en/modules/catalogue/detail.tt | 109 +++++++++++++++++- > 5 files changed, 155 insertions(+), 8 deletions(-) > >diff --git a/Koha/Item.pm b/Koha/Item.pm >index f677abac769..b3fc8d56525 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -767,6 +767,10 @@ sub get_transfer { > return Koha::Item::Transfer->_new_from_dbic($transfer) if $transfer; > } > >+sub transfer { >+ return shift->get_transfer(@_); >+} >+ > =head3 get_transfers > > my $transfer = $item->get_transfers; >@@ -1049,6 +1053,11 @@ sub current_holds { > return Koha::Holds->_new_from_dbic($hold_rs); > } > >+sub first_hold { >+ my ( $self ) = @_; >+ return $self->current_holds->next; >+} >+ > =head3 stockrotationitem > > my $sritem = Koha::Item->stockrotationitem; >@@ -1744,6 +1753,9 @@ sub itemtype { > > return Koha::ItemTypes->find( $self->effective_itemtype ); > } >+sub item_type { >+ return shift->itemtype; >+} > > =head3 orders > >diff --git a/Koha/Template/Plugin/AuthorisedValues.pm b/Koha/Template/Plugin/AuthorisedValues.pm >index 5cb91b83a3c..4e74c1bbad5 100644 >--- a/Koha/Template/Plugin/AuthorisedValues.pm >+++ b/Koha/Template/Plugin/AuthorisedValues.pm >@@ -69,8 +69,8 @@ sub GetCategories { > > sub GetDescriptionsByKohaField { > my ( $self, $params ) = @_; >- return Koha::AuthorisedValues->get_descriptions_by_koha_field( >- { kohafield => $params->{kohafield} } ); >+ return [ Koha::AuthorisedValues->get_descriptions_by_koha_field( >+ { kohafield => $params->{kohafield} } ) ]; > } > > sub GetDescriptionByKohaField { >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index bb5a96ffb5e..1c816f21b27 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -242,6 +242,34 @@ properties: > type: > - object > - "null" >+ checkout: >+ type: >+ - object >+ - "null" >+ transfer: >+ type: >+ - object >+ - "null" >+ first_hold: >+ type: >+ - object >+ - "null" >+ recall: >+ type: >+ - object >+ - "null" >+ item_type: >+ type: >+ - object >+ - "null" >+ in_bundle: >+ type: >+ - boolean >+ - "null" >+ bundle_host: >+ type: >+ - object >+ - "null" > _strings: > type: > - object >diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml >index a15997e3ba7..101fa172ed0 100644 >--- a/api/v1/swagger/paths/biblios.yaml >+++ b/api/v1/swagger/paths/biblios.yaml >@@ -423,6 +423,16 @@ > type: string > enum: > - +strings >+ - checkout >+ - checkout.patron >+ - transfer >+ - first_hold >+ - first_hold.patron >+ - recall >+ - recall.patron >+ - item_type >+ - in_bundle >+ - bundle_host > - cover_image_ids > - item_group_item.item_group.description > - serialitem.serial >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 73499267cee..d05b58c37be 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -2485,11 +2485,16 @@ > > }); > [% END %] >- const can_edit_items_from = [% To.json(can_edit_items_from) | $raw %]; >+ const can_edit_items_from = [% To.json(can_edit_items_from || {}) | $raw %]; > const item_type_image_locations = [% To.json(item_type_image_locations) | $raw %]; > const av_loc = new Map([% To.json(AuthorisedValues.Get('LOC')) | $raw %].map( av => [av.authorised_value, av.lib])); >+ const av_lost = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.itemlost' })) | $raw %].map( av => [av.authorised_value, av.lib])); >+ const av_withdrawn = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.withdrawn' })) | $raw %].map( av => [av.authorised_value, av.lib])); >+ const av_damaged = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.damaged' })) | $raw %].map( av => [av.authorised_value, av.lib])); >+ const av_not_for_loan= new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.notforloan' })) | $raw %].map( av => [av.authorised_value, av.lib])); >+ const av_restricted = new Map([% To.json(AuthorisedValues.GetDescriptionsByKohaField({ kohafield => 'items.restricted' })) | $raw %].map( av => [av.authorised_value, av.lib])); > let table_url = "/api/v1/biblios/[% biblio.biblionumber | uri %]/items?"; >- let embed = ["+strings"]; >+ let embed = ["+strings,checkout,checkout.patron,transfer,first_hold,first_hold.patron,item_type"]; > [% IF Koha.Preference('LocalCoverImages') %] > embed.push('cover_image_ids'); > [% END %] >@@ -2499,6 +2504,10 @@ > [% IF biblio.serial %] > embed.push('serialitem.serial'); > [% END %] >+ [% IF Koha.Preference('UseRecalls') %] >+ embed.push('recall', 'recall.patron') >+ [% END %] >+ embed.push('in_bundle', 'bundle_host'); > let table_settings = [% TablesSettings.GetTableSettings('catalogue', 'detail','holdings_table','json') | $raw %]; > var items_table = $("#table_items").kohaTable({ > ajax: { url: table_url }, >@@ -2659,12 +2668,100 @@ > } > }, > { >- data: "", >+ data: "me.lost_status", > className: "status", >- searchable: false, // FIXME >- orderable: true, >+ searchable: false, // FIXME We are losing the ability to search on the status >+ orderable: false, > render: function (data, type, row, meta) { >- return "status"; // FIXME Display status >+ let nodes = ""; >+ if ( row.checkout ) { >+ nodes += '<span>'; >+ if ( row.checkout.onsite_checkout ) { >+ if ( can_edit_items_from[row.holding_library_id] ){ >+ let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] >+ nodes += _("Currently in local use by %s").format(patron_to_html); >+ } else { >+ nodes += _("Currently in local use"); >+ } >+ } else { >+ nodes += '<span class="datedue">'; >+ if ( can_edit_items_from[row.holding_library_id] ){ >+ let patron_to_html = $patron_to_html(row.checkout.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] >+ nodes += _("Checked out to %s").format(patron_to_html); >+ } else { >+ nodes += _("Checked out"); >+ } >+ } >+ nodes += ': '; >+ nodes += _("due %s").format($date(row.checkout.due_date)); [%# FIXME Missing due date formatting here, $date do not have as_due_date option %] >+ nodes += "</span>" >+ } else if ( row.transfer ) { >+ if ( row.transfer.datesent ) { >+ nodes += '<span class="intransit">%s</span>'.format(_("In transit from %s to %s since %s").format(row.transfer.frombranch, row.transfer.tobranch, $date(row.transfer.datesent))); [%# FIXME display library names, not codes, do we use _strings here? %] >+ } else { >+ nodes += '<span class="transitrequested">%s</span>'.format(_("Transit pending from %s to %s since %s").format(row.transfer.frombranch, row.transfer.tobranch, $date(row.transfer.daterequested))); [%# FIXME See above %] >+ } >+ } >+ >+ if ( row.lost_status ) { >+ let lost_lib = av_lost.get(row.lost_status.toString()) || _("Unavailable (lost or missing"); >+ nodes += '<span class="lost">%s</span>'.format(lost_lib); >+ } >+ >+ if ( row.withdrawn ) { >+ let withdrawn_lib = av_withdrawn.get(row.withdrawn.toString()) || _("Withdrawn"); >+ nodes += '<span class="wdn">%s</span>'.format(withdrawn_lib); >+ } >+ >+ if ( row.damaged ) { >+ let damaged_lib = av_damaged.get(row.damaged.toString()) || _("Damaged"); >+ nodes += '<span class="dmg">%s</span>'.format(damaged_lib); >+ } >+ >+ if ( row.not_for_loan_status || row.item_type.notforloan ) { >+ let not_for_loan_lib = av_not_for_loan.get(row.not_for_loan_status.toString()); >+ nodes += '<span class="notforloan">%s'.format(_("Not for loan")) + ( not_for_loan_lib ? '<span class="reason"> (%s)</span>'.format(not_for_loan_lib) : '' ) + '</span>'; >+ } >+ >+ if ( row.first_hold ) { >+ if ( row.first_hold.waiting_date ) { >+ [%# FIXME Display library names instead of codes %] >+ [%# FIXME We lost the desk name, we need an additional embed %] >+ nodes += '<span class="waitingat">%s</span>'.format(_("Waiting at %s since %s.".format(row.first_hold.pickup_library_id, $date(row.first_hold.waiting_date)))); >+ [% IF Koha.Preference('canreservefromotherbranches') %] >+ if ( row.first_hold.waiting_date || row.first_hold.priority == 1 ) { >+ let patron_to_html = $patron_to_html(row.first_hold.patron); [%# FIXME What about hide_patron_infos_if_needed?? %] >+ nodes += ' <span class="heldfor">%s</span>'.format(_("Hold for: %s").format(patron_to_html)); >+ } >+ [% END %] >+ } else { >+ nodes += '<span class="holdonitem">%s</span>'.format(_("There is an item level hold on this item (priority = %s).").format(row.first_hold.priority)); >+ } >+ } >+ >+ [% IF Koha.Preference('UseRecalls') %] >+ if ( row.recall ) { >+ if ( row.recall.waiting_date ) { >+ nodes += '<span>%s</span>'.format(_("Waiting at %s since %s").format(row.recall.pickup_library_id, $date(row.recall.waiting_date))); # FIXME Display library names instead of codes >+ } else { >+ let patron_to_html = $patron_to_html(row.recall.patron); >+ nodes += '<span>%s</span>'.format(_("recalled by %s on %s").format(patron_to_html, row.recall.created_date)); >+ } >+ } >+ [% END %] >+ >+ if ( ! ( row.not_for_loan_status || row.item_type.notforloan || row.checked_out_date || row.lost_status || row.withdrawn || row.damaged || row.transfer || row.first_hold || row.recall ) ) { >+ nodes += ' <span>%s</span>'.format(_("Available")) >+ } >+ >+ if ( row.restricted_status ) { >+ nodes += '<span class="restricted">(%s)</span>'.format(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 }))); >+ } >+ 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