From 8eb9798cc746a3bc371857e248aa35f70f1c4cf5 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 Signed-off-by: Kyle M Hall --- Koha/Illrequest.pm | 31 ++++++++++++++++++- 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(+), 6 deletions(-) diff --git a/Koha/Illrequest.pm b/Koha/Illrequest.pm index 8d03599dfe8..f0e1a9e76f2 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2067,7 +2067,6 @@ sub strings_map { return $strings; } - =head3 get_op_param_deprecation my $op = Koha::Illrequest->check_url_param_deprecation($params); @@ -2124,6 +2123,36 @@ sub get_op_param_deprecation { return $op; } +=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 d9278b6db8f..3a3faccc29f 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -407,6 +407,7 @@ if ( $backends_available ) { } } + $template->param( table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ) ); } elsif ( $op eq "save_comment" ) { my $comment = Koha::Illcomment->new({ illrequest_id => scalar $params->{illrequest_id}, 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 01ec9a0b3ec..184faf7fb27 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 op == 'illlist' %] +