Commit 697f1232 authored by igoshin's avatar igoshin Committed by Matija Obreza
Browse files

#12579

parent 14d25162
...@@ -278,7 +278,7 @@ public class ExplorerController extends BaseController { ...@@ -278,7 +278,7 @@ public class ExplorerController extends BaseController {
@RequestParam(value = "pick", required = false) String jsonPick) { @RequestParam(value = "pick", required = false) String jsonPick) {
String[] selectedFilters =new String[0]; String[] selectedFilters =new String[0];
jsonFilter=jsonFilter.replaceAll("_",":");
Crop crop=null; Crop crop=null;
if (StringUtils.isNotBlank(jsonPick)) { if (StringUtils.isNotBlank(jsonPick)) {
// Cleanup JSON pick // Cleanup JSON pick
......
...@@ -335,7 +335,7 @@ filter.inSvalbard=Safety duplicated in Svalbard ...@@ -335,7 +335,7 @@ filter.inSvalbard=Safety duplicated in Svalbard
filter.mlsStat=MLS status of the accession filter.mlsStat=MLS status of the accession
filter.available=Available for distribution filter.available=Available for distribution
filter.download-dwca=Download DwCA filter.download-dwca=Download DwCA
filter.add=Add filter filter.add=View & modify filters
filter.additional=Additional filters filter.additional=Additional filters
filter.apply=Apply filter.apply=Apply
filter.close=Close filter.close=Close
......
...@@ -71,7 +71,7 @@ ...@@ -71,7 +71,7 @@
<c:forEach items="${allFilters}" var="filter"> <c:forEach items="${allFilters}" var="filter">
<c:set var="normalizedKey" value="${filter.key.replace(':', '_')}"/> <c:set var="normalizedKey" value="${fn:replace(filter.key,':', '_')}"/>
<c:set var="filterKey" value="${filter.key}"/> <c:set var="filterKey" value="${filter.key}"/>
<div class="clearfix filter-block" style="display:${pick[filterKey] eq filterKey ? '' : 'none'}" <div class="clearfix filter-block" style="display:${pick[filterKey] eq filterKey ? '' : 'none'}"
...@@ -167,6 +167,9 @@ ...@@ -167,6 +167,9 @@
</select> </select>
</span> </span>
</div> </div>
<div style="margin-top: 3px">
<button class="btn btn-primary apply"><spring:message code="filter.apply"/></button>
</div>
</c:when> </c:when>
<c:otherwise> <c:otherwise>
<div class="form-group input-group"> <div class="form-group input-group">
...@@ -186,8 +189,7 @@ ...@@ -186,8 +189,7 @@
<a href="#" style="float: right" class="edit-fil glyphicon glyphicon-pencil"></a> <a href="#" style="float: right" class="edit-fil glyphicon glyphicon-pencil"></a>
</div> </div>
<div class="col-lg-4 filter-values" id="${normalizedKey}_value"> <div class="col-lg-4 filter-values" id="${normalizedKey}_value">
<%--<a href="#" style="float: right" class="close-fil glyphicon glyphicon-remove"></a>--%>
<%--<a href="#" style="float: right" class="edit-fil glyphicon glyphicon-pencil"></a>--%>
<c:forEach items="${filters[filter.key]}" var="value"> <c:forEach items="${filters[filter.key]}" var="value">
<c:set var="string" value="${value}"/> <c:set var="string" value="${value}"/>
...@@ -285,10 +287,17 @@ ...@@ -285,10 +287,17 @@
<content tag="javascript"> <content tag="javascript">
<script type="text/javascript"> <script type="text/javascript">
var jsonData = ${jsonFilter}; var jsonData = ${fn:replace(jsonFilter,'_',':')};
var filterPick = []; var filterPick = [];
var page=${pagedData.number};
if(page==0){
$(".dropdown-toggle").hide();
$(".filter-block").show();
}
function setCharAt(str,index,chr) { function setCharAt(str,index,chr) {
if(index > str.length-1) return str; if(index > str.length-1) return str;
return str.substr(0,index) + chr + str.substr(index+1); return str.substr(0,index) + chr + str.substr(index+1);
...@@ -308,6 +317,7 @@ ...@@ -308,6 +317,7 @@
} }
function existInJson(input, key) { function existInJson(input, key) {
key=key.replace("_",":");
var exist = input != ''; var exist = input != '';
var array = jsonData[key]; var array = jsonData[key];
...@@ -351,6 +361,7 @@ ...@@ -351,6 +361,7 @@
} }
function collectData(key,value) { function collectData(key,value) {
key=key.replace("_",":");
var jsonValue = []; var jsonValue = [];
var exist = jsonData[key] != null; var exist = jsonData[key] != null;
...@@ -363,7 +374,7 @@ ...@@ -363,7 +374,7 @@
} }
function removeValue(value, key) { function removeValue(value, key) {
key= key.replace("_",":")
var array = jsonData[key]; var array = jsonData[key];
for (var val in array) { for (var val in array) {
...@@ -392,7 +403,7 @@ ...@@ -392,7 +403,7 @@
if (existInJson(value, key)) { if (existInJson(value, key)) {
appendHtml(key, value); appendHtml(key, value);
jsonData[key] = collectData(key,value); jsonData[key.replace("_",":")] = collectData(key,value);
$(inputId).val(''); $(inputId).val('');
} }
} }
...@@ -412,9 +423,9 @@ ...@@ -412,9 +423,9 @@
var jsonValue = []; var jsonValue = [];
var exist = jsonData[key] != null; var exist = jsonData[key.replace("_",":")] != null;
if (exist) { if (exist) {
jsonValue = jsonData[key]; jsonValue = jsonData[key.replace("_",":")];
} }
var notNull=inputValue1!=''&&inputValue2!=''; var notNull=inputValue1!=''&&inputValue2!='';
...@@ -445,7 +456,8 @@ ...@@ -445,7 +456,8 @@
} }
appendHtml(key, value); appendHtml(key, value);
jsonData[key] = jsonValue;
jsonData[key.replace("_",":")] = jsonValue;
$(inputId1).val(''); $(inputId1).val('');
$(inputId2).val(''); $(inputId2).val('');
} }
...@@ -459,8 +471,8 @@ ...@@ -459,8 +471,8 @@
var checked = $(inputId).is(":checked"); var checked = $(inputId).is(":checked");
if (checked && existInJson(value, key)) { if (checked && existInJson(value, key)) {
jsonData[key.replace("_",":")] = collectData(key,value);
appendHtml(key, value); appendHtml(key, value);
jsonData[key] = collectData(key,value);
} else { } else {
var xkey = key + value; var xkey = key + value;
...@@ -479,7 +491,6 @@ ...@@ -479,7 +491,6 @@
if(value!=''){ if(value!=''){
appendHtml(key, value); appendHtml(key, value);
jsonData[key] = collectData(key, value); jsonData[key] = collectData(key, value);
submitJson();
} }
} }
...@@ -491,7 +502,7 @@ ...@@ -491,7 +502,7 @@
if (checked && existInJson(value, key)) { if (checked && existInJson(value, key)) {
appendHtml(key, value); appendHtml(key, value);
jsonData[key] = collectData(key,value); jsonData[key.replace("_",":")] = collectData(key,value);
} else { } else {
var xkey = key + value; var xkey = key + value;
...@@ -501,14 +512,15 @@ ...@@ -501,14 +512,15 @@
}); });
$(".apply").click(function () { $(".apply").click(function () {
submitJson() submitJson();
}); });
$(".close-fil").on("click", function () { $(".close-fil").on("click", function () {
var parent = $(this).parent().parent(); var parent = $(this).parent().parent();
var key = parent.attr("key"); var key = parent.attr("key");
console.log(key); console.log(key);
delete jsonData[key]; delete jsonData[key.replace("_",":")];
submitJson();
parent.hide(); parent.hide();
}); });
...@@ -534,6 +546,11 @@ ...@@ -534,6 +546,11 @@
} }
removeValue(value, key); removeValue(value, key);
if($(this).parent().parent().find(".filter-new").is(":hidden")){
submitJson();
}
$(this).remove(); $(this).remove();
$('input[i-key=' + key + value + ']').prop('checked', false); $('input[i-key=' + key + value + ']').prop('checked', false);
}); });
......
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