Commit 3276a847 authored by Alexander Dolzhenko's avatar Alexander Dolzhenko Committed by Matija Obreza
Browse files

fix javascript filter values

parent 67611f89
......@@ -405,6 +405,11 @@ filter.string.equals=Equals
filter.string.like=Starts with
filter.inverse=Excluding
filter.set-inverse=Exclude selected values
filter.internal.message.like=Like {0}
filter.internal.message.between=Between {0}
filter.internal.message.and={0} and {0}
filter.internal.message.more=More than {0}
filter.internal.message.less=Less than {0}
search.page.title=Full-text Search
......
......@@ -404,7 +404,11 @@ filter.string.equals=يساوي
filter.string.like=يبدأ بـ
filter.inverse=جاري الاستثناء
filter.set-inverse=استثناء القيم المُحددة
filter.internal.message.like=مثل {0}
filter.internal.message.between=ما بين {0}
filter.internal.message.and={0} و {0}
filter.internal.message.more=أكثر من {0}
filter.internal.message.less=اقل من {0}
search.page.title=بحث عن كامل النص
search.no-results=لم يُعثر على نتائج لبحثك.
......
......@@ -408,7 +408,11 @@ filter.string.equals=Равные
filter.string.like=Начинается с
filter.inverse=Не включая
filter.set-inverse=Выбранные значения не включаются
filter.internal.message.like=Начинается с {0}
filter.internal.message.between=Диапозон от {0}
filter.internal.message.and={0} до {0}
filter.internal.message.more=От {0}
filter.internal.message.less=До {0}
search.page.title=Полнотекстовый поиск
search.no-results=Не найдено данных, соответствующих вашему запросу.
......
......@@ -369,7 +369,7 @@ var GenesysFilter = {
if (value === '') {
return;
}
if (!GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value, value, element);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
......@@ -378,7 +378,7 @@ var GenesysFilter = {
return jsonData;
},
// add filter with two input text fields for enter values of range
filterRange : function(element, jsonData) {
filterRange : function(element, jsonData,i18n) {
var key = $(element).attr('i-key');
var normKey = GenesysFilter.normKey(key);
var inputId1 = '#' + normKey + '_input_1';
......@@ -415,12 +415,12 @@ var GenesysFilter = {
range.min = parseFloat(inputValue1);
jsonValue.push(range);
value = 'More than ' + inputValue1;
value = i18n.moreThan + inputValue1;
} else if (inputValue1 === '' && inputValue2 !== '') {
range.max = parseFloat(inputValue2);
jsonValue.push(range);
value = 'Less than ' + inputValue2;
value = i18n.lessThan + inputValue2;
} else if (inputValue1 !== '' && inputValue2 !== '') {
rangeValue.push(parseFloat(inputValue1));
......@@ -428,7 +428,7 @@ var GenesysFilter = {
range.range = rangeValue;
jsonValue.push(range);
value = 'Between ' + inputValue1 + ' and ' + inputValue2;
value = i18n.between + inputValue1 + i18n.varEnd + inputValue2;
}
GenesysFilterUtil.appendHtml(key, value, range, element);
......@@ -461,16 +461,20 @@ var GenesysFilter = {
}
},
// add filter with three checkboxes true/false/null values
filterBoolean : function(element, jsonData) {
filterBoolean : function(element, jsonData,i18n) {
var value = $(element).val();
var textValue;
if (value === 'null') {
value = null;
textValue = i18n.varNull;
}
if (value === 'true') {
value = true;
textValue = i18n.varTrue;
}
if (value === 'false') {
value = false;
textValue = i18n.varFalse;
}
var key = $(element).attr('i-key');
......@@ -479,7 +483,7 @@ var GenesysFilter = {
var checked = $(element).is(':checked');
if (checked && !GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value, value, element);
GenesysFilterUtil.appendHtml(key, textValue, value, element);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
} else {
......@@ -509,20 +513,19 @@ var GenesysFilter = {
}
},
filterLike : function(element, jsonData) {
filterLike : function(element, jsonData, i18n) {
var key = $(element).attr('i-key');
var normKey = GenesysFilter.normKey(key);
var inputId = '#' + normKey + '_input';
var value = $(element).parent().find(inputId).val();
if (value === '') {
return;
}
var likeArray = {};
likeArray.like = value;
var likeValue = 'Like ' + value;
var likeValue = i18n.like + value;
if (!GenesysFilterUtil.existInJson(likeArray, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, likeValue, likeArray, element);
......
<!DOCTYPE html>
<%@include file="/WEB-INF/jsp/init.jsp"%>
<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"/>
<html>
<head>
......@@ -120,14 +128,12 @@
<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>
......@@ -223,34 +229,39 @@
<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,',',' and ')}"/>
<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=','More than ')}"/>
<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=','Less than ')}"/>
<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(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="null" />
<c:set var="string" value="${varNull}" />
<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>
......@@ -316,6 +327,17 @@
$(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();
}
......@@ -362,11 +384,11 @@
$("body").on("keypress", ".string-type", function (e) {
if(e.keyCode==13){
var btn=$(this).parent().find("button");
console.log(btn)
console.log(btn);
var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
if (selectedValue == "like") {
GenesysFilter.filterLike(btn, jsonData);
GenesysFilter.filterLike(btn, jsonData, i18nFilterMessage);
} else {
GenesysFilter.filterAutocomplete(btn, jsonData);
}
......@@ -380,18 +402,18 @@
$("body").on("click", ".filter-auto", function () {
var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
if (selectedValue == "like") {
GenesysFilter.filterLike($(this), jsonData);
GenesysFilter.filterLike($(this), jsonData, i18nFilterMessage);
} else {
GenesysFilter.filterAutocomplete($(this), jsonData);
}
});
$("body").on("click", ".filter-range", function () {
GenesysFilter.filterRange($(this), jsonData);
GenesysFilter.filterRange($(this), jsonData, i18nFilterMessage);
});
$("body").on("click", ".filter-bool", function () {
GenesysFilter.filterBoolean($(this), jsonData);
GenesysFilter.filterBoolean($(this), jsonData, i18nFilterMessage);
});
$('body').on('keyup keypress click blur change', '.filter-crop', function () {
......
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