Skip to content

Commit

Permalink
Initial filtering implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
markusweigelt committed Oct 11, 2023
1 parent e107408 commit 77d8725
Show file tree
Hide file tree
Showing 8 changed files with 76 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,13 @@ default boolean isComplex() {
*/
boolean isEditable();

/**
* Returns whether values under this key can be filtered in this view.
*
* @return whether values can be filtered
*/
boolean isFilterable();

/**
* Returns whether the value corresponds to the value range. The value range
* can be determined in various ways. Integers or dates must parse, it may
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,15 @@ public boolean isEditable() {
return settings.isEditable(declaration.getId());
}

@Override
public boolean isFilterable() {
InputType inputType = getInputType();
if (InputType.MULTIPLE_SELECTION.equals(inputType) || InputType.ONE_LINE_SINGLE_SELECTION.equals(inputType)) {
return settings.isFilterable(declaration.getId());
}
return false;
}

/**
* Checks if a URI is in the configured namespace, if one has been
* specified. Typically, a namespace is used as a URL prefix. For namespaces
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,22 @@ boolean isEditable(String keyId) {
}
}

/**
* Whether the key is filterable.
*
* @param keyId
* key for which the query is
* @return whether the key is filterable
*/
boolean isFilterable(String keyId) {
if (currentSettings.containsKey(keyId)) {
return currentSettings.get(keyId).isFilterable();
} else {
return true;
}
}


/**
* Whether the key is excluded.
*
Expand Down Expand Up @@ -176,6 +192,7 @@ private List<Setting> merge(Collection<Setting> currentSettings, Collection<Sett
other.getAlwaysShowing() != null ? other.getAlwaysShowing() : current.getAlwaysShowing());
merged.setEditable(other.getEditable() != null ? other.getEditable() : current.getEditable());
merged.setExcluded(other.getExcluded() != null ? other.getExcluded() : current.getExcluded());
merged.setFilterable(other.getFilterable() != null ? other.getFilterable() : current.getFilterable());
merged.setMultiline(other.getMultiline() != null ? other.getMultiline() : current.getMultiline());
merged.setReimport(other.getReimport() != null ? other.getReimport() : current.getReimport());
merged.setSettings(merge(current.getSettings(), other.getSettings()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ public class Setting {
@XmlAttribute
private Boolean editable;

@XmlAttribute
private Boolean filterable;

/**
* This will hide a field, even if a value has been entered for this field.
* Normally, there are rules in the ruleset that say which fields are
Expand Down Expand Up @@ -121,6 +124,10 @@ public Boolean getExcluded() {
return excluded;
}

public Boolean getFilterable() {
return filterable;
}

/**
* Returns the key whose representation is influenced.
*
Expand Down Expand Up @@ -182,6 +189,10 @@ public boolean isEditable() {
return editable != null ? editable : true;
}

public boolean isFilterable() {
return filterable != null ? filterable : false;
}

/**
* Returns the “excluded” value or otherwise the default value if the
* attribute is not set.
Expand Down Expand Up @@ -224,6 +235,11 @@ public void setEditable(Boolean editable) {
this.editable = editable;
}


public void setFilterable(Boolean filterable) {
this.filterable = filterable;
}

/**
* This sets the “excluded” value. If you set the value to {@code null}, no
* attribute is written.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,7 @@
package org.kitodo.production.forms.createprocess;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.*;
import java.util.Map.Entry;
import java.util.function.BiConsumer;

Expand Down Expand Up @@ -111,6 +106,10 @@ public String getInput() {
}
}

public boolean isFilterable() {
return Objects.isNull(settings) || settings.isFilterable();
}

/**
* Returns the select item objects required to display the list.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,10 @@ public boolean isEditable() {
return Objects.isNull(settings) || settings.isEditable();
}

public boolean isFilterable() {
return Objects.isNull(settings) || settings.isFilterable();
}

@Override
public boolean isUndefined() {
return Objects.isNull(settings) || settings.isUndefined();
Expand Down
14 changes: 14 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 @@ -2966,10 +2966,24 @@ Column content
}

#metadataAccordion\:metadata\:metadataTable_data .ui-inputfield.ui-selectmanymenu.read-only,
#metadataAccordion\:metadata\:metadataTable_data .ui-selectlistbox-filter-container .ui-selectlistbox-filter,
#metadataAccordion\:metadata\:metadataTable_data .ui-selectoneradio.read-only {
max-width: unset;
}

#metadataAccordion\:metadata\:metadataTable_data .ui-selectlistbox-filter-container .ui-icon-search {
top: 8px;
right: 6px;
text-indent: unset;
background: none;
}

#metadataAccordion\:metadata\:metadataTable_data .ui-selectlistbox-filter-container .ui-icon-search::after {
font-family: FontAwesome;
content: "\f002";
text-indent: unset;
}

#metadataAccordion\:metadata\:metadataTable_data .ui-selectoneradio {
display: inline-table;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,8 @@
styleClass="#{not item.editable or readOnly ? 'read-only disabled' : ''}"
disabled="#{not item.editable or readOnly}"
required="#{item.required and (not empty param['editForm:save'] or not empty param['editForm:saveContinue'])}"
showCheckbox="true">
showCheckbox="true"
filter="#{item.filterable}">
<f:selectItems value="#{item.items}"/>
<p:ajax event="change"
oncomplete="preserveMetadata(); #{item.leading ? (request.requestURI.contains('metadataEditor') ? 'updateTitleMetadataWithTable();' : 'updateProcessMetadata();') : (request.requestURI.contains('metadataEditor') ? 'updateTitleMetadata();' : '')}"/>
Expand All @@ -139,7 +140,8 @@
autoWidth="false"
disabled="#{not item.editable or readOnly}"
required="#{item.required and (not empty param['editForm:save'] or not empty param['editForm:saveContinue'])}"
styleClass="#{readOnly ? 'read-only' : ''}">
styleClass="#{readOnly ? 'read-only' : ''}"
filter="#{item.filterable}">
<f:selectItem itemValue="#{null}"
itemDisabled="#{item.required}"
itemLabel="#{msgs.notSelected}"
Expand Down

0 comments on commit 77d8725

Please sign in to comment.