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 <david@davidnind.com>

Signed-off-by: Katrin Fischer <katrin.fischer.83@web.de>

Signed-off-by: Jonathan Druart <jonathan.druart@bugs.koha-community.org>
This commit is contained in:
Owen Leonard 2020-08-01 00:37:32 +00:00 committed by Jonathan Druart
parent f0275e6677
commit 99befa42c8
2 changed files with 44 additions and 20 deletions

View file

@ -76,7 +76,6 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
<table id="tagst">
<thead>
<tr>
<th class="NoSort">&nbsp;</th>
<th class="NoSort">&nbsp;</th>
<th>Status</th>
<th>Term</th>
@ -89,18 +88,28 @@ tr > td input,td input[type="submit"] { font-size: 85%; padding: 1px; }
<tbody>
[% FOREACH tagloo IN tagloop %]
<tr>
<td class="count">[% offset + loop.count | html %]
</td>
[% IF ( tagloo.approved == 0 ) %]<td><span><input type="checkbox" value="[% tagloo.term | html %]" name="tags" class="pending" /></span>
[% ELSE %]<td><span><input type="checkbox" value="[% tagloo.term | html %]" name="tags" /></span>[% END %]
<td>
[% IF ( tagloo.approved == 0 ) %]
<input id="checkbox[% offset + loop.count | html %]" type="checkbox" value="[% tagloo.term | html %]" name="tags" class="pending" />
[% ELSIF ( tagloo.approved == 1 ) %]
<input id="checkbox[% offset + loop.count | html %]" type="checkbox" value="[% tagloo.term | html %]" name="tags" class="approved" />
[% ELSE %]
<input id="checkbox[% offset + loop.count | html %]" type="checkbox" value="[% tagloo.term | html %]" name="tags" class="rejected" />
[% END %]
</td>
<td>
[% IF ( tagloo.approved == -1 ) %]
<span class="rejected status[% offset + loop.count | html %]">Rejected</span>
<label for="checkbox[% offset + loop.count | html %]">
<span class="rejected status[% offset + loop.count | html %]">Rejected</span>
</label>
[% ELSIF ( tagloo.approved == 1 ) %]
<span class="approved status[% offset + loop.count | html %]">Approved</span>
<label for="checkbox[% offset + loop.count | html %]">
<span class="approved status[% offset + loop.count | html %]">Approved</span>
</label>
[% ELSE %]
<span class="pending status[% offset + loop.count | html %]">Pending</span>
<label for="checkbox[% offset + loop.count | html %]">
<span class="pending status[% offset + loop.count | html %]">Pending</span>
</label>
[% END %]
</td>
<td><a href="/cgi-bin/koha/tags/list.pl?tag=[% tagloo.term|uri %]">[% tagloo.term | html %]</a>
@ -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 %]

View file

@ -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("<div id=\"searchheader\"><a id=\"CheckAll\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-check\" aria-hidden=\"false\"><\/i> " + __("Select all") + "<\/a> | <a id=\"CheckNone\" href=\"/cgi-bin/koha/tags/review.pl\"><i class=\"fa fa-remove\" aria-hidden=\"false\"><\/i> " + __("Clear all") + "<\/a> | <a id=\"CheckPending\" href=\"/cgi-bin/koha/tags/review.pl\"> " + __("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("<i class='fa fa-remove' aria-hidden='false'></i> " + __("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 {