From b5d7ccd8b30e9a2b9adbf653777fc059e69809be Mon Sep 17 00:00:00 2001 From: Jeff Davis Date: Fri, 5 Nov 2021 16:41:55 -0700 Subject: [PATCH] LP#1951318: API call to retrieve (publicly-visible) carousel contents Signed-off-by: Jeff Davis Signed-off-by: Mike Rylander --- .../lib/OpenILS/Application/Actor/Carousel.pm | 44 +++++++++++++++++++ .../perlmods/lib/OpenILS/WWW/EGCatLoader.pm | 36 +++------------ 2 files changed, 49 insertions(+), 31 deletions(-) diff --git a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm index 9e9fa616fc..cc5d0ec13b 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/Application/Actor/Carousel.pm @@ -18,6 +18,50 @@ my $logger = "OpenSRF::Utils::Logger"; sub initialize { return 1; } +__PACKAGE__->register_method( + method => "get_carousel_contents", + api_name => "open-ils.actor.carousel.get_contents", + authoritative => 1, + notes => <<" NOTES"); + Given a carousel ID, returns the carousel name and any publicly-visible + bibs from the associated bucket + PARAMS(carousel_id) + NOTES + +sub get_carousel_contents { + my($self, $client, $id) = @_; + my $e = new_editor(); + my $carousel = $e->retrieve_container_carousel($id); + my $ret = { + id => $id, + name => $carousel->name + }; + my $q = { + select => { bre => ['id'], mfde => [{ column => 'value', alias => 'title' }] }, + from => { + bre => { + cbrebi => { + join => { + cbreb => { + join => { cc => {} } + } + } + }, + mfde => {} + } + }, + where => { + '+cc' => { id => $id }, + '+bre' => { deleted => 'f' }, + '+mfde' => { name => 'title' } + }, + order_by => {cbrebi => ['pos','create_time']} + }; + my $r = $e->json_query($q); + $ret->{bibs} = $r; + return $ret; +} + __PACKAGE__->register_method( method => "retrieve_carousels_at_org", api_name => "open-ils.actor.carousel.retrieve_by_org", diff --git a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm index 9b0279d687..6d5432eced 100644 --- a/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm +++ b/Open-ILS/src/perlmods/lib/OpenILS/WWW/EGCatLoader.pm @@ -430,7 +430,6 @@ sub load_common { $self->load_org_util_funcs; $self->load_perm_funcs; - # FIXME - move carousel helpers to a separate file $ctx->{get_visible_carousels} = sub { my $org_unit = $self->ctx->{carousel_loc} || $self->ctx->{physical_loc} || $self->cgi->param('loc') || $self->ctx->{aou_tree}->()->id; return $U->simplereq( @@ -441,36 +440,11 @@ sub load_common { }; $ctx->{get_carousel} = sub { my $id = shift; - - my $carousel = $e->retrieve_container_carousel($id); - my $ret = { - id => $id, - name => $carousel->name - }; - my $q = { - select => { bre => ['id'], mfde => [{ column => 'value', alias => 'title' }] }, - from => { - bre => { - cbrebi => { - join => { - cbreb => { - join => { cc => {} } - } - } - }, - mfde => {} - } - }, - where => { - '+cc' => { id => $id }, - '+bre' => { deleted => 'f' }, - '+mfde' => { name => 'title' } - }, - order_by => {cbrebi => ['pos','create_time']} - }; - my $r = $e->json_query($q); - $ret->{bibs} = $r; - return $ret; + return $U->simplereq( + 'open-ils.actor', + 'open-ils.actor.carousel.get_contents', + $id + ); }; $ctx->{fetch_display_fields} = sub { -- 2.43.2