From d337541353580e936a70c7548ce77942694d65af 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 Signed-off-by: Katrin Fischer --- 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 95f61b3de4..bfaf284bdd 100644 --- a/Koha/Illrequest.pm +++ b/Koha/Illrequest.pm @@ -2003,7 +2003,6 @@ sub strings_map { return $strings; } - =head3 get_op_param_deprecation my $op = Koha::Illrequest->check_url_param_deprecation($params); @@ -2062,6 +2061,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 2c70d1ca06..9087825a0d 100755 --- a/ill/ill-requests.pl +++ b/ill/ill-requests.pl @@ -409,6 +409,7 @@ if ( $backends_available ) { } } + $template->param( table_actions => encode_json( Koha::Illrequest->get_staff_table_actions ) ) } elsif ( $op eq "cud-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 e7b2f20e59..1ae4f9b2cf 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' %] +