Commit 33e8a08b authored by Matija Obreza's avatar Matija Obreza

Show selected filters in Overview

parent 2e227d8b
......@@ -445,6 +445,14 @@ public class ExplorerController extends BaseController {
public String overview(ModelMap model, @RequestParam(value = "filter", required = false, defaultValue = "{}") String jsonFilter) throws IOException, SearchException {
AppliedFilters appliedFilters = mapper.readValue(jsonFilter, AppliedFilters.class);
String[] selectedFilters = appliedFilters.getFilterNames();
final List<GenesysFilter> currentFilters = filterHandler.selectFilters(selectedFilters);
model.addAttribute("currentFilters", currentFilters);
// JSP works with JsonObject
final Map<String, List<String>> filters = mapper.readValue(appliedFilters.toString(), Map.class);
model.addAttribute("filters", filters);
// Composition overview
overviewInstitutes(model, appliedFilters);
......
......@@ -19,9 +19,72 @@
</div>
</div>
<c:if test="${fn:length(currentFilters) gt 0}">
<div id="allfilters" class="disabled applied-filters">
<%-- Only render currently present filters --%>
<c:forEach items="${currentFilters}" var="filter">
<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}"/>
<div class="clearfix filter-block" id="<c:out value="${normalizedKey}" />_filter" norm-key="<c:out value="${normalizedKey}" />" i-key="<c:out value="${filter.key}" />">
<div class="col-lg-3 edit-fil">
<c:if test="${not filter.core}">
<c:out value="${filter.title}" />
<%-- <a href="<c:url value="/descriptors/${filter.key}" />"> --%>
</c:if>
<c:if test="${filter.core}">
<spring:message code="filter.${filter.key}" />
</c:if>
</div>
<div class="col-lg-9">
<div class="filter-values" id="<c:out value="${normalizedKey}" />_value">
<c:forEach items="${filters[filter.key]}" var="value">
<c:set var="string" value="${value}"/>
<c:if test="${fn:contains(value, 'range')}">
<c:set var="string" value="${fn:replace(value,'{range=[','Between ')}"/>
<c:set var="string" value="${fn:replace(string,',',' and ')}"/>
<c:set var="string" value="${fn:replace(string,']}','')}"/>
<c:set var="value" value="${fn:replace(value,'{','{\"')}"/>
<c:set var="value" value="${fn:replace(value,'=','\":')}"/>
</c:if>
<c:if test="${fn:contains(value, 'min')}">
<c:set var="string" value="${fn:replace(value,'{min=','More than ')}"/>
<c:set var="string" value="${fn:replace(string,'}','')}"/>
<c:set var="value" value="${fn:replace(value,'{','{\"')}"/>
<c:set var="value" value="${fn:replace(value,'=','\":')}"/>
</c:if>
<c:if test="${fn:contains(value, 'max')}">
<c:set var="string" value="${fn:replace(value,'{max=','Less than ')}"/>
<c:set var="string" value="${fn:replace(string,'}','')}"/>
<c:set var="value" value="${fn:replace(value,'{','{\"')}"/>
<c:set var="value" value="${fn:replace(value,'=','\":')}"/>
</c:if>
<c:if test="${fn:contains(value, 'like')}">
<c:set var="string" value="${fn:replace(value,'{like=','Like ')}"/>
<c:set var="string" value="${fn:replace(string,'}','')}"/>
<c:set var="value" value="${fn:replace(value,'{','{\"')}"/>
<c:set var="value" value="${fn:replace(value,'=','\":\"')}"/>
<c:set var="value" value="${fn:replace(value,'}','\"}')}"/>
</c:if>
<c:if test="${string==null}">
<c:set var="string" value="null" />
<c:set var="value" value="null" />
</c:if>
<div class="filtval complex" x-key="<c:out value="${normalizedKey}" /><c:out value="${value}"/>" i-key="<c:out value="${filter.key}" />"><c:out value="${string}" /></div>
<c:remove var="string" />
</c:forEach>
</div>
</div>
</div>
</c:forEach>
</div>
</c:if>
<h3><spring:message code="data-overview.institutes" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-instcode"><spring:message code="filter.institute.code" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsInstCode}" />
......@@ -29,7 +92,7 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-instcty"><spring:message code="filter.institute.country.iso3" /></h4>
<c:set var="type" value="country" />
<c:set var="termResult" value="${statsInstCountry}" />
......@@ -40,8 +103,8 @@
</div>
<h3><spring:message code="data-overview.composition" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-crops"><spring:message code="filter.crops" /></h4>
<c:set var="type" value="crop" />
<c:set var="termResult" value="${statsCrops}" />
......@@ -49,7 +112,7 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-sampstat"><spring:message code="filter.sampStat" /></h4>
<c:set var="type" value="i18n.accession.sampleStatus" />
<c:set var="termResult" value="${statsSampStat}" />
......@@ -58,14 +121,14 @@
<c:remove var="type" />
</div>
</div>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-genus"><spring:message code="filter.taxonomy.genus" /></h4>
<c:set var="termResult" value="${statsGenus}" />
<%@include file="termresult.jspf"%>
<c:remove var="termResult" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-species"><spring:message code="filter.taxonomy.species" /></h4>
<c:set var="termResult" value="${statsSpecies}" />
<%@include file="termresult.jspf"%>
......@@ -74,8 +137,8 @@
</div>
<h3><spring:message code="data-overview.sources" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-orgcty"><spring:message code="filter.orgCty.iso3" /></h4>
<c:set var="type" value="country" />
<c:set var="termResult" value="${statsOrgCty}" />
......@@ -83,7 +146,7 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-donorcode"><spring:message code="filter.donorCode" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsDonorCode}" />
......@@ -94,8 +157,8 @@
</div>
<h3><spring:message code="data-overview.availability" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-sampstat"><spring:message code="filter.mlsStatus" /></h4>
<c:set var="type" value="bool" />
<c:set var="termResult" value="${statsMLS}" />
......@@ -103,7 +166,7 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-available"><spring:message code="filter.available" /></h4>
<c:set var="type" value="bool" />
<c:set var="termResult" value="${statsAvailable}" />
......@@ -114,8 +177,8 @@
</div>
<h3><spring:message code="data-overview.management" /></h3>
<div class="row row-section">
<div class="col-xs-12 col-sm-6">
<div class="row">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-storage"><spring:message code="filter.storage" /></h4>
<c:set var="type" value="i18n.accession.storage" />
<c:set var="termResult" value="${statsStorage}" />
......@@ -123,7 +186,7 @@
<c:remove var="termResult" />
<c:remove var="type" />
</div>
<div class="col-xs-12 col-sm-6">
<div class="col-xs-12 col-sm-6 row-section">
<h4 id="stats-duplsite"><spring:message code="filter.duplSite" /></h4>
<c:set var="type" value="instCode" />
<c:set var="termResult" value="${statsDuplSite}" />
......
......@@ -4,7 +4,7 @@
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
<table class="accession">
<table class="terms-table">
<c:forEach items="${termResult.terms}" var="term">
<tr><td>
<c:choose>
......
......@@ -1174,6 +1174,24 @@ html[dir="rtl"] #stats .stat-lists ol li img {
margin: 2px 5px;
}
#allfilters.disabled .filter-block {
padding:2px 5px;
}
#allfilters.disabled .filter-block .filtval {
background-image:none;
padding:2px 5px;
}
#allfilters .edit-fil {
padding: 7px 0px;
}
#allfilters.disabled .edit-fil {
cursor: default;
padding:4px 5px;
}
.filtval:hover {
background-color:#ccc7af;
text-decoration:none;
......@@ -1984,3 +2002,7 @@ html[dir="rtl"] .text-left {
.row-section {
margin-bottom: 2em;
}
table.terms-table td {
padding: 4px 10px;
}
\ No newline at end of file
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