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> Signed-off-by: Katrin Fischer <katrin.fischer@bsz-bw.de>
This commit is contained in:
parent
d94bf8a5d5
commit
d337541353
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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},
|
||||
|
|
|
|||
|
|
@ -56,6 +56,9 @@
|
|||
<div class="row">
|
||||
|
||||
[% IF op == 'illlist' %]
|
||||
<script>
|
||||
var ill_table_actions = [% table_actions | $raw %];
|
||||
</script>
|
||||
<div class="col-sm-2">
|
||||
<aside>
|
||||
<form method="get" id="illfilter_form">
|
||||
|
|
|
|||
|
|
@ -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?' +
|
||||
'op=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();
|
||||
|
|
|
|||
Loading…
Reference in New Issue