Commit 952d3f1d authored by igoshin's avatar igoshin Committed by Matija Obreza

Removing filters fixed

parent 9dec70a7
......@@ -182,23 +182,34 @@
<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="${normalizedKey}${string}" id="${normalizedKey}">${string}</div>
<div class="filtval complex" x-key="${normalizedKey}<c:out value="${value}"/>" id="${normalizedKey}">${string}</div>
<c:remove var="string" />
</c:forEach>
</div>
......@@ -378,11 +389,11 @@
var value = $(this).attr("x-key").replace(key, "");
if (value.indexOf("{") > -1) {
var jsonVal = value.replace("=", ":").replace(" ", "");
value = GenesysFilterUtil.setCharAt(jsonVal, jsonVal.indexOf("{"), '{"');
value = GenesysFilterUtil.setCharAt(value, jsonVal.indexOf(":") + 1, '":');
}
// if (value.indexOf("{") > -1) {
// var jsonVal = value.replace("=", ":").replace(" ", "");
// value = GenesysFilterUtil.setCharAt(jsonVal, jsonVal.indexOf("{"), '{"');
// value = GenesysFilterUtil.setCharAt(value, jsonVal.indexOf(":") + 1, '":');
// }
if (value=="null") value=null;
GenesysFilterUtil.removeValue(value, key, jsonData);
......
......@@ -1437,8 +1437,8 @@ html[dir="rtl"] #allfilters .filter-block .filter-name {
}
#allfilters .select-like {
width: 80px;
padding-left: 6px;
width: 102px;
padding: 6px;
}
......
......@@ -106,7 +106,7 @@ GenesysFilter = {
var value = $(element).parent().find(inputId).val();
if (! GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value, element);
GenesysFilterUtil.appendHtml(key, value,value, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
$(inputId).val('');
}
......@@ -161,7 +161,7 @@ GenesysFilter = {
value = "Between " + inputValue1 + " and " + inputValue2;
}
GenesysFilterUtil.appendHtml(key, value, element);
GenesysFilterUtil.appendHtml(key, value,range, element);
jsonData[key.replace("_", ":")] = jsonValue;
$(inputId1).val('');
......@@ -181,7 +181,7 @@ GenesysFilter = {
if (checked && ! GenesysFilterUtil.existInJson(value, key, jsonData)) {
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
GenesysFilterUtil.appendHtml(key, value, element);
GenesysFilterUtil.appendHtml(key, value,value, element);
} else {
var xkey = key + value;
......@@ -199,7 +199,7 @@ GenesysFilter = {
var checked = $(element).is(":checked");
if (checked && ! GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value, element);
GenesysFilterUtil.appendHtml(key, value,value, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
} else {
......@@ -220,7 +220,7 @@ GenesysFilter = {
$(selectBox).parent().parent().parent().parent().find('.complex').remove()
if (value != '') {
GenesysFilterUtil.appendHtml(key, value, element);
GenesysFilterUtil.appendHtml(key, value,value, element);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
$("#menu2").show();
} else {
......@@ -239,7 +239,7 @@ GenesysFilter = {
var likeValue = "Like " + value;
if (!GenesysFilterUtil.existInJson(likeArray, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, likeValue, element);
GenesysFilterUtil.appendHtml(key, likeValue,likeArray, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, likeArray, jsonData);
$(inputId).val('');
}
......@@ -297,17 +297,51 @@ GenesysFilterUtil = {
return jsonValue;
},
//add in html value of filter
appendHtml: function (key, value, element) {
var valueId = "#" + key + "_value";
appendHtml: function (key, value,jsonValue, element) {
if (value==null) value="null";
var div = "<div class='filtval complex' x-key='" + key + value + "' id='" + key + "'>" + value + "</div>";
if (jsonValue==null) jsonValue="null";
if (typeof jsonValue == "object" && jsonValue != null) {
jsonValue = JSON.stringify(jsonValue);
}
var div = "<div class='filtval complex' x-key='" + key + jsonValue + "' id='" + key + "'>" + value + "</div>";
$(element).parents(".filter-block").find(".filter-values").append(div);
},
//remove value from json array
removeValue: function (value, key, jsonData) {
key = key.replace("_", ":")
key = key.replace("_", ":");
var array = jsonData[key];
array.splice(array.indexOf(value), 1);
try {
value = JSON.parse(value);
if(typeof value=="number"){
value=String(value);
array.splice(array.indexOf(value), 1);
return false;
}
if(typeof value=="boolean"){
array.splice(array.indexOf(value), 1);
return false;
}
if (typeof value == "object") {
$.each(array, function (i) {
if (JSON.stringify(array[i]) == JSON.stringify(value)) {
array.splice(i, 1);
return false;
}
});
}
} catch (stringValue) {
array.splice(array.indexOf(value), 1);
}
},
//add new filter
appendFilter: function (filter, filterId, jsonData) {
......
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