explore.jsp 36.6 KB
Newer Older
igoshin's avatar
igoshin committed
1
2
<!DOCTYPE html>

3
<%@include file="/WEB-INF/jsp/init.jsp" %>
4
5
6
7
8
9
10
11
<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"/>
igoshin's avatar
igoshin committed
12
13
14

<html>
<head>
15
    <title><spring:message code="accession.page.data.title"/></title>
igoshin's avatar
igoshin committed
16
17
</head>
<body>
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<cms:informative-h1 title="accession.page.data.title" fancy="${pagedData.number eq 0}"
                    info="accession.page.data.intro"/>

<%--Dropdown filters--%>
<div class="main-col-header clearfix">

    <div class="nav-header">
        <div class="results">
            <spring:message code="accessions.number" arguments="${pagedData.totalElements}"/>
        </div>
        <div class="row">
            <div class="col-md-12 col-lg-5">
                <form method="get" action="">
                    <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>

                    <div class="pagination">
                        <spring:message code="paged.pageOfPages"
                                        arguments="${pagedData.number+1},${pagedData.totalPages}"/>
                        <a href="<spring:url value=""><spring:param name="page" value="${pagedData.number eq 0 ? 1 : pagedData.number}" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>"><spring:message
                                code="pagination.previous-page"/></a>
                        <input class="form-control" style="display: inline; max-width: 5em; text-align: center"
                               type="text" name="page" placeholder="${pagedData.number + 1}"/>
                        <a href="<spring:url value=""><spring:param name="page" value="${pagedData.number+2}" /><spring:param name="filter" value="${jsonFilter}" /></spring:url>"><spring:message
                                code="pagination.next-page"/></a>
                    </div>
                </form>
            </div>
            <div class="col-md-12 col-lg-7 text-right" style="padding-top: 12px">
                <div class="btn-group">
                    <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                            aria-haspopup="true" aria-expanded="false" id="menuShareLink">
                        <span class="glyphicon glyphicon-share"></span><span><spring:message code="share.link"/></span>
                        <span class="caret"></span>
                    </button>
                    <ul class="dropdown-menu">
                        <li class="padding10">
                            <p><spring:message code="share.link.text"/></p>
                            <input id="shortLink" type="text"
                                   placeholder="<spring:message code="share.link.placeholder" />" value=""/>
                        </li>
                    </ul>
igoshin's avatar
igoshin committed
59
                </div>
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
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
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254

                <c:if test="${pagedData.totalElements le 200000}">
                    <div class="btn-group">
                        <button type="button" class="btn btn-default dropdown-toggle" data-toggle="dropdown"
                                aria-haspopup="true" aria-expanded="false">
                            <span class="glyphicon glyphicon-download"></span><span><spring:message
                                code="download"/></span> <span class="caret"></span>
                        </button>
                        <ul class="dropdown-menu">
                            <security:authorize access="isAuthenticated()">
                                <li>
                                    <form style="display: inline-block" method="post"
                                          action="<c:url value="/download/explore/download/mcpd" />">
                                        <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                                        <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>
                                        <button class="btn btn-inline" type="submit"><span><spring:message
                                                code="filter.download-mcpd"/></span></button>
                                    </form>
                                </li>
                            </security:authorize>
                            <li>
                                <form style="display: inline-block" method="post"
                                      action="<c:url value="/download/explore/dwca" />">
                                    <input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
                                    <input type="hidden" name="filter" value="<c:out value="${jsonFilter}" />"/>
                                    <button class="btn btn-inline" type="submit"><span><spring:message
                                            code="filter.download-dwca"/></span></button>
                                </form>
                            </li>
                        </ul>
                    </div>
                </c:if>
                <a class="btn btn-default"
                   href="<c:url value="/explore/overview"><c:param name="filter">${jsonFilter}</c:param></c:url>"><span
                        class="glyphicon glyphicon-eye-open"></span><span><spring:message
                        code="data-overview.short"/></span></a>
                <a class="btn btn-default"
                   href="<c:url value="/explore/map"><c:param name="filter">${jsonFilter}</c:param></c:url>"><span
                        class="glyphicon glyphicon-globe"></span><span><spring:message code="maps.view-map"/></span></a>
            </div>
        </div>
    </div>
</div>

