Bugzilla – Attachment 159105 Details for
Bug 35331
Add an ILL table actions plugin hook
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 35331: Add table actions hook to ILL table
Bug-35331-Add-table-actions-hook-to-ILL-table.patch (text/plain), 5.43 KB, created by
Kyle M Hall (khall)
on 2023-11-17 18:26:03 UTC
(
hide
)
Description:
Bug 35331: Add table actions hook to ILL table
Filename:
MIME Type:
Creator:
Kyle M Hall (khall)
Created:
2023-11-17 18:26:03 UTC
Size:
5.43 KB
patch
obsolete
>From 0c07559ef34c16f6de21a00182352bcb8ae6838f Mon Sep 17 00:00:00 2001 >From: Pedro Amorim <pedro.amorim@ptfs-europe.com> >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 <david@davidnind.com> >Signed-off-by: Kyle M Hall <kyle@bywatersolutions.com> >--- > 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 831d6fa52de..5f6dea5c7b1 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 a668b259791..6a3529c65af 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 87d73fc747c..7296b5cf6e1 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 @@ > <div class="row"> > > [% IF query_type == 'illlist' %] >+ <script> >+ var ill_table_actions = [% table_actions | $raw %]; >+ </script> > <div class="col-sm-2"> > <aside> > <form method="get" id="illfilter_form"> >diff --git a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >index 8d564a4ee7a..310a40cbfce 100644 >--- a/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >+++ b/koha-tmpl/intranet-tmpl/prog/js/ill-list-table.js >@@ -408,11 +408,7 @@ $(document).ready(function() { > "orderable": false, > "searchable": false, > "render": function( data, type, row, meta ) { >- return '<a class="btn btn-default btn-sm" ' + >- 'href="/cgi-bin/koha/ill/ill-requests.pl?' + >- 'method=illview&illrequest_id=' + >- encodeURIComponent(data) + >- '">' + ill_manage + '</a>'; >+ return render_table_actions(data); > } > } > ] >@@ -420,6 +416,20 @@ $(document).ready(function() { > > $("#illfilter_form").on('submit', filter); > >+ function render_table_actions(data) { >+ let actions_string = ""; >+ ill_table_actions.forEach((ill_table_action) => { >+ let link_data = ill_table_action.append_column_data_to_link >+ ? encodeURIComponent(data) >+ : ""; >+ let link_text = ill_table_action.button_link_translatable_text >+ ? eval(ill_table_action.button_link_translatable_text) >+ : ill_table_action.button_link_text; >+ actions_string += `<a class="${ill_table_action.button_class}" href="${ill_table_action.button_link}${link_data}">${link_text}</a>`; >+ }); >+ return actions_string; >+ } >+ > function redrawTable() { > let table_dt = ill_requests_table.DataTable(); > table_dt.draw(); >-- >2.30.2
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 35331
:
158916
|
158917
|
158993
|
159037
|
159046
|
159047
|
159048
|
159049
|
159105
|
159106
|
159107
|
159108
|
159109
|
160634
|
160635
|
160636
|
160637
|
162812
|
162813
|
162814
|
162815
|
162816