Bugzilla – Attachment 164333 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: Course reserves
Bug-33568-Course-reserves.patch (text/plain), 8.43 KB, created by
Jonathan Druart
on 2024-04-03 07:39:12 UTC
(
hide
)
Description:
Bug 33568: Course reserves
Filename:
MIME Type:
Creator:
Jonathan Druart
Created:
2024-04-03 07:39:12 UTC
Size:
8.43 KB
patch
obsolete
>From 884b024dbaeb6f7c5d96da3aa1c576556f918716 Mon Sep 17 00:00:00 2001 >From: Jonathan Druart <jonathan.druart@bugs.koha-community.org> >Date: Thu, 20 Apr 2023 08:35:48 +0200 >Subject: [PATCH] Bug 33568: Course reserves >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >FIXME We need tests here > >FIXME/TODO - Isn't it possible to replace all this mess with the >following Koha::Item method and a new DBIC rs? >sub courses { > my ($self) = @_; > return Koha::Courses->search( > { 'ci.itemnumber' => $self->itemnumber }, > { join => { course_reserves => 'ci' } } > ); >} > >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/Course/Reserve.pm | 19 +++++++- > Koha/Item.pm | 17 +++++++ > api/v1/swagger/definitions/item.yaml | 4 ++ > api/v1/swagger/paths/biblios.yaml | 1 + > .../prog/en/modules/catalogue/detail.tt | 45 +++++++++++-------- > 5 files changed, 67 insertions(+), 19 deletions(-) > >diff --git a/Koha/Course/Reserve.pm b/Koha/Course/Reserve.pm >index 963a2ee272d..6493ba90a39 100644 >--- a/Koha/Course/Reserve.pm >+++ b/Koha/Course/Reserve.pm >@@ -17,15 +17,32 @@ package Koha::Course::Reserve; > > use Modern::Perl; > >- > use base qw(Koha::Object); > >+use Koha::Courses; >+ > =head1 NAME > > Koha::Course::Reserve - Koha Course Reserve Object class > > =head1 API > >+=head2 Methods >+ >+=head3 course >+ >+ my $course = $course_reserve->course; >+ >+Return the course for this course reserve. >+ >+=cut >+ >+sub course { >+ my ($self) = @_; >+ my $rs = $self->_result->course; >+ return Koha::Course->_new_from_dbic($rs); >+} >+ > =head2 Internal methods > > =cut >diff --git a/Koha/Item.pm b/Koha/Item.pm >index b3fc8d56525..42897cfb1c0 100644 >--- a/Koha/Item.pm >+++ b/Koha/Item.pm >@@ -35,6 +35,8 @@ use Koha::BackgroundJob::BatchUpdateBiblioHoldsQueue; > use Koha::Biblio::ItemGroups; > use Koha::Checkouts; > use Koha::CirculationRules; >+use Koha::Courses; >+use Koha::Course::Items; > use Koha::CoverImages; > use Koha::Exceptions; > use Koha::Exceptions::Checkin; >@@ -1787,6 +1789,21 @@ sub tracked_links { > return Koha::TrackedLinks->_new_from_dbic($tracked_links); > } > >+=head3 course_item >+ >+ my $course_item = $item->course_item; >+ >+Returns a Koha::Course::Item object >+ >+=cut >+ >+sub course_item { >+ my ($self) = @_; >+ my $rs = $self->_result->course_item; >+ return unless $rs; >+ return Koha::Course::Item->_new_from_dbic($rs); >+} >+ > =head3 move_to_biblio > > $item->move_to_biblio($to_biblio[, $params]); >diff --git a/api/v1/swagger/definitions/item.yaml b/api/v1/swagger/definitions/item.yaml >index 1c816f21b27..d3a035b514e 100644 >--- a/api/v1/swagger/definitions/item.yaml >+++ b/api/v1/swagger/definitions/item.yaml >@@ -270,6 +270,10 @@ properties: > type: > - object > - "null" >+ course_item: >+ type: >+ - object >+ - "null" > _strings: > type: > - object >diff --git a/api/v1/swagger/paths/biblios.yaml b/api/v1/swagger/paths/biblios.yaml >index 101fa172ed0..3ba4be8d206 100644 >--- a/api/v1/swagger/paths/biblios.yaml >+++ b/api/v1/swagger/paths/biblios.yaml >@@ -433,6 +433,7 @@ > - item_type > - in_bundle > - bundle_host >+ - course_item.course_reserves.course > - 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 d9851e03c87..bff8e66ac2e 100644 >--- a/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >+++ b/koha-tmpl/intranet-tmpl/prog/en/modules/catalogue/detail.tt >@@ -19,19 +19,6 @@ > [% AmazonAssocTag = '' %] > [% END %] > >-[% ShowCourseReserves = 0 | html %] >-[% IF UseCourseReserves %] >- [% FOREACH item IN itemloop %] >- [% IF item.course_reserves %] >- [% FOREACH r IN item.course_reserves %] >- [% IF r.course.enabled == 'yes' %] >- [% ShowCourseReserves = 1 | html %] >- [% END %] >- [% END %] >- [% END %] >- [% END %] >-[% END %] >- > [% SET plugins_intranet_catalog_biblio_tabs = KohaPlugins.get_plugins_intranet_catalog_biblio_tab({ biblio => biblio, biblio_id => biblionumber }) %] > > [% SET footerjs = 1 %] >@@ -379,7 +366,7 @@ > <th id="[% tab | html %]_itemnotes_nonpublic" data-colname="[% tab | html %]_itemnotes_nonpublic">Non-public notes</th> > [% IF ( hostrecords ) %]<th id="[% tab | html %]_hostrecord" data-colname="[% tab | html %]_hostrecord">Host records</th>[% END %] > [% IF ( analyze ) %]<th id="[% tab | html %]_usedin" data-colname="[% tab | html %]_usedin">Used in</th><th></th>[% END %] >- [% IF ( ShowCourseReserves ) %]<th id="[% tab | html %]_course_reserves" data-colname="[% tab | html %]_course_reserves">Course reserves</th>[% END %] >+ [% IF Koha.Preference('UseCourseReserves') %]<th id="[% tab | html %]_course_reserves" data-colname="[% tab | html %]_course_reserves">Course reserves</th>[% END %] > [% IF ( SpineLabelShowPrintOnBibDetails ) %]<th id="[% tab | html %]_spinelabel" data-colname="[% tab | html %]_spinelabel" class="NoSort">Spine label</th>[% END %] > [% IF ( CAN_user_editcatalogue_edit_items ) %]<th id="[% tab | html %]_actions" data-colname="[% tab | html %]_actions"class="NoSort noExport"> </th>[% END %] > </tr> >@@ -2174,6 +2161,9 @@ > 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])); >+ [% IF Koha.Preference('UseCourseReserves') %] >+ const av_courses_term = new Map([% To.json(AuthorisedValues.Get('TERM')) | $raw %].map( av => [av.authorised_value, av.lib])); >+ [% END %] > [% IF Koha.Preference('URLLinkText') %] > const url_link_text = "[% Koha.Preference('URLLinkText') | html %]"; > [% ELSE %] >@@ -2197,6 +2187,9 @@ > embed.push('recall', 'recall.patron') > [% END %] > embed.push('in_bundle', 'bundle_host'); >+ [% IF Koha.Preference('UseCourseReserves') %] >+ embed.push('course_item.course_reserves.course'); >+ [% END %] > > function build_table (table_id, table_settings, filters) { > [% IF hidden_count %] >@@ -2586,13 +2579,29 @@ > } > }, > [% END %] >- [% IF ( ShowCourseReserves ) %] >+ [% IF Koha.Preference('UseCourseReserves') %] > { >- data: "", >- searchable: false, // FIXME >+ data: "course_item.course_reserves.course.course_name", >+ searchable: true, > orderable: true, > render: function (data, type, row, meta) { >- return ""; // FIXME Display course reserves >+ let nodes = ''; >+ if (!row.course_item) return nodes; >+ row.course_item.course_reserves.forEach((cr, i) => { >+ let c = cr.course; >+ if ( c.enabled != 'yes' ) return; >+ nodes += '<p>'; >+ nodes += '<a href="/cgi-bin/koha/course_reserves/course-details.pl?course_id=%s">'.format(c.course_id); >+ nodes += c.course_name; >+ if ( c.section ) { >+ nodes += ' ' + c.section; >+ } >+ if ( c.term ) { >+ nodes += ' ' + av_courses_term.get(c.term.toString()); >+ } >+ nodes += '</p>'; >+ }); >+ return nodes; > } > }, > [% 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