filter.tag 8.4 KB
Newer Older
Matija Obreza's avatar
Matija Obreza committed
1
2
3
4
5
6
<%@ tag description="Display filter" pageEncoding="UTF-8"%>
<%@ tag body-content="empty"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags"%>
7
<%@ taglib prefix="filters" tagdir="/WEB-INF/tags/filters"%>
Matija Obreza's avatar
Matija Obreza committed
8
9
10
11
12
13
14
<%@ attribute name="availableFilters" required="true" type="java.util.Map"%>
<%@ attribute name="filterMap" required="true" type="java.util.Map"%>
<%@ attribute name="filterKey" required="true" type="java.lang.String"%>
<%@ attribute name="appliedFilters" required="true" type="org.genesys2.server.service.impl.FilterHandler.AppliedFilters"%>
<%@ attribute name="type" required="true" type="java.lang.String"%>
<%@ attribute name="cropList" required="false" type="java.util.Map"%>
<%@ attribute name="currentCrop" required="false" type="org.genesys2.server.model.impl.Crop"%>
15

Taisiya Glushko's avatar
Taisiya Glushko committed
16
17
18
19
20
21
22
23
24
<spring:message code="filter.internal.message.between" var="between" arguments=" "/>
<spring:message code="filter.internal.message.and" var="varEnd" arguments=" "/>
<spring:message code="filter.internal.message.more" var="moreThan" arguments=" "/>
<spring:message code="filter.internal.message.less" var="lessThan" arguments=" "/>
<spring:message code="filter.internal.message.like" var="like" arguments=" "/>
<spring:message code="boolean.true" var="varTrue"/>
<spring:message code="boolean.false" var="varFalse"/>
<spring:message code="boolean.null" var="varNull"/>

Matija Obreza's avatar
Matija Obreza committed
25
26
27
<c:set var="filter" value="${availableFilters[filterKey]}" />
<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
28

Matija Obreza's avatar
Matija Obreza committed
29
<div id="collapse_filt_${filterKey}" class="${filterKey}">
30

Matija Obreza's avatar
Matija Obreza committed
31
32
33
34
<c:choose>
	<c:when test="${type eq 'select'}">
		<!-- <select name="crops" i-key="crops" class="form-control filter-crop"> -->
	<!-- 		<option disabled selected>Select crop</option> -->
Aleksandr Sharaban's avatar
Aleksandr Sharaban committed
35
			<c:forEach items="${cropList}" var="c" varStatus="i">
Matija Obreza's avatar
Matija Obreza committed
36
				<c:forEach items="${c.value}" var="val">
37
38
39
40
41
42
					<div class="radio-wrapper">
						<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>
					<div/>
Matija Obreza's avatar
Matija Obreza committed
43
44
45
46
47
				</c:forEach>
			</c:forEach>
		<!-- </select> -->
	</c:when>
	<c:when test="${type eq 'like'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
48
		<span class="glyphicon glyphicon-menu-down"></span>
Matija Obreza's avatar
Matija Obreza committed
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
		<select class="form-control like-switcher">
			<option value="like"><spring:message code="filter.string.like" /></option>
			<option value="equals"><spring:message code="filter.string.equals" /></option>
		</select>
		<div class="input-group">
			<input type="text" class="span2 form-control string-type" id="<c:out value="${normalizedKey}" />_input">
			<span class="input-group-btn">
				<button class="btn btn-secondary notimportant filter-auto" type="button" norm-key="<c:out value="${normalizedKey}" />" i-key="<c:out value="${filter.key}" />">
					<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
				</button>
			</span>
		</div>
	</c:when>
	<c:when test="${type eq 'option'}">
		<c:forEach items="${filter.options}" var="option" varStatus="i">
Taisiya Glushko's avatar
Taisiya Glushko committed
64
			<div class="checkbox-wrapper">
Matija Obreza's avatar
Matija Obreza committed
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
				<label>
					<input class="filter-list" id="<c:out value="${normalizedKey}${option.value}" />_input" ${fn:contains(filterMap[appliedFilter.key], option.value)?'checked':''}
						norm-key="<c:out value="${normalizedKey}" />" i-key="<c:out value="${filter.key}" />" type="checkbox" value="${option.value}" />
					<spring:message code="${option.name}" />
					(${filter.counts[i.index]})
				</label>
			</div>
		</c:forEach>
	</c:when>
	<c:when test="${type eq 'autocomplete'}">
		<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" />
			<span class="input-group-btn">
				<button class="btn btn-secondary notimportant filter-auto" type="button" norm-key="<c:out value="${normalizedKey}" />" i-key="<c:out value="${filter.key}" />">
					<span class="glyphicon glyphicon-plus" aria-hidden="true"></span>
				</button>
			</span>
		</div>
	</c:when>
	<c:when test="${type eq 'range'}">
		<c:choose>
			<c:when test="${filterKey eq 'geo.latitude'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
