Commit 0fa9c482 authored by Aleksandr Sharaban's avatar Aleksandr Sharaban

Filtering fixes.

parent acd8d6c7
......@@ -241,7 +241,9 @@ public class ExplorerController extends BaseController implements InitializingBe
model.addAttribute("availableColumns", validDisplayColumns);
model.addAttribute("selectedColumns", cleanupDisplayColumns(columns, cookieColumns, response));
model.addAttribute("crops", getCrops(appliedFilters));
tempFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
model.addAttribute("crops", getCrops(tempFilters));
model.addAttribute("pagedData", accessions);
model.addAttribute("appliedFilters", appliedFilters);
model.addAttribute("currentFilters", currentFilters);
......@@ -324,6 +326,7 @@ public class ExplorerController extends BaseController implements InitializingBe
private Map<String, Map<String, Integer>> getCrops(AppliedFilters appliedFilters) throws SearchException {
Map<String, Map<String, Integer>> crops = new HashMap<>();
appliedFilters.removeIf(appliedFilter -> appliedFilter.getKey().equals(FilterConstants.CROPS));
for (Term term: elasticService.termStatisticsAuto(appliedFilters, FilterConstants.CROPS, 30).getTerms()) {
String cropShortName = term.getTerm();
Crop crop = cropService.getCrop(cropShortName);
......@@ -350,10 +353,17 @@ public class ExplorerController extends BaseController implements InitializingBe
return "/accession/i18n";
}
@RequestMapping(value = "/explore/getCrops", method = RequestMethod.GET, produces = "text/plain;charset=UTF-8")
@RequestMapping(value = "/explore/getCrops", method = RequestMethod.GET, produces = MediaType.APPLICATION_JSON_VALUE)
@ResponseBody
public List<Crop> getCrops(@RequestParam List<String> cropNames) {
return cropService.getCrops(cropNames);
public Map<String, String> getCrops() {
Map<String, String> crops = new HashMap<>();
List<Crop> cropList = cropService.list(getLocale());
for (Crop crop: cropList) {
crops.put(crop.getShortName(), crop.getName(getLocale()));
}
return crops;
}
/**
......
......@@ -23,12 +23,13 @@
<c:when test="${type eq 'select'}">
<!-- <select name="crops" i-key="crops" class="form-control filter-crop"> -->
<!-- <option disabled selected>Select crop</option> -->
<c:forEach items="${cropList}" var="c">
<c:forEach items="${cropList}" var="c" varStatus="i">
<c:forEach items="${c.value}" var="val">
<input type="radio" name="crops" i-key="crops" class="filter-crop" value="${c.key}" ${c.key == currentCrop.shortName? 'selected' : ''} />
<label>
<input type="radio" name="crops" id="crops_${i.count}" i-key="crops" class="filter-crop" value="${c.key}" ${c.key == currentCrop.shortName? 'checked' : ''} />
<label for="crops_${i.count}">
<c:out value="${val.key}" /> (${val.value})
</label>
<br/>
</c:forEach>
</c:forEach>
<!-- </select> -->
......@@ -60,17 +61,6 @@
</c:forEach>
</c:when>
<c:when test="${type eq 'autocomplete'}">
<c:if test="${filterKey eq 'taxonomy.genus'}">
<select class="form-control" id="more-filters">
<option disabled selected>Select category</option>
<option value="taxonomy.genus"><spring:message code="filter.taxonomy.genus" /></option>
<option value="taxonomy.species"><spring:message code="filter.taxonomy.species" /></option>
<option value="taxonomy.subtaxa"><spring:message code="filter.taxonomy.subtaxa" /></option>
<option value="taxonomy.sciName"><spring:message code="filter.taxonomy.sciName" /></option>
<option value="orgCty.iso3"><spring:message code="filter.orgCty.iso3" /></option>
<option value="institute.country.iso3"><spring:message code="filter.institute.country.iso3" /></option>
</select>
</c:if>
<div class="input-group">
<input id="<c:out value="${normalizedKey}" />_input" class="span2 form-control autocomplete-filter string-type" x-source="<c:url value="${filter.autocompleteUrl}" />"
placeholder="<spring:message code="filter.autocomplete-placeholder" />" type="text" />
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment