From b366155e92819dde39a43dc37a210a0f18a4c090 Mon Sep 17 00:00:00 2001 From: Matt Blenkinsop Date: Thu, 17 Oct 2024 07:47:00 +0000 Subject: [PATCH] Bug 38010: Respect AcqViewBaskets syspref --- Koha/REST/V1/Acquisitions/Baskets.pm | 19 ++++++++++++++++--- .../prog/en/modules/acqui/vendors.tt | 3 +-- .../prog/js/vue/components/Vendors/Main.vue | 1 + 3 files changed, 18 insertions(+), 5 deletions(-) diff --git a/Koha/REST/V1/Acquisitions/Baskets.pm b/Koha/REST/V1/Acquisitions/Baskets.pm index b7f39b81448..1f0326e646c 100644 --- a/Koha/REST/V1/Acquisitions/Baskets.pm +++ b/Koha/REST/V1/Acquisitions/Baskets.pm @@ -18,9 +18,10 @@ package Koha::REST::V1::Acquisitions::Baskets; use Modern::Perl; use Mojo::Base 'Mojolicious::Controller'; - use Try::Tiny qw( catch try ); +use C4::Acquisition qw( CanUserManageBasket ); + =head1 NAME Koha::REST::V1::Acquisitions::Baskets @@ -65,13 +66,25 @@ Return a list of baskets =cut sub list { - my $c = shift->openapi->valid_input or return; + my $c = shift->openapi->valid_input or return; + my $patron = $c->stash('koha.user'); return try { + my $baskets_rs = Koha::Acquisition::Baskets->new; + my $baskets = $c->objects->search($baskets_rs); + + my $userflags = C4::Auth::getuserflags( $patron->flags, $patron->userid ); + + my @user_baskets; + foreach my $basket (@$baskets) { + my $success = CanUserManageBasket( $patron->unblessed, $basket, $userflags ); + push @user_baskets, $basket if $success; + } + return $c->render( status => 200, - openapi => $c->objects->search( Koha::Acquisition::Baskets->new ), + openapi => \@user_baskets ); } catch { $c->unhandled_exception($_); diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt index 4497e3362a1..f71b42881f5 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/acqui/vendors.tt @@ -32,8 +32,7 @@ const userPermissions = [% To.json(user_permissions) | $raw %]; const currencies = [% To.json(currencies) | $raw %]; const gstValues = [% To.json(gst_values) | $raw %]; - const edifact = [% To.json(edifact) | $raw %] - const viewBaskets = [% To.json(viewbaskets) | $raw %] + const edifact = [% To.json(edifact) | $raw %]; diff --git a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue index 552be59f6b3..abad2f756ab 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue +++ b/koha-tmpl/intranet-tmpl/prog/js/vue/components/Vendors/Main.vue @@ -95,6 +95,7 @@ export default { fetchConfig().then(() => { this.loaded() this.userPermissions = userPermissions + this.config.settings.edifact = edifact this.vendorStore.currencies = currencies this.vendorStore.gstValues = gstValues.map(gv => { return { -- 2.39.3 (Apple Git-146)