88
				<filters:filter-range-child filter="${availableFilters['geo.latitude']}" appliedFilters="${appliedFilters}" filterMap="${filterMap}" />
89

Taisiya Glushko's avatar
Taisiya Glushko committed
90
91
				<p class="label-name"><spring:message code="filter.geo.longitude" /></p>
                            <filters:filter-range-child filter="${availableFilters['geo.longitude']}" appliedFilters="${appliedFilters}" filterMap="${filterMap}" />
92

Taisiya Glushko's avatar
Taisiya Glushko committed
93
94
				<p class="label-name"><spring:message code="filter.geo.elevation" /></p>
                            <filters:filter-range-child filter="${availableFilters['geo.elevation']}" appliedFilters="${appliedFilters}" filterMap="${filterMap}" />
Matija Obreza's avatar
Matija Obreza committed
95
96
			</c:when>
			<c:otherwise>
Taisiya Glushko's avatar
Taisiya Glushko committed
97
				<filters:filter-range-child filter="${availableFilters[filterKey]}" appliedFilters="${appliedFilters}" filterMap="${filterMap}" />
Matija Obreza's avatar
Matija Obreza committed
98
99
100
101
			</c:otherwise>
		</c:choose>
	</c:when>
	<c:when test="${type eq 'boolean'}">
Taisiya Glushko's avatar
Taisiya Glushko committed
102
		<div class="checkbox-wrapper">
Matija Obreza's avatar
Matija Obreza committed
103
104
105
106
107
108
			<label>
				<input type="checkbox" ${fn:contains(filterMap[appliedFilter.key], 'true')?'checked':''} class="filter-bool" i-key="<c:out value="${filter.key}" />" id="<c:out value="${normalizedKey}" />"
					value="true">
				<spring:message code="boolean.true" />
			</label>
		</div>
Taisiya Glushko's avatar
Taisiya Glushko committed
109
		<div class="checkbox-wrapper">
Matija Obreza's avatar
Matija Obreza committed
110
111
112
113
114
115
116
			<label>
				<input type="checkbox" ${fn:contains(filterMap[appliedFilter.key], 'false')?'checked':''} class="filter-bool" i-key="<c:out value="${filter.key}" />" id="<c:out value="${normalizedKey}" />"
					value="false">
				<spring:message code="boolean.false" />
			</label>
		</div>
		<c:if test="${filter.allowsNull}">
Taisiya Glushko's avatar
Taisiya Glushko committed
117
			<div class="checkbox-wrapper">
Matija Obreza's avatar
Matija Obreza committed
118
119
120
121
122
123
124
125
126
127
				<label>
					<input type="checkbox" ${fn:contains(filterMap[appliedFilter.key], 'null')?'checked':''} class="filter-bool" i-key="<c:out value="${filter.key}" />" id="<c:out value="${normalizedKey}" />"
						value="null">
					<spring:message code="boolean.null" />
				</label>
			</div>
		</c:if>
	</c:when>
	<c:otherwise />
</c:choose>
128

Matija Obreza's avatar
Matija Obreza committed
129
130
131
132
133
<c:if test="${type ne 'range'}">
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
</c:if>
134

Matija Obreza's avatar
Matija Obreza committed
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
<c:if test="${filterKey eq 'taxonomy.genus'}">
	<c:set var="filter" value="${availableFilters['taxonomy.species']}" />
	<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
	<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
	<c:set var="filter" value="${availableFilters['taxonomy.subtaxa']}" />
	<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
	<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
	<c:set var="filter" value="${availableFilters['taxonomy.sciName']}" />
	<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
	<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
	<c:set var="filter" value="${availableFilters['orgCty.iso3']}" />
	<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
	<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
	<c:set var="filter" value="${availableFilters['institute.country.iso3']}" />
	<c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}" />
	<c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}" />
	<c:forEach items="${filterMap[appliedFilter.key]}" var="value">
		<%@include file="filtval.jspf"%>
	</c:forEach>
</c:if>
167

Matija Obreza's avatar
Matija Obreza committed
168
169
170
171
<button type="button" class="btn btn-success applyBtn">
	<spring:message code="filter.apply" />
</button>
</div>