From ae1f515446e7ee1f31700df42b810a0ce1061cf5 Mon Sep 17 00:00:00 2001 From: Ozzieisaacs Date: Mon, 27 Dec 2021 20:02:42 +0100 Subject: [PATCH] Bugfix uncheck all ekements in books list and user list Improved testability for books list --- cps/static/js/table.js | 30 +++++++++++++++--------------- cps/templates/book_table.html | 4 ++-- 2 files changed, 17 insertions(+), 17 deletions(-) diff --git a/cps/static/js/table.js b/cps/static/js/table.js index e98f6a8b..112ca957 100644 --- a/cps/static/js/table.js +++ b/cps/static/js/table.js @@ -47,15 +47,15 @@ $(function() { var rows = rowsAfter; if (e.type === "uncheck-all") { - rows = rowsBefore; + selections = []; + } else { + var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { + return row.id; + }); + + var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; + selections = window._[func](selections, ids); } - - var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { - return row.id; - }); - - var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; - selections = window._[func](selections, ids); if (selections.length >= 2) { $("#merge_books").removeClass("disabled"); $("#merge_books").attr("aria-disabled", false); @@ -540,14 +540,14 @@ $(function() { var rows = rowsAfter; if (e.type === "uncheck-all") { - rows = rowsBefore; + selections = []; + } else { + var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { + return row.id; + }); + var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; + selections = window._[func](selections, ids); } - - var ids = $.map(!$.isArray(rows) ? [rows] : rows, function (row) { - return row.id; - }); - var func = $.inArray(e.type, ["check", "check-all"]) > -1 ? "union" : "difference"; - selections = window._[func](selections, ids); handle_header_buttons(); }); }); diff --git a/cps/templates/book_table.html b/cps/templates/book_table.html index fb0cfed8..eb5c1bff 100644 --- a/cps/templates/book_table.html +++ b/cps/templates/book_table.html @@ -120,8 +120,8 @@