diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js b/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js index 2ce6d82fb8b..37b9bd11fdb 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js @@ -9,6 +9,9 @@ * GPL3-License.txt file that was distributed with this source code. */ +/*global PF*/ +/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^PF" }]*/ + function registerRowToggleEvents(event) { // add listener to expanded rows $(".ui-expanded-row").hover(function() { @@ -28,12 +31,31 @@ function registerRowToggleEvents(event) { ); } -$( document ).on( "click", ".allSelectable .ui-chkbox-all .ui-chkbox-box", function() { - /*global PF*/ - /*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^PF" }]*/ - if( $(this).hasClass( "ui-state-active" ) ) { +PrimeFaces.widget.DataTable.prototype.updateData = (function () { + let cachedFunction = PrimeFaces.widget.DataTable.prototype.updateData; + return function () { + let reselectAll = (typeof this.selection !== undefined && this.selection[0] === '@all'); + let result = cachedFunction.apply(this, arguments); + if (reselectAll) { + this.selectAllRows(); + } + return result; + }; +})(); + +$(document).on("click", ".allSelectable .ui-chkbox-all .ui-chkbox-box", function () { + let tableId = $(this).closest(".allSelectable").attr('id').split(":").at(-1); + let table = new PF(tableId); + if ($(this).hasClass("ui-state-active")) { new PF('allSelectableOverlayPanel').show(); - } else { - new PF('processesTable').unselectAllRows(); + } + table.unselectAllRows(); +}); + +$(document).on("click", ".allSelectable .ui-chkbox .ui-chkbox-box", function () { + let tableId = $(this).closest(".allSelectable").attr('id').split(":").at(-1); + let table = new PF(tableId); + if (typeof table.selection !== undefined && table.selection[0] === '@all') { + table.unselectAllRows(); } }); \ No newline at end of file