Skip to content

Commit

Permalink
Move UI element for deactivated templates to table footer
Browse files Browse the repository at this point in the history
  • Loading branch information
solth committed Apr 17, 2023
1 parent 411f7c0 commit fd192e2
Show file tree
Hide file tree
Showing 9 changed files with 137 additions and 23 deletions.
58 changes: 58 additions & 0 deletions Kitodo/src/main/java/org/kitodo/production/forms/TemplateForm.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,11 @@
import java.io.InputStream;
import java.text.MessageFormat;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
import java.util.Objects;

import javax.annotation.PostConstruct;
import javax.enterprise.context.SessionScoped;
import javax.inject.Named;

Expand Down Expand Up @@ -54,6 +56,9 @@ public class TemplateForm extends TemplateBaseForm {
private static final String TITLE_USED = "templateTitleAlreadyInUse";
private final String templateListPath = MessageFormat.format(REDIRECT_PATH, "projects");
private final String templateEditPath = MessageFormat.format(REDIRECT_PATH, "templateEdit");
private List<String> templateFilters;
private List<String> selectedTemplateFilters;
private static final String DEACTIVATED_TEMPLATES_FILTER = "deactivatedTemplates";

/**
* Constructor.
Expand All @@ -62,6 +67,16 @@ public TemplateForm() {
super.setLazyDTOModel(new LazyDTOModel(ServiceManager.getTemplateService()));
}

/**
* Initialize list of template filters (currently only 'deactivated templates').
*/
@PostConstruct
public void init() {
templateFilters = new LinkedList<>();
templateFilters.add(DEACTIVATED_TEMPLATES_FILTER);
selectedTemplateFilters = new LinkedList<>();
}

/**
* Check if inactive templates should be shown.
*
Expand Down Expand Up @@ -430,4 +445,47 @@ public boolean isCurrentTemplateInUse() {
return false;
}
}

/**
* Get templateFilters.
*
* @return value of templateFilters
*/
public List<String> getTemplateFilters() {
return templateFilters;
}

/**
* Set templateFilters.
*
* @param templateFilters as java.util.List<java.lang.String>
*/
public void setTemplateFilters(List<String> templateFilters) {
this.templateFilters = templateFilters;
}

/**
* Get selectedTemplateFilters.
*
* @return value of selectedTemplateFilters
*/
public List<String> getSelectedTemplateFilters() {
return selectedTemplateFilters;
}

/**
* Set selectedTemplateFilters.
*
* @param selectedTemplateFilters as java.util.List<java.lang.String>
*/
public void setSelectedTemplateFilters(List<String> selectedTemplateFilters) {
this.selectedTemplateFilters = selectedTemplateFilters;
}

/**
* Event listener for template filter changed event.
*/
public void templateFiltersChanged() {
setShowInactiveTemplates(selectedTemplateFilters.contains(DEACTIVATED_TEMPLATES_FILTER));
}
}
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/messages_de.properties
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ dataPrivacyDefaultText=Datenschutzinformationen f\u00FCr dieses System wurden no
databaseStatistic=Datenbankstatistik
day=Tag
days=Tage
deactivatedTemplates=Deaktivierte Produktionsvorlagen
defaults=Vorgaben
delete=L\u00F6schen
deleteAfterMove=Nach dem Export l\u00F6schen
Expand Down Expand Up @@ -1025,7 +1026,6 @@ showDataForProcess=Zeige Daten des Vorgangs
showHierarchyLevel=Zeige Hierarchielevel
showInSelectList=In Auswahlliste anzeigen
showInactiveProjects=Deaktivierte Projekte zeigen
showInactiveTemplates=Deaktivierte Produktionsvorlagen zeigen
showOnlyStructureElements=Zeige nur Strukturelemente
showProjectProcesses=Vorg\u00E4nge dieses Projektes anzeigen
showProjectTasks=Aktuelle Aufgaben dieses Projektes anzeigen
Expand Down
2 changes: 1 addition & 1 deletion Kitodo/src/main/resources/messages/messages_en.properties
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,7 @@ dataPrivacyDefaultText=Data privacy information have not been configured for thi
databaseStatistic=Database statistics
day=day
days=days
deactivatedTemplates=Deactivated templates
defaults=Defaults
delete=Delete
deleteAfterMove=Delete after export
Expand Down Expand Up @@ -1025,7 +1026,6 @@ showDataForProcess=show process data
showHierarchyLevel=Show hierarchy level
showInSelectList=Show in selection list
showInactiveProjects=show deactivated projects
showInactiveTemplates=show deactivated templates
showOnlyStructureElements=Show only structure elements
showProjectProcesses=Show processes of this project
showProjectTasks=Show current tasks of this project
Expand Down
19 changes: 2 additions & 17 deletions Kitodo/src/main/webapp/WEB-INF/resources/css/kitodo.css
Original file line number Diff line number Diff line change
Expand Up @@ -1325,21 +1325,6 @@ main i.fa {
text-overflow: clip;
}

#showInactiveTemplatesForm {
height: 100%;
}

#showInactiveTemplatesForm .ui-outputlabel {
display: inline-block;
height: 100%;
margin-right: var(--default-half-size);
vertical-align: middle;
}

#showInactiveTemplatesForm .switch {
display: inline;
}

.hierarchy-info {
width: calc(var(--default-double-size) + var(--default-full-size));
}
Expand Down Expand Up @@ -1800,15 +1785,15 @@ Mass import
color: var(--medium-gray);
}

.task-filter-panel.ui-selectcheckboxmenu-panel .ui-selectcheckboxmenu-items-wrapper {
.filter-panel.ui-selectcheckboxmenu-panel .ui-selectcheckboxmenu-items-wrapper {
overflow-y: hidden;
}

#tasksTabView\:filterForm {
margin-right: var(--default-full-size);
}

