From 23ebad24b69e9cbf6b89e4acad8bb6e7f71a603d Mon Sep 17 00:00:00 2001 From: Jonathan Druart Date: Wed, 7 Feb 2024 16:19:19 +0100 Subject: [PATCH] Bug 34478: Add 'op' to tags/review Signed-off-by: Jonathan Druart --- .../prog/en/modules/tags/review.tt | 8 +++---- .../prog/js/pages/tags-review.js | 16 +++++++------- tags/review.pl | 21 +++++++++---------- 3 files changed, 23 insertions(+), 22 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt index 89cef4835e..a5efb15b43 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -81,8 +81,8 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% IF ( op_count ) %]
- [% IF ( op == 'approve' ) %] Approved - [% ELSIF ( op == 'reject' ) %] Rejected + [% IF ( op == 'cud-approve' ) %] Approved + [% ELSIF ( op == 'cud-reject' ) %] Rejected [% ELSIF ( op == 'test' ) %] Tested [% ELSE %]Unknown operation ([% op | html %]) on [% END %] @@ -184,8 +184,8 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
[% END %] [% IF ( tagloop ) %]
- - + +
[% END %] diff --git a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js index 0fbebacf89..39a349f196 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js @@ -1,6 +1,5 @@ review_ajax_params = { url: "/cgi-bin/koha/tags/review.pl", - type: "POST", dataType: "script" }; @@ -102,9 +101,10 @@ $(document).ready(function() { var gettitle; // window.alert(__("Click detected on ") + event.target + ": " + $(event.target).html); if ($(event.target).is('.ok')) { - $.ajax(Object.assign({}, review_ajax_params, { + $.ajax(Object.assign({}, {...review_ajax_params, type: "POST"}, { data: { - ok: $(event.target).attr("title") + tag: $(event.target).attr("title"), + op: 'cud-approve', }, success: count_approve // success_approve })); @@ -123,9 +123,10 @@ $(document).ready(function() { } } if ($(event.target).is('.rej')) { - $.ajax(Object.assign({}, review_ajax_params, { + $.ajax(Object.assign({}, {...review_ajax_params, type: "POST"}, { data: { - rej: $(event.target).attr("title") + tag: $(event.target).attr("title"), + op: 'cud-reject', }, success: count_reject // success_reject })); @@ -146,9 +147,10 @@ $(document).ready(function() { } if ($(event.target).is('#test_button')) { $(event.target).text( __("Testing...") ).prop('disabled', true); - $.ajax(Object.assign({}, review_ajax_params, { + $.ajax(Object.assign({}, {...review_ajax_params, type: "GET"}, { data: { - test: $('#test').val() + tag: $('#test').val(), + op: 'test', }, success: success_test_call // success_reject })); diff --git a/tags/review.pl b/tags/review.pl index 7cfbafe480..6df5bc5b5f 100755 --- a/tags/review.pl +++ b/tags/review.pl @@ -56,15 +56,17 @@ sub ajax_auth_cgi { # returns CGI object if (is_ajax()) { my $input = &ajax_auth_cgi($needed_flags); my $operator = C4::Context->userenv->{'number'}; # must occur AFTER auth - my ($tag, $js_reply); - if ($tag = $input->param('test')) { + my $js_reply; + my $op = $input->param('op') || q{}; + my $tag = $input->param('tag'); + if ($op eq 'test') { my $check = is_approved($tag); $js_reply = ( $check >= 1 ? 'success' : $check <= -1 ? 'failure' : 'indeterminate' ) . "_test('".uri_escape_utf8($tag)."');\n"; } - if ($tag = $input->param('ok')) { + elsif ($op eq 'cud-approve') { $js_reply = ( whitelist($operator,$tag) ? 'success' : 'failure') . "_approve('".uri_escape_utf8($tag)."');\n"; } - if ($tag = $input->param('rej')) { + elsif ($op eq 'cud-reject') { $js_reply = ( blacklist($operator,$tag) ? 'success' : 'failure') . "_reject('".uri_escape_utf8($tag)."');\n"; } output_with_http_headers $input, undef, $js_reply, 'js'; @@ -83,20 +85,17 @@ my ($template, $borrowernumber, $cookie) = get_template_and_user( } ); -my ($op, @errors, @tags); +my (@errors, @tags); -foreach (qw( approve reject test )) { - $op = $_ if ( $input->param("op-$_") ); -} -$op ||= 'none'; +my $op = $input->param('op') || q{}; @tags = $input->multi_param('tags'); -if ($op eq 'approve') { +if ($op eq 'cud-approve') { foreach (@tags) { whitelist($borrowernumber,$_) or push @errors, {failed_ok=>$_}; } -} elsif ($op eq 'reject' ) { +} elsif ($op eq 'cud-reject' ) { foreach (@tags) { blacklist($borrowernumber,$_) or push @errors, {failed_rej=>$_}; } -- 2.39.5