Skip to content

Commit

Permalink
search visible fields
Browse files Browse the repository at this point in the history
  • Loading branch information
rsehr committed Dec 14, 2020
1 parent a0199e8 commit 531bb98
Show file tree
Hide file tree
Showing 2 changed files with 61 additions and 32 deletions.
33 changes: 28 additions & 5 deletions Goobi/src/org/goobi/vocabulary/Vocabulary.java
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@

import javax.xml.bind.annotation.XmlRootElement;

import org.apache.commons.lang.StringUtils;
import org.goobi.beans.DatabaseObject;

import com.fasterxml.jackson.annotation.JsonIgnore;
Expand Down Expand Up @@ -40,10 +41,14 @@ public void lazyLoad() {
}

@JsonIgnore
@Deprecated
private String mainFieldName;

@JsonIgnore
@Deprecated
private String searchField;
@JsonIgnore
@Deprecated
private String order; // blank, ASC, DESC
@JsonIgnore
private int totalNumberOfRecords;
Expand All @@ -61,6 +66,9 @@ public void lazyLoad() {
@JsonIgnore
private Integer internalSortField;

@JsonIgnore
private String searchValue;

public int getLastPageNumber() {
int ret = Double.valueOf(Math.floor(this.records.size() / numberOfRecordsPerPage)).intValue();
if (this.records.size() % numberOfRecordsPerPage == 0) {
Expand Down Expand Up @@ -100,10 +108,27 @@ public int getSizeOfList() {
public List<VocabRecord> getPaginatorList() {
List<VocabRecord> subList = new ArrayList<>();

if (records.size() > (pageNo * numberOfRecordsPerPage) + numberOfRecordsPerPage) {
subList = records.subList(pageNo * numberOfRecordsPerPage, (pageNo * numberOfRecordsPerPage) + numberOfRecordsPerPage);
List<VocabRecord> searchList = new ArrayList<>();

if (StringUtils.isNotBlank(searchValue)) {
for (VocabRecord rec : records) {
for (Field f : rec.getMainFields()) {
if (StringUtils.isNotBlank(f.getValue())) {
if (f.getValue().toLowerCase().contains(searchValue.toLowerCase())) {
searchList.add(rec);
break;
}
}
}
}
} else {
searchList = records;
}

if (searchList.size() > (pageNo * numberOfRecordsPerPage) + numberOfRecordsPerPage) {
subList = searchList.subList(pageNo * numberOfRecordsPerPage, (pageNo * numberOfRecordsPerPage) + numberOfRecordsPerPage);
} else {
subList = records.subList(pageNo * numberOfRecordsPerPage, records.size());
subList = searchList.subList(pageNo * numberOfRecordsPerPage, searchList.size());
}

return subList;
Expand Down Expand Up @@ -200,7 +225,6 @@ public void changeOrder() {
} else {
Collections.sort(records, Collections.reverseOrder(recordComparator));
}

}

private Comparator<VocabRecord> recordComparator = new Comparator<VocabRecord>() {
Expand All @@ -226,5 +250,4 @@ public int compare(VocabRecord o1, VocabRecord o2) {
return value1.compareTo(value2);
}
};

}
60 changes: 33 additions & 27 deletions Goobi/webapp/uii/vocabulary_records.xhtml
Original file line number Diff line number Diff line change
Expand Up @@ -97,32 +97,38 @@
<h:panelGroup
id="recordList"
layout="block"
styleClass="col-sm-3 vocabulary-left-column">
<!-- <x:dataList -->
<!-- var="record" -->
<!-- value="#{vocabularyBean.currentVocabulary.paginatorList}" -->
<!-- varStatus="status"> -->
<!-- <h:commandLink -->
<!-- id="switch" -->
<!-- styleClass="font-black font-size-s vocabulary-left-column-entry #{status.last?'margin-bottom-regular':''}" -->
<!-- title="#{record.id}" -->
<!-- action="#{vocabularyBean.Reload}"> -->
<!-- <i class="btn fa #{vocabularyBean.currentVocabRecord != record?'fa-circle-thin':'fa-check-circle'} margin-right-5 #{record.valid ? '' : 'font-danger'}" /> -->
<!-- <h:outputText -->
<!-- value="#{record.title}" -->
<!-- styleClass="#{vocabularyBean.currentVocabRecord == record?'font-bold':''} #{record.valid ? '' : 'font-danger'}" /> -->
<!-- <f:setPropertyActionListener -->
<!-- value="#{record}" -->
<!-- target="#{vocabularyBean.currentVocabRecord}" /> -->
<!-- <f:ajax -->
<!-- execute="@this" -->
<!-- render="@form" /> -->
<!-- <f:passThroughAttribute -->
<!-- name="aria-label" -->
<!-- value="#{record.title}" /> -->
<!-- </h:commandLink> -->
<!-- <br /> -->
<!-- </x:dataList> -->
styleClass="col-sm-4 vocabulary-left-column">
<div class="dataTables_filter">
<div class="input-group input-group">
<span class="input-group-addon">
<i class="fa fa-search"></i>
</span>
<h:inputText
id="searchField"
pt:aria-label="search"
styleClass="form-control searchfield"
value="#{vocabularyBean.currentVocabulary.searchValue}">
<f:passThroughAttribute
name="placeholder"
value="#{msgs.search}" />
</h:inputText>
<div class="input-group-btn">
<x:commandLink
id="FilterAlle2"
forceId="true"
value="#{msgs.search}"
styleClass="btn"
action="#{vocabularyBean.Reload}" />
</div>
</div>
<x:commandButton
type="submit"
id="FilterAlle"
forceId="true"
style="display: none;"
action="#{vocabularyBean.Reload}" />
</div>
<br />

<table class="table table-hover table-nomargin dataTable table-bordered responsive">
<thead>
Expand Down Expand Up @@ -220,7 +226,7 @@



<div class="col-sm-9 vocabulary-right-column">
<div class="col-sm-8 vocabulary-right-column">
<div class="form-group vocabulary-right-column-formfield">
<h:outputLabel
for="recordid"
Expand Down

0 comments on commit 531bb98

Please sign in to comment.