#tasksTabView\:filterForm .ui-selectcheckboxmenu-label,
.filter-form .ui-selectcheckboxmenu .ui-selectcheckboxmenu-label,
#tasksTabView\:statusForm .ui-selectcheckboxmenu-label {
padding-right: var(--input-height);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
xmlns:p="http://primefaces.org/ui">
<!--@elvariable id="item" type="org.kitodo.production.dto.TemplateDTO"-->
<p:dataTable id="templateTable"
widgetVar="templateTable"
styleClass="default-layout"
var="item"
value="#{TemplateForm.lazyDTOModel}"
Expand Down Expand Up @@ -189,5 +190,26 @@
</p:rowExpansion>

</p:dataTable>

<div id="dropDownMenus">
<h:form id="filterForm"
styleClass="filter-form"
style="display: inline-block;">
<p:selectCheckboxMenu id="templateFilters"
panelStyleClass="filter-panel"
value="#{TemplateForm.selectedTemplateFilters}"
styleClass="secondary"
label="#{msgs.filter}">
<f:selectItems value="#{TemplateForm.templateFilters}"
var="templateFilter"
itemLabel="#{msgs[templateFilter]}"/>
<p:ajax event="change"
onstart="PF('templateTable').getPaginator().setPage(0);"
listener="#{TemplateForm.templateFiltersChanged}"
update="templateTable"/>
</p:selectCheckboxMenu>
</h:form>
</div>

<ui:include src="/WEB-INF/templates/includes/processFromTemplate/dialogs/selectProject.xhtml"/>
</ui:composition>
Original file line number Diff line number Diff line change
Expand Up @@ -278,4 +278,40 @@
</p:rowExpansion>
</p:dataTable>
</h:form>

<div id="dropDownMenus">
<h:form id="filterForm"
styleClass="filter-form"
style="display: inline-block;">
<p:selectCheckboxMenu id="taskFilters"
panelStyleClass="filter-panel"
value="#{CurrentTaskForm.selectedTaskFilters}"
styleClass="secondary"
label="#{msgs.filter}">
<f:selectItems value="#{CurrentTaskForm.taskFilters}"
var="taskFilter"
itemLabel="#{msgs[taskFilter]}"/>
<p:ajax event="change"
onstart="PF('taskTable').getPaginator().setPage(0);"
listener="#{CurrentTaskForm.taskFiltersChanged}"
update="tasksTabView:tasksForm:taskTable"/>
</p:selectCheckboxMenu>
</h:form>
<h:form id="statusForm"
style="display: inline-block;">
<p:selectCheckboxMenu id="taskStatus"
panelStyleClass="filter-panel"
value="#{CurrentTaskForm.selectedTaskStatus}"
styleClass="secondary"
label="#{msgs.processingStatus}">
<f:selectItems value="#{CurrentTaskForm.taskStatus}"
var="taskStatus"
itemLabel="#{msgs[taskStatus.title]}"/>
<p:ajax event="change"
onstart="PF('taskTable').getPaginator().setPage(0);"
listener="#{CurrentTaskForm.taskStatusChanged}"
update="tasksTabView:tasksForm:taskTable"/>
</p:selectCheckboxMenu>
</h:form>
</div>
</ui:composition>
1 change: 0 additions & 1 deletion Kitodo/src/test/java/org/kitodo/selenium/ListingST.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,6 @@ public void listTemplatesTest() throws Exception {
assertEquals("Wrong number of templates after hiding first template", 1,
projectsPage.getTemplateTitles().size());
projectsPage.goToTemplateTab();
Thread.sleep(500);
projectsPage.toggleHiddenTemplates();
assertEquals("Wrong number of templates after toggling hidden templates", 2,
projectsPage.getTemplateTitles().size());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public abstract class Page<T> {
private static final Logger logger = LogManager.getLogger(Page.class);
static final String DATA = "_data";
static final String CSS_SELECTOR_DROPDOWN_TRIGGER = ".ui-selectonemenu-trigger";
static final String WAIT_FOR_FILTER_FORM_MENU = "Wait for filter form menu to open";

@SuppressWarnings("unused")
@FindBy(id = "user-menu")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,13 @@ public class ProjectsPage extends Page<ProjectsPage> {
@FindBy(id = RULESET_TABLE + ":0:actionForm:deleteRuleset")
private WebElement deleteFirstRulesetButton;

@FindBy(id = "showInactiveTemplateWrapper")
@FindBy(id = "filterForm:templateFilters")
private WebElement filterMenu;

@FindBy(id = "filterForm:templateFilters_panel")
private WebElement checkBoxPanel;

@FindBy(css = ".filter-panel li:last-child .ui-chkbox")
private WebElement toggleHiddenTemplatesWrapper;

public ProjectsPage() {
Expand Down Expand Up @@ -638,7 +644,14 @@ public Long getNumberOfMappingFiles() {
* Toggle switch to hide/show inactive templates.
*/
public void toggleHiddenTemplates() {
toggleHiddenTemplatesWrapper.findElement(By.className("ui-chkbox-box")).click();

filterMenu.click();
await(WAIT_FOR_FILTER_FORM_MENU).pollDelay(700, TimeUnit.MILLISECONDS)
.atMost(3, TimeUnit.SECONDS)
.until(() -> checkBoxPanel.isDisplayed());
toggleHiddenTemplatesWrapper.click();

await("Wait for template filter list to be updated").pollDelay(700, TimeUnit.MILLISECONDS)
.atMost(3, TimeUnit.SECONDS)
.until(() -> filterMenu.isEnabled());
}
}

0 comments on commit fd192e2

Please sign in to comment.