Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#3747 implementation of all processes selection #4722

Merged
merged 7 commits into from
Nov 22, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 6 additions & 14 deletions Kitodo/src/main/java/org/kitodo/production/forms/ProcessForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -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<Process> selectedProcesses) {
this.selectedProcesses = selectedProcesses;
}

/**
* Return list of process properties configured as custom list columns in kitodo
* configuration.
Expand Down Expand Up @@ -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) {
Expand All @@ -507,7 +498,7 @@ public void downloadToHomeForAll() {
* Set up processing status selection.
*/
public void setTaskStatusUpForSelection() {
workflowControllerService.setTaskStatusUpForProcesses(this.selectedProcesses);
workflowControllerService.setTaskStatusUpForProcesses(getSelectedProcesses());
}

/**
Expand All @@ -521,7 +512,7 @@ public void setTaskStatusUpForAll() {
* Set down processing status selection.
*/
public void setTaskStatusDownForSelection() {
workflowControllerService.setTaskStatusDownForProcesses(this.selectedProcesses);
workflowControllerService.setTaskStatusDownForProcesses(getSelectedProcesses());
}

/**
Expand Down Expand Up @@ -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<Process> processes, String kitodoScript) {
Expand Down Expand Up @@ -1024,7 +1015,7 @@ public String changeFilter(String filter) {
}

private String filterList() {
this.selectedProcesses.clear();
this.selectedProcessesOrProcessDTOs.clear();
return processesPage;
}

Expand Down Expand Up @@ -1172,4 +1163,5 @@ public String getAmount() {
return "";
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<T> extends BaseForm {

private static final Logger logger = LogManager.getLogger(ProcessListBaseView.class);
private ChartMode chartMode;
Expand All @@ -56,7 +56,7 @@ public class ProcessListBaseView extends BaseForm {
private int numberOfGlobalImages;
private int numberOfGlobalStructuralElements;
private int numberOfGlobalMetadata;
List<Process> selectedProcesses = new ArrayList<>();
List<T> selectedProcessesOrProcessDTOs = new ArrayList<>();
private final String doneDirectoryName = ConfigCore.getParameterOrDefaultValue(ParameterCore.DONE_DIRECTORY_NAME);
DeleteProcessDialog deleteProcessDialog = new DeleteProcessDialog();

Expand All @@ -76,7 +76,19 @@ public ProcessListBaseView() {
* @return value of selectedProcesses
*/
public List<Process> getSelectedProcesses() {
return selectedProcesses;
if (selectedProcessesOrProcessDTOs.size() > 0) {
if (selectedProcessesOrProcessDTOs.get(0) instanceof ProcessDTO) {
try {
selectedProcessesOrProcessDTOs = (List<T>) ServiceManager.getProcessService()
.convertDtosToBeans((List<ProcessDTO>) selectedProcessesOrProcessDTOs);
} catch (DAOException e) {
Helper.setErrorMessage(ERROR_LOADING_MANY,
new Object[] {ObjectType.PROCESS.getTranslationPlural() }, logger, e);
}
}
return (List<Process>) selectedProcessesOrProcessDTOs;
}
return new ArrayList<>();
}

/**
Expand All @@ -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");
}
Expand All @@ -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");
Expand All @@ -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);
Expand Down Expand Up @@ -282,7 +294,7 @@ public boolean isShowInactiveProjects() {
* Export DMS for selected processes.
*/
public void exportDMSForSelection() {
exportDMSForProcesses(this.selectedProcesses);
exportDMSForProcesses(getSelectedProcesses());
}

/**
Expand Down Expand Up @@ -329,6 +341,7 @@ private void exportDMSForProcesses(List<Process> processes) {
ExportDms export = new ExportDms();
for (Process processToExport : processes) {
try {

export.startExport(processToExport);
Helper.setMessage(EXPORT_FINISHED);
} catch (DataException e) {
Expand Down Expand Up @@ -505,4 +518,12 @@ public boolean canBeExported(int processId) {
}
}

public List<T> getSelectedProcessesOrProcessDTOs() {
return selectedProcessesOrProcessDTOs;
}

public void setSelectedProcessesOrProcessDTOs(List<T> selectedProcessesOrProcessDTOs) {
this.selectedProcessesOrProcessDTOs = selectedProcessesOrProcessDTOs;
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -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<ProcessDTO> 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.
*
Expand Down Expand Up @@ -324,4 +310,5 @@ public Integer getCurrentProjectFilter() {
public void setCurrentProjectFilter(Integer currentProjectFilter) {
this.currentProjectFilter = currentProjectFilter;
}

}
2 changes: 2 additions & 0 deletions Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 17 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand Down
33 changes: 33 additions & 0 deletions Kitodo/src/main/webapp/WEB-INF/resources/js/lists.js
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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();
}
});
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,11 @@
<!--@elvariable id="process" type="org.kitodo.production.dto.ProcessDTO"-->
<p:dataTable id="processesTable"
widgetVar="processesTable"
styleClass="default-layout"
styleClass="default-layout allSelectable"
var="process"
value="#{ProcessForm.lazyDTOModel}"
first="#{ProcessForm.firstRow}"
selection="#{ProcessForm.selectedProcesses}"
selection="#{ProcessForm.selectedProcessesOrProcessDTOs}"
lazy="true"
paginator="true"
resizableColumns="true"
Expand All @@ -37,12 +37,14 @@
currentPageReportTemplate="#{msgs.currentPageReportTemplate}"
paginatorPosition="bottom">


<p:ajax event="page"
listener="#{ProcessForm.onPageChange}"/>
<p:ajax event="rowToggle"
oncomplete="registerRowToggleEvents();" />

<p:column styleClass="checkboxListColumn" selectionMode="multiple" resizable="false"/>

<p:column styleClass="hierarchy-info">
<p:rowToggler rendered="#{process.getParentID() ne 0 or process.hasChildren() or ProcessForm.getCurrentTasksForUser(process).size() gt 0}"/>
<h:outputText rendered="#{process.getParentID() ne 0 and not process.hasChildren()}"><i class="fa fa-long-arrow-left" title="#{msgs.hierarchicalParents}"/></h:outputText>
Expand Down Expand Up @@ -218,6 +220,14 @@
</p:rowExpansion>

</p:dataTable>

<p:overlayPanel widgetVar="allSelectableOverlayPanel" dismissable="true" styleClass="allSelectableOverlayPanel" >
<ul>
<li><p:commandLink value="#{msgs.selectAllRowsOnPage}" onclick="PF('processesTable').unselectAllRows();PF('processesTable').selectAllRowsOnPage();PF('allSelectableOverlayPanel').hide();"/></li>
<li><p:commandLink value="#{msgs.selectAllRows}" onclick="PF('processesTable').selectAllRows();PF('allSelectableOverlayPanel').hide();"/></li>
</ul>
</p:overlayPanel>

<div id="dropDownMenus">
<p:commandButton id="actionsButton" value="#{msgs.possibleActions}" styleClass="secondary"
icon="fa fa-sort" iconPos="right" process="@this"/>
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/webapp/pages/searchResult.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
styleClass="default-layout"
var="process"
value="#{SearchResultForm.filteredList}"
selection="#{SearchResultForm.selectedProcesses}"
selection="#{SearchResultForm.selectedProcessesOrProcessDTOs}"
rowKey="#{process.id}"
paginator="true"
rows="#{LoginForm.loggedUser.tableSize}"
Expand Down