From dc170fcafe2afb130b4117a195b78014a8675c96 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Sat, 1 Aug 2020 00:37:32 +0000 Subject: [PATCH] Bug 26120: Remove the use of jquery.checkboxes plugin from tags review template This patch removes the use of the jquery.checkboxes plugin and improves the handling of tag status markup so that the "Select all pending" selection link works correctly. To test, apply the patch and go to Tools -> Tags. To test properly you should have multiple tags awaiting moderation. - The initial view of tags moderation shows only tags awaiting moderation. Test that the "select all," "clear all," and "Select all pending" links work correctly. - Click the "Approve" button for a tag, and the "Reject" button for another tag. - Test the "Select all pending" link again. Only the tags awaiting moderation should be selected. Signed-off-by: David Nind Signed-off-by: Katrin Fischer Signed-off-by: Jonathan Druart (cherry picked from commit 99befa42c80eddec6e49aa1a86b77e74f529f0bd) Signed-off-by: Lucas Gass --- .../prog/en/modules/tags/review.tt | 26 ++++++++----- .../prog/js/pages/tags-review.js | 38 +++++++++++++------ 2 files changed, 44 insertions(+), 20 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 32af227d02..e588174d32 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/tags/review.tt @@ -76,7 +76,6 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } - @@ -89,18 +88,28 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% FOREACH tagloo IN tagloop %] - - [% IF ( tagloo.approved == 0 ) %]
    Status Term
[% offset + loop.count | html %] - - [% ELSE %][% END %] + + [% IF ( tagloo.approved == 0 ) %] + + [% ELSIF ( tagloo.approved == 1 ) %] + + [% ELSE %] + + [% END %] [% IF ( tagloo.approved == -1 ) %] - Rejected + [% ELSIF ( tagloo.approved == 1 ) %] - Approved + [% ELSE %] - Pending + [% END %] [% tagloo.term | html %] @@ -228,7 +237,6 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; } [% MACRO jsinclude BLOCK %] [% INCLUDE 'datatables.inc' %] [% INCLUDE 'calendar.inc' %] - [% Asset.js("lib/jquery/plugins/jquery.checkboxes.min.js") | $raw %] [% Asset.js("js/pages/tags-review.js") | $raw %] [% 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 842ffb9acf..f5ee5245d2 100644 --- a/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js +++ b/koha-tmpl/intranet-tmpl/prog/js/pages/tags-review.js @@ -65,23 +65,37 @@ $(document).ready(function() { { "sType": "anti-the", "aTargets" : [ "anti-the" ] }, { "sType": "title-string", "aTargets" : [ "title-string" ] } ], - "aaSorting": [[ 4, "desc" ]], + "aaSorting": [[ 2, "desc" ]], "sPaginationType": "full" })); $('.ajax_buttons' ).css({visibility:"visible"}); $("p.check").html("
<\/i> " + __("Select all") + "<\/a> | <\/i> " + __("Clear all") + "<\/a> | " + __("Select all pending") + "<\/a><\/div>"); - $("#CheckAll").click(function(){ - $(".checkboxed").checkCheckboxes(); - return false; + + $("#CheckAll").on("click", function (e) { + e.preventDefault(); + $("#tagst input:checkbox").each(function () { + $(this).prop("checked", true); + }); }); - $("#CheckNone").click(function(){ - $(".checkboxed").unCheckCheckboxes(); - return false; + + $("#CheckNone").on("click", function(e){ + e.preventDefault(); + $("#tagst input:checkbox").each(function(){ + $(this).prop("checked", false ); + }); }); - $("#CheckPending").click(function(){ - $(".checkboxed").checkCheckboxes(".pending"); - return false; + + $("#CheckPending").on("click", function (e) { + e.preventDefault(); + $("#tagst input:checkbox").each(function () { + if( $(this).hasClass("pending") ){ + $(this).prop("checked", true); + } else { + $(this).prop("checked", false); + } + }); }); + $(".approval_btn").on('click',function(event) { event.preventDefault(); pull_counts(); @@ -102,6 +116,7 @@ $(document).ready(function() { getelement = $(event.target).data("num"); gettitle = ".status" + getelement; $(gettitle).text( __("Approved") ); + $("#checkbox" + getelement ).attr("class", "approved"); if ($(gettitle).hasClass("pending") ){ $(gettitle).toggleClass("pending approved"); } else { @@ -121,7 +136,8 @@ $(document).ready(function() { $(event.target).html(" " + __("Rejected")); getelement = $(event.target).data("num"); gettitle = ".status" + getelement; - $(gettitle).text( __("Rejected") ); + $(gettitle).text(__("Rejected")); + $("#checkbox" + getelement).attr("class", "rejected"); if ($(gettitle).hasClass("pending") ){ $(gettitle).toggleClass("pending rejected"); } else { -- 2.39.5