From 7aea4af36a2443d12aee3e910d6fd7fb0d605291 Mon Sep 17 00:00:00 2001 From: Pedro Amorim Date: Mon, 13 Nov 2023 17:24:23 +0000 Subject: [PATCH] Bug 35331: Add table actions hook to ILL table Test plan, k-t-d, apply patches: 1) Install FreeForm backend, enable ILLModule sys pref, run: bash <(curl -s https://raw.githubusercontent.com/ammopt/koha-ill-dev/master/start-ill-dev.sh) 2) Navigate to ILL requests, visit: /cgi-bin/koha/ill/ill-requests.pl 3) Click '+New ILL request', select a type, enter an existing cardnumber (e.g. '42') and pick a library. Click 'Create'. 4) Visit ILL requests again, repeat 2) 5) Notice the row for the created request has the already existing action button 'Manage request' 6) Install the ILL actions plugin, located at: https://github.com/PTFS-Europe/koha-plugin-ill-actions/releases/tag/v1.0.0 7) Restart plack, run: koha-plack --restart kohadev 8) Repeat 4) and 5). Notice the row for the created request now has a new custom action in addition to the already existing core one. Signed-off-by: David Nind --- Koha/Illrequest.pm | 30 +++++++++++++++++++ ill/ill-requests.pl | 1 + .../prog/en/modules/ill/ill-requests.tt | 3 ++ .../intranet-tmpl/prog/js/ill-list-table.js | 20 +++++++++---- 4 files changed, 49 insertions(+), 5 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 831d6fa52d..5f6dea5c7b 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2003,6 +2003,36 @@ sub strings_map { return $strings; } +=head3 get_staff_table_actions + + my $ill_table_actions = $self->get_staff_table_actions; + +Returns the table actions available in the Staff ILL list table +A total join of core static actions with custom actions provided by +installed plugins that implement the ill_table_actions hook + +=cut + +sub get_staff_table_actions { + my ( $self, $params ) = @_; + + my $ill_table_actions = [ + { + button_class => 'btn btn-default btn-sm', + button_link => '/cgi-bin/koha/ill/ill-requests.pl?method=illview&illrequest_id=', + append_column_data_to_link => 1, + button_link_translatable_text => 'ill_manage', + } + ]; + + my @plugin_responses = Koha::Plugins->call('ill_table_actions'); + for my $plugin_variables (@plugin_responses) { + push( @{$ill_table_actions}, $plugin_variables ); + } + + return $ill_table_actions; +} + =head3 _type =cut diff --git a/ill/ill-requests.pl b/ill/ill-requests.pl index a668b25979..6a3529c65a 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -410,6 +410,7 @@ if ( $backends_available ) { } } + $template->param( table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ) ); } elsif ( $op eq "save_comment" ) { die "Wrong CSRF token" unless Koha::Token->new->check_csrf({ session_id => scalar $cgi->cookie('CGISESSID'), diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt index 87d73fc747..7296b5cf6e 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/ill/ill-requests.tt @@ -56,6 +56,9 @@
[% IF query_type == 'illlist' %] +