From 2f4513a52de4d0a1558d9761aebc4b80ddd282f2 Mon Sep 17 00:00:00 2001 From: Markus Weigelt Date: Tue, 5 Oct 2021 18:15:08 +0200 Subject: [PATCH] #3747 implementation of all processes selection --- .../kitodo/production/forms/ProcessForm.java | 20 ++++------- .../production/forms/ProcessListBaseView.java | 35 +++++++++++++++---- .../production/forms/SearchResultForm.java | 15 +------- .../resources/messages/messages_de.properties | 2 ++ .../resources/messages/messages_en.properties | 2 ++ .../webapp/WEB-INF/resources/css/kitodo.css | 17 +++++++++ .../main/webapp/WEB-INF/resources/js/lists.js | 8 +++++ .../includes/processes/processList.xhtml | 14 ++++++-- .../src/main/webapp/pages/searchResult.xhtml | 2 +- 9 files changed, 77 insertions(+), 38 deletions(-) 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 cf548461497..fb7b1c13831 100644 --- a/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java +++ b/Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java @@ -124,15 +124,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. @@ -486,7 +477,7 @@ public void exportPdf() { */ public void downloadToHomeForSelection() { try { - ProcessService.downloadToHome(this.selectedProcesses); + ProcessService.downloadToHome(getSelectedProcesses()); // TODO: fix message Helper.setMessage("createdInUserHomeAll"); } catch (DAOException e) { @@ -510,7 +501,7 @@ public void downloadToHomeForAll() { * Set up processing status selection. */ public void setTaskStatusUpForSelection() { - workflowControllerService.setTaskStatusUpForProcesses(this.selectedProcesses); + workflowControllerService.setTaskStatusUpForProcesses(getSelectedProcesses()); } /** @@ -524,7 +515,7 @@ public void setTaskStatusUpForAll() { * Set down processing status selection. */ public void setTaskStatusDownForSelection() { - workflowControllerService.setTaskStatusDownForProcesses(this.selectedProcesses); + workflowControllerService.setTaskStatusDownForProcesses(getSelectedProcesses()); } /** @@ -648,7 +639,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) { @@ -1027,7 +1018,7 @@ public String changeFilter(String filter) { } private String filterList() { - this.selectedProcesses.clear(); + this.selectedProcessesOrProcessDTOs.clear(); return processesPage; } @@ -1175,4 +1166,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 8ebfa1e1fbc..f9b8f04b8a5 100644 --- a/Kitodo/src/main/resources/messages/messages_de.properties +++ b/Kitodo/src/main/resources/messages/messages_de.properties @@ -921,6 +921,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 605177bf8d5..a555fa2c939 100644 --- a/Kitodo/src/main/resources/messages/messages_en.properties +++ b/Kitodo/src/main/resources/messages/messages_en.properties @@ -937,6 +937,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 b1a7edbcc9c..265fea85d95 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: 0px; +} + #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..ea8d4a8e661 100644 --- a/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js +++ b/Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js @@ -27,3 +27,11 @@ function registerRowToggleEvents(event) { } ); } + +$( document ).on( "click", ".allSelectable .ui-chkbox-all .ui-chkbox-box", function() { + if( $(this).hasClass( "ui-state-active" ) ) { + PF('allSelectableOverlayPanel').show(); + } else { + PF('processesTable').unselectAllRows(); + } +}); \ No newline at end of file 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 @@ + + +
    +
  • +
  • +
+
+