diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java index eb60ac7fba5..a268c17202e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java @@ -125,15 +125,6 @@ public void init() { ServiceManager.getListColumnService().getSelectedListColumnsForListAndClient("process"); } - /** - * Set selectedProcesses. - * - * @param selectedProcesses as java.util.List of {@link org.kitodo.data.database.beans.Process} - */ - public void setSelectedProcesses(List selectedProcesses) { - this.selectedProcesses = selectedProcesses; - } - /** * Return list of process properties configured as custom list columns in kitodo * configuration. @@ -483,7 +474,7 @@ public void exportPdf() { */ public void downloadToHomeForSelection() { try { - ProcessService.downloadToHome(this.selectedProcesses); + ProcessService.downloadToHome(getSelectedProcesses()); // TODO: fix message Helper.setMessage("createdInUserHomeAll"); } catch (DAOException e) { @@ -507,7 +498,7 @@ public void downloadToHomeForAll() { * Set up processing status selection. */ public void setTaskStatusUpForSelection() { - workflowControllerService.setTaskStatusUpForProcesses(this.selectedProcesses); + workflowControllerService.setTaskStatusUpForProcesses(getSelectedProcesses()); } /** @@ -521,7 +512,7 @@ public void setTaskStatusUpForAll() { * Set down processing status selection. */ public void setTaskStatusDownForSelection() { - workflowControllerService.setTaskStatusDownForProcesses(this.selectedProcesses); + workflowControllerService.setTaskStatusDownForProcesses(getSelectedProcesses()); } /** @@ -645,7 +636,7 @@ public void executeKitodoScriptAll() { * Execute Kitodo script for selected processes. */ public void executeKitodoScriptSelection() { - executeKitodoScriptForProcesses(this.selectedProcesses, this.kitodoScriptSelection); + executeKitodoScriptForProcesses(getSelectedProcesses(), this.kitodoScriptSelection); } private void executeKitodoScriptForProcesses(List processes, String kitodoScript) { @@ -1024,7 +1015,7 @@ public String changeFilter(String filter) { } private String filterList() { - this.selectedProcesses.clear(); + this.selectedProcessesOrProcessDTOs.clear(); return processesPage; } @@ -1172,4 +1163,5 @@ public String getAmount() { return ""; } } + } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java index b24b38bb905..46134c396dd 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessListBaseView.java @@ -45,7 +45,7 @@ import org.primefaces.model.charts.hbar.HorizontalBarChartModel; import org.primefaces.model.charts.pie.PieChartModel; -public class ProcessListBaseView extends BaseForm { +public class ProcessListBaseView extends BaseForm { private static final Logger logger = LogManager.getLogger(ProcessListBaseView.class); private ChartMode chartMode; @@ -56,7 +56,7 @@ public class ProcessListBaseView extends BaseForm { private int numberOfGlobalImages; private int numberOfGlobalStructuralElements; private int numberOfGlobalMetadata; - List selectedProcesses = new ArrayList<>(); + List selectedProcessesOrProcessDTOs = new ArrayList<>(); private final String doneDirectoryName = ConfigCore.getParameterOrDefaultValue(ParameterCore.DONE_DIRECTORY_NAME); DeleteProcessDialog deleteProcessDialog = new DeleteProcessDialog(); @@ -76,7 +76,19 @@ public ProcessListBaseView() { * @return value of selectedProcesses */ public List getSelectedProcesses() { - return selectedProcesses; + if (selectedProcessesOrProcessDTOs.size() > 0) { + if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) { + try { + selectedProcessesOrProcessDTOs = (List) ServiceManager.getProcessService() + .convertDtosToBeans((List) selectedProcessesOrProcessDTOs); + } catch (DAOException e) { + Helper.setErrorMessage(ERROR_LOADING_MANY, + new Object[] {ObjectType.PROCESS.getTranslationPlural() }, logger, e); + } + } + return (List) selectedProcessesOrProcessDTOs; + } + return new ArrayList<>(); } /** @@ -93,7 +105,7 @@ public HorizontalBarChartModel getStackedBarModel() { */ public void showDurationOfTasks() { chartMode = ChartMode.BAR; - stackedBarModel = ServiceManager.getProcessService().getBarChartModel(selectedProcesses); + stackedBarModel = ServiceManager.getProcessService().getBarChartModel(getSelectedProcesses()); PrimeFaces.current().executeScript("PF('statisticsDialog').show();"); PrimeFaces.current().ajax().update("statisticsDialog"); } @@ -103,7 +115,7 @@ public void showDurationOfTasks() { */ public void showStateOfVolume() { chartMode = ChartMode.PIE; - statisticResult = ServiceManager.getProcessService().getProcessTaskStates(selectedProcesses); + statisticResult = ServiceManager.getProcessService().getProcessTaskStates(getSelectedProcesses()); pieModel = ServiceManager.getProcessService().getPieChardModel(statisticResult); PrimeFaces.current().executeScript("PF('statisticsDialog').show();"); PrimeFaces.current().ajax().update("statisticsDialog"); @@ -117,7 +129,7 @@ public void showProcessMetadataStatistic() { processMetadataStatistics = new ArrayList<>(); resetGlobalStatisticValues(); Workpiece workpiece; - for (Process selectedProcess : selectedProcesses) { + for (Process selectedProcess : getSelectedProcesses()) { try { URI metadataFilePath = ServiceManager.getFileService().getMetadataFilePath(selectedProcess); workpiece = ServiceManager.getMetsService().loadWorkpiece(metadataFilePath); @@ -282,7 +294,7 @@ public boolean isShowInactiveProjects() { * Export DMS for selected processes. */ public void exportDMSForSelection() { - exportDMSForProcesses(this.selectedProcesses); + exportDMSForProcesses(getSelectedProcesses()); } /** @@ -329,6 +341,7 @@ private void exportDMSForProcesses(List processes) { ExportDms export = new ExportDms(); for (Process processToExport : processes) { try { + export.startExport(processToExport); Helper.setMessage(EXPORT_FINISHED); } catch (DataException e) { @@ -505,4 +518,12 @@ public boolean canBeExported(int processId) { } } + public List getSelectedProcessesOrProcessDTOs() { + return selectedProcessesOrProcessDTOs; + } + + public void setSelectedProcessesOrProcessDTOs(List selectedProcessesOrProcessDTOs) { + this.selectedProcessesOrProcessDTOs = selectedProcessesOrProcessDTOs; + } + } diff --git a/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java b/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java index 5a51909c407..e12acd18b5e 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/SearchResultForm.java @@ -53,20 +53,6 @@ public class SearchResultForm extends ProcessListBaseView { private final String searchResultListPath = MessageFormat.format(REDIRECT_PATH, "searchResult"); private final WorkflowControllerService workflowControllerService = new WorkflowControllerService(); - /** - * Set selectedProcesses. - * - * @param selectedProcesses as java.util.List of {@link org.kitodo.production.dto.ProcessDTO} - */ - public void setSelectedProcesses(List selectedProcesses) { - try { - this.selectedProcesses = ServiceManager.getProcessService().convertDtosToBeans(selectedProcesses); - } catch (DAOException e) { - Helper.setErrorMessage(ERROR_LOADING_MANY, new Object[] {ObjectType.PROCESS.getTranslationPlural() }, - logger, e); - } - } - /** * Searches for processes with the entered searchQuery. * @@ -324,4 +310,5 @@ public Integer getCurrentProjectFilter() { public void setCurrentProjectFilter(Integer currentProjectFilter) { this.currentProjectFilter = currentProjectFilter; } + } diff --git a/Kitodo/src/main/resources/messages/messages_de.properties b/Kitodo/src/main/resources/messages/messages_de.properties index 22d04ecc0e6..044daf22296 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -929,6 +929,8 @@ surname=Nachname save=Speichern saveExit=Speichern \u0026 Schlie\u00DFen search=Suche +selectAllRows=Alle Treffer +selectAllRowsOnPage=Alle Treffer dieser Seite start=Start startDate=Startdatum startIndexing=Indexierung starten diff --git a/Kitodo/src/main/resources/messages/messages_en.properties b/Kitodo/src/main/resources/messages/messages_en.properties index 7e05fd455ac..ade64520f9b 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -945,6 +945,8 @@ surname=Surname save=Save saveExit=Save \u0026 exit search=Search +selectAllRows=Select all rows +selectAllRowsOnPage=Select all rows on page start=Start startDate=Start date startIndexing=Start indexing diff --git a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css index 36ef236cd48..91a9191b204 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css +++ b/Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css @@ -1103,6 +1103,23 @@ h3#headerText { vertical-align: middle; } +.allSelectableOverlayPanel { + top: 36px; + left: 16px; +} + +.allSelectableOverlayPanel ul { + list-style: none; +} + +.allSelectableOverlayPanel ul li { + margin-top: 5px; +} + +.allSelectableOverlayPanel ul li:first-child { + margin-top: 0; +} + #processesTabView\:processesForm\:processesTable .ui-row-toggler { margin-right: 8px; } 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 3d0848ca239..28ed1868e60 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,10 @@ * GPL3-License.txt file that was distributed with this source code. */ +/*global PF, PrimeFaces*/ +/*eslint new-cap: ["error", { "capIsNewExceptionPattern": "^PF" }]*/ +/*eslint wrap-iife: ["error", "any"]*/ + function registerRowToggleEvents(event) { // add listener to expanded rows $(".ui-expanded-row").hover(function() { @@ -27,3 +31,32 @@ function registerRowToggleEvents(event) { } ); } + +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(); + } + 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(); + } +}); diff --git a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processes/processList.xhtml b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processes/processList.xhtml index d852c213384..072fa84e21a 100644 --- a/Kitodo/src/main/webapp/WEB-INF/templates/includes/processes/processList.xhtml +++ b/Kitodo/src/main/webapp/WEB-INF/templates/includes/processes/processList.xhtml @@ -21,11 +21,11 @@ + + @@ -218,6 +220,14 @@ + + +
    +
  • +
  • +
+
+