<%--Filters--%>
<div id="toggleFilters" class="applied-filters  ${pagedData.number eq 0 ? 'hide' : ''}">
    <ul class="nav nav-pills">
        <li class="active filter-toggler"><a><spring:message code="filters.toggle-filters"/></a></li>
        <li class="message">
            <span class="${fn:length(currentFilters) gt 0 ? '' : 'hide'}"><spring:message
                    code="filter.filters-applied"/></span>
            <span class="${fn:length(currentFilters) gt 0 ? 'hide' : ''}"><spring:message
                    code="filter.filters-not-applied"/></span>
        </li>
    </ul>
</div>
<div id="allfilters" class="applied-filters ${pagedData.number gt 0 ? 'hide' : ''}">
    <ul class="nav nav-pills">
        <li class="filter-toggler"><a><spring:message code="filters.toggle-filters"/></a></li>
        <li class="active dropdown form-horizontal" id="menu1">

            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <spring:message code="filter.add"/>
                <b class="glyphicon-plus"></b>
            </a>

            <ul class="dropdown-menu">
                <c:forEach items="${availableFilters}" var="filter">
                    <li><a href="#" i-key="${filter.key}" class="filter-enable">
                        <spring:message code="filter.${filter.key}"/></a></li>
                </c:forEach>
            </ul>

        </li>
        <li class="active dropdown form-horizontal" id="selectColumns">

            <a class="dropdown-toggle" data-toggle="dropdown" href="#">
                <b class="glyphicon-th-list"></b>
                <spring:message code="columns.add"/>
            </a>

            <ul class="dropdown-menu" style="min-width: 232px">
                <li style="  margin-left: 10px;">
                    <label>
                        <a id="columnsApplay" type="submit" class="btn btn-default"><spring:message code="columns.applay"/></a>
                    </label>
                </li>
                <c:forEach items="${defaultColumns}" var="defaultColumn">
                    <li style="  margin-left: 10px;">
                        <label class="column-enable">
                            <c:choose>
                                <c:when test="${selectedColumns.contains(defaultColumn)}">
                                    <input type="checkbox" checked="checked"  name="${defaultColumn}"/>
                                </c:when>
                                <c:otherwise>
                                    <input type="checkbox" name="${defaultColumn}"/>
                                </c:otherwise>
                            </c:choose>
                            <spring:message code="columns.${defaultColumn}"/>
                        </label>
                    </li>
                </c:forEach>
                <span>-</span>
                <c:forEach items="${availableColumns}" var="columnName">
                    <li style="  margin-left: 10px;">
                        <label class="column-enable">
                            <c:choose>
                                <c:when test="${selectedColumns.contains(columnName)}">
                                    <input type="checkbox" checked="checked" name="${columnName}"/>
                                </c:when>
                                <c:otherwise>
                                    <input type="checkbox" name="${columnName}"/>
                                </c:otherwise>
                            </c:choose>
                            <spring:message code="columns.${columnName}"/>
                        </label>
                    </li>
                </c:forEach>
            </ul>

        </li>


        <li class="dropdown form-horizontal" id="menu2" style="display: none">
            <a class="" data-toggle="modal" data-target="#myModal">
                <spring:message code="filter.additional"/>
                <b class="glyphicon-plus"></b>
            </a>
        </li>
        <li class="message">
            <span class="${fn:length(currentFilters) gt 0 ? '' : 'hide'}"><spring:message
                    code="filter.filters-applied"/></span>
            <span class="${fn:length(currentFilters) gt 0 ? 'hide' : ''}"><spring:message
                    code="filter.filters-not-applied"/></span>
        </li>
    </ul>

    <%-- Only render currently present filters --%>
    <c:forEach items="${currentFilters}" var="filter">

        <c:set var="normalizedKey" value="${filter.key.replace('.', '-').replace(':', '_')}"/>
        <c:set var="appliedFilter" value="${appliedFilters.get(filter.key)}"/>
        <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-5 filter-new">
                <c:choose>
                    <c:when test="${filter.filterType=='LIST'}">
                        <div class="">
                            <c:forEach items="${filter.options}" var="option">
                                <div>
                                    <label>
                                        <input class="filter-list"
                                               id="<c:out value="${normalizedKey}${option.value}" />_input" ${fn:contains(filters[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}"/>
                                    </label>
                                </div>
                            </c:forEach>
                        </div>
                    </c:when>
                    <c:when test="${filter.filterType=='I18NLIST'}">
                        <div class="">
                            <c:forEach items="${filter.options}" var="option">
                                <div>
                                    <label>
                                        <input class="filter-list"
                                               id="<c:out value="${normalizedKey}${option.value}" />_input" ${fn:contains(filters[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}"/>
                                    </label>
                                </div>
                            </c:forEach>
                            <div><label><input
                                    type="checkbox" ${fn:contains(filters[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>
                        </div>
                    </c:when>
                    <c:when test="${filter.filterType=='AUTOCOMPLETE'}">
                        <div class="ui-front">
                            <div class="form-group input-group">
igoshin's avatar
igoshin committed
255
                                     <span class="input-group-btn">
256
257
258
259
260
261
262
263
264
                                         <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"/>
                                         <button class="btn notimportant filter-auto"
                                                 norm-key="<c:out value="${normalizedKey}" />"
                                                 i-key="<c:out value="${filter.key}" />">+
                                         </button>
igoshin's avatar
igoshin committed
265
266
                                      </span>
                            </div>
267
268
269
270
                        </div>
                    </c:when>
                    <c:when test="${filter.dataType=='NUMERIC'}">
                        <div class="form-group input-group">
igoshin's avatar
igoshin committed
271
                                <span class="input-group-btn">
272
273
274
275
276
277
278
279
                                    <input id="<c:out value="${normalizedKey}" />_input_1" class="span5 form-control"
                                           type="text"/>
                                    <input id="<c:out value="${normalizedKey}" />_input_2" class="span5 form-control"
                                           type="text"/>
                                    <button class="btn notimportant filter-range"
                                            norm-key="<c:out value="${normalizedKey}" />"
                                            i-key="<c:out value="${filter.key}" />">+
                                    </button>
igoshin's avatar
igoshin committed
280
                                </span>
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
                        </div>
                    </c:when>
                    <c:when test="${filter.dataType=='BOOLEAN'}">
                        <div class="">
                            <div><label><input
                                    type="checkbox" ${fn:contains(filters[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>
                            <div><label><input
                                    type="checkbox" ${fn:contains(filters[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}">
                                <div><label><input
                                        type="checkbox" ${fn:contains(filters[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>
                        </div>
                    </c:when>
                    <c:when test="${filter.key=='crops'}">
                        <div class="form-group input-group">
306
                                <span class="input-group-btn">
307
308
                                    <select name="crops" id="cropselector" i-key="${filter.key}"
                                            class="form-control filter-crop">
309
310
                                        <option value=""></option>
                                        <c:forEach items="${crops}" var="c">
311
312
                                            <option value="${c.shortName}" ${c.shortName== crop.shortName?'selected':''} >
                                                <c:out value="${c.getName(pageContext.response.locale)}"/></option>
313
314
315
                                        </c:forEach>
                                    </select>
                                </span>
316
317
318
319
                        </div>
                    </c:when>
                    <c:otherwise>
                        <div class="ui-front">
igoshin's avatar
igoshin committed
320
321
                            <div class="form-group input-group">
                                <span class="input-group-btn">
322
                                    <select id="like-switcher" class="form-control select-like">
323
324
                                        <option value="like"><spring:message code="filter.string.like"/></option>
                                        <option value="equals"><spring:message code="filter.string.equals"/></option>
325
                                    </select>
326
327
328
329
330
331
                                    <input class="span2 form-control string-type"
                                           id="<c:out value="${normalizedKey}" />_input" type="text"/>
                                    <button class="btn notimportant filter-auto"
                                            norm-key="<c:out value="${normalizedKey}" />"
                                            i-key="<c:out value="${filter.key}" />">+
                                    </button>
igoshin's avatar
igoshin committed
332
333
                                </span>
                            </div>
334
                        </div>
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
                    </c:otherwise>
                </c:choose>
            </div>
            <div class="col-lg-9">
                <div class="filter-values" id="<c:out value="${normalizedKey}" />_value">
                    <c:if test="${appliedFilter.inverse}">
                        <spring:message code="filter.inverse"/>
                    </c:if>
                    <c:forEach items="${filters[appliedFilter.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,',',varEnd)}"/>
                            <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=',moreThan)}"/>
                            <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=',lessThan)}"/>
                            <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="${fn:contains(value, 'true')}">
                            <c:set var="string" value="${fn:replace(value,'true', varTrue)}"/>
                        </c:if>
                        <c:if test="${fn:contains(value, 'false')}">
                            <c:set var="string" value="${fn:replace(value,'false', varFalse)}"/>
                        </c:if>
                        <c:if test="${string==null}">
                            <c:set var="string" value="${varNull}"/>
                            <c:set var="value" value="null"/>
                        </c:if>
                        <c:if test="${appliedFilter.key=='storage'}">
                            <spring:message code='accession.storage.${value}' var="string"/>
                        </c:if>
                        <c:if test="${appliedFilter.key=='sampStat'}">
                            <spring:message code='accession.sampleStatus.${value}' var="string"/>
                        </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>
igoshin's avatar
igoshin committed
391
                </div>
392
393
394
                <div style="margin-top: 3px" class="filter-apply-btn">
                    <button class="btn btn-primary apply"><spring:message code="filter.apply"/></button>
                    <button class="btn btn-default remove-filter"><spring:message code="filter.remove"/></button>
igoshin's avatar
igoshin committed
395
396
                </div>
            </div>
397
398
399
        </div>
    </c:forEach>
</div>
400
401


402
403
404
405
<!-- Modal -->
<div class="modal fade" id="myModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
    <div class="modal-dialog">
        <div class="modal-content"></div>
igoshin's avatar
igoshin committed
406
    </div>
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
</div>
<!--End modal-->
<%--Accessions--%>
<table class="accessions">
    <thead>
    <tr>
        <td class="idx-col"></td>
        <td/>
        <c:forEach items="${selectedColumns}" var="column">
            <c:choose>
                <c:when test="${column eq 'acceNumb' || column eq 'scientificName'}">
                    <td ><spring:message code="columns.${column}"/></td>
                </c:when>
                <c:when test="${column eq 'orgCty' || column eq 'sampStat' || column eq 'instCode'}">
                    <td class="notimportant"><spring:message code="columns.${column}"/></td>
                </c:when>
                <c:otherwise>
                    <td class="notimportant"><spring:message code="columns.${column}"/></td>
                </c:otherwise>
            </c:choose>
        </c:forEach>
        <%-- 				<td><spring:message code="accession.holdingCountry" /></td>
--%>
    </tr>
    </thead>
    <tbody>
    <c:forEach items="${pagedData.content}" var="accession" varStatus="status">
        <tr class="acn ${status.count % 2 == 0 ? 'even' : 'odd'} ${accession.historic ? 'historic-record' : ''}">
            <td class="idx-col">${status.count + pagedData.size * pagedData.number}</td>
            <td class="sel" x-aid="${accession.id}"></td>
            <%--<td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out--%>
                    <%--value="${accession.accessionName}"/></b></a></td>--%>
                <%-- <td><a href="<c:url value="/acn/t/${accession.taxonomy.genus}/${accession.taxonomy.species}" />"><c:out value="${accession.taxonomy.taxonName}" /></a></td> --%>
            <%--<td><span dir="ltr" class="sci-name"><c:out value="${accession.taxonomy.taxonName}"/></span></td>--%>
                <%-- <td class="notimportant"><a href="<c:url value="/geo/${accession.origin}" />"><c:out value="${accession.countryOfOrigin.name}" /></a></td> --%>
            <%--<td class="notimportant"><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}"/></td>--%>
            <%--<td class="notimportant"><spring:message code="accession.sampleStatus.${accession.sampleStatus}"/></td>--%>
            <%--<td class="notimportant"><a href="<c:url value="/wiews/${accession.institute.code}" />"><c:out--%>
                    <%--value="${accession.institute.code}"/></a></td>--%>
            <c:forEach items="${selectedColumns}" var="col">
                <c:choose>
                    <c:when test="${col eq 'acceNumb'}">
                        <td><a href="<c:url value="/acn/id/${accession.id}" />"><b><c:out value="${accession.accessionName}"/></b></a></td>
                    </c:when>
                    <c:when test="${col eq 'scientificName'}">
                        <td><span dir="ltr" class="sci-name"><c:out value="${accession.taxonomy.taxonName}"/></span></td>
                    </c:when>
                    <c:when test="${col eq 'orgCty'}">
                        <td class="notimportant"><c:out value="${accession.countryOfOrigin.getName(pageContext.response.locale)}"/></td>
                    </c:when>
                    <c:when test="${col eq 'sampStat'}">
                        <td class="notimportant"><spring:message code="accession.sampleStatus.${accession.sampleStatus}"/></td>
                    </c:when>
                    <c:when test="${col eq 'instCode'}">
                        <td class="notimportant"><a href="<c:url value="/wiews/${accession.institute.code}" />"><c:out
                                value="${accession.institute.code}"/></a></td>
                    </c:when>
                    <c:when test="${col eq 'genus'}">
                        <td class="notimportant"><c:out value="${accession.taxonomy.genus}"/></td>
                    </c:when>
                    <c:when test="${col eq 'species'}">
                        <td class="notimportant"><c:out value="${accession.taxonomy.species}"/></td>
                    </c:when>
                    <c:when test="${col eq 'subtaxa'}">
                        <td class="notimportant"><c:out value="${accession.taxonomy.subtaxa}"/></td>
                    </c:when>
                    <c:when test="${col eq 'cropName'}">
                        <c:if test="${fn:length(jspHelper.getCropsByAccession(accession)) == 0}">
                            <td class="notimportant"></td>
                        </c:if>
                        <c:forEach items="${jspHelper.getCropsByAccession(accession)}" var="crop">
                            <td class="notimportant"><a href="<c:url value="/c/${crop.shortName}" />"><c:out
                                    value="${crop.getName(pageContext.response.locale)}"
                                    /></a></td>
                        </c:forEach>
                        <%--<td class="notimportant"><c:out value="${accession.accessionId.pdci.cropName}"/></td>--%>
                    </c:when>
                    <c:when test="${col eq 'latitudeAndLongitude'}">
                        <td class="notimportant"><c:out value="${accession.institute.latitude}"/><c:out value=" ${accession.institute.longitude}"/></td>
                    </c:when>
                    <c:otherwise>
                        <td class="notimportant"></td>
                    </c:otherwise>
                </c:choose>
            </c:forEach>
                <%-- 			<td><a href="<c:url value="/geo/${accession.institute.country.code3}" />"><c:out value="${accession.institute.country.name}" /></a></td>
     --%>
        </tr>
    </c:forEach>
    </tbody>
</table>

<content tag="javascript">
    <script type="text/javascript">
        var jsonData = ${jsonFilter};

        var page =${pagedData.number};

        $(document).ready(function () {

            var i18nFilterMessage = {
                between: '${between}',
                varEnd: '${varEnd}',
                moreThan: '${moreThan}',
                lessThan: '${lessThan}',
                like: '${like}',
                varTrue: '${varTrue}',
                varFalse: '${varFalse}',
                varNull: '${varNull}'
            };

            if (jsonData.crops != null && jsonData.crops.length > 0) {
                $("#menu2").show();
            }

            $(".filter-toggler").on("click", function (ev) {
                ev.preventDefault();
                $("#allfilters").toggleClass("hide");
                $("#toggleFilters").toggleClass("hide");
            });
527
528


529
530
531
532
533
534
535
536
537
538
            $("#menu2").on("click", function () {
                $.ajax("<c:url value="/modal" />", {
                    type: 'GET',
                    data: "shortName=" + jsonData.crops,
                    success: function (data) {
                        $(".modal-content").empty();
                        $(".modal-content").append(data);
                        for (var x in jsonData) {
                            console.log(".modal-body input[value='" + x + "']");
                            $(".modal-body .filter-block label > input[value='" + x + "']").prop("checked", true);
539
                        }
540
541
542
                    },
                    error: function (error) {
                        console.log(error);
igoshin's avatar
igoshin committed
543
544
                    }
                });
545
            });
546

547

548
549
550
551
552
553
554
555
556
557
558
559
            $("body").on("click", ".additional", function () {
                var id = $(this).attr("id");
                var filterId = "#" + id.replace("_id", "_filter");
                var filter = id.replace("gm_", "gm:").replace("_id", "");

                if ($(this).is(":checked")) {
                    GenesysFilterUtil.appendFilter(filter, filterId, jsonData);
                } else {
                    delete jsonData[filter];
                    $(filterId).remove();
                }
            });
560

561
562
563
564
            $("body").on("keypress", ".string-type", function (e) {
                if (e.keyCode == 13) {
                    var btn = $(this).parent().find("button");
                    console.log(btn);
565
                    var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
566

567
                    if (selectedValue == "like") {
568
569
570
                        GenesysFilter.filterLike(btn, jsonData, i18nFilterMessage);
                    } else {
                        GenesysFilter.filterAutocomplete(btn, jsonData);
571
                    }
572
573
                }
            });
574

575
576
577
            $("body").on("click", ".filter-list", function () {
                GenesysFilter.filterList($(this), jsonData, $(this).parent().text());
            });
igoshin's avatar
igoshin committed
578

579
580
581
582
583
584
585
586
            $("body").on("click", ".filter-auto", function () {
                var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
                if (selectedValue == "like") {
                    GenesysFilter.filterLike($(this), jsonData, i18nFilterMessage);
                } else {
                    GenesysFilter.filterAutocomplete($(this), jsonData);
                }
            });
igoshin's avatar
igoshin committed
587

588
589
590
            $("body").on("click", ".filter-range", function () {
                GenesysFilter.filterRange($(this), jsonData, i18nFilterMessage);
            });
igoshin's avatar
igoshin committed
591

592
593
594
            $("body").on("click", ".filter-bool", function () {
                GenesysFilter.filterBoolean($(this), jsonData, i18nFilterMessage);
            });
igoshin's avatar
igoshin committed
595

596
597
598
            $('body').on('keyup keypress click blur change', '.filter-crop', function () {
                GenesysFilter.filterCrop($(this), jsonData);
            });
599

600
601
602
603
604
605
            $("body").on("click", ".filter-enable", function () {
                var key = $(this).attr("i-key");
                var normKey = GenesysFilter.normKey(key);
                var filterId = "#" + normKey + "_filter";
                GenesysFilterUtil.appendFilter(key, filterId, jsonData);
            });
igoshin's avatar
igoshin committed
606

607
608
609
610
611
612
            $("body").on("click", ".apply", function () {
                // Trigger the 'add-filter' event
                $('button.filter-range, button.filter-auto').click();
                // Upload
                GenesysFilterUtil.submitJson('<c:url value="/explore" />', jsonData);
            });
613

614
615
616
617
618
            $("body").on("click", ".remove-filter", function () {
                var key = $(this).parents(".filter-block").attr("i-key");
                delete jsonData[key];
                GenesysFilterUtil.submitJson('<c:url value="/explore" />', jsonData);
            });
igoshin's avatar
igoshin committed
619

620
621
622
623
624
625
626
627
628
629
            $("body").on("click", ".edit-fil", function () {
                GenesysFilterUtil.showFilter($(this).parents(".filter-block"));
            });

            $("body").on("click", ".filtval", function (event) {
                event.preventDefault();

                var key = $(this).attr("i-key");
                var normKey = GenesysFilter.normKey(key);
                var value = $(this).attr("x-key").replace(normKey, "");
igoshin's avatar
igoshin committed
630

igoshin's avatar
igoshin committed
631
632
633
634
635
//                    if (value.indexOf("{") > -1) {
//                        var jsonVal = value.replace("=", ":").replace(" ", "");
//                        value = GenesysFilterUtil.setCharAt(jsonVal, jsonVal.indexOf("{"), '{"');
//                        value = GenesysFilterUtil.setCharAt(value, jsonVal.indexOf(":") + 1, '":');
//                    }
636

637
638
                if (value == "null") value = null;
                GenesysFilterUtil.removeValue(value, key, jsonData);
igoshin's avatar
#12579    
igoshin committed
639

640
641
642
                if (!$(this).parents(".filter-block").hasClass("filter-edit")) {
                    GenesysFilterUtil.submitJson('<c:url value="/explore" />', jsonData);
                }
igoshin's avatar
#12579    
igoshin committed
643

644
645
646
                $(this).remove();
                $('input[i-key=' + normKey + value + ']').prop('checked', false);
            });
igoshin's avatar
igoshin committed
647

648
649
            $("#menuShareLink").on("click", function () {
                if ($('#shortLink').val() === '') {
650
651
                    $.ajax({
                        type: 'POST',
652
                        url: '/explore/shorten-url',
653
                        data: {
654
                            'page': ${pagedData.number + 1}, 'filter': JSON.stringify(jsonData)
655
                        },
656
                        success: function (response) {
657
658
659
660
661
                            var inp = $("#shortLink");
                            inp.val(response.shortUrl);
                            inp.select();
                        }
                    });
662
663
664
665
                } else {
                    console.log('No repeat.');
                }
            });
666

667
668
669
670
671
672
673
674
675
676
            $('#columnsApplay').on('click', function(){
                var columns = [];
               [].forEach.call($('.column-enable'), function(el){
                   if($(el).find('input:checkbox').is(':checked')){
                       columns.push($(el).find('input:checkbox').prop('name'));
                   }
               });
                var filter = JSON.stringify(jsonData);
                var url = '<c:url value="/explore" />' + '?filter=' + filter + "&columns=" + columns.toString();
                window.location.href = encodeURI(url);
igoshin's avatar
igoshin committed
677
            });
678
679
680
681
682

            GenesysFilterUtil.registerAutocomplete("#allfilters", jsonData);
        });
    </script>
</content>
igoshin's avatar
igoshin committed
683
684
</body>
</html>