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..bf1622a8af4 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js @@ -28,12 +28,35 @@ function registerRowToggleEvents(event) { ); } -$( document ).on( "click", ".allSelectable .ui-chkbox-all .ui-chkbox-box", function() { +PrimeFaces.widget.DataTable.prototype.updateData = (function () { + let cached_function = PrimeFaces.widget.DataTable.prototype.updateData; + return function () { + let reselectAll = (this.selection != undefined && this.selection[0] === '@all'); + let result = cached_function.apply(this, arguments); + if (reselectAll) { + this.selectAllRows(); + } + return result; + }; +})(); + +$(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" ) ) { + 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 () { + /*global PF*/ + /*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^PF" }]*/ + let tableId = $(this).closest(".allSelectable").attr('id').split(":").at(-1); + let table = new PF(tableId); + if (table.selection != undefined && table.selection[0] === '@all') { + table.unselectAllRows(); } }); \ No newline at end of file