Commit b96a530a authored by igoshin's avatar igoshin Committed by Matija Obreza

"Like" string filters, fix min and max values for numeric fields, <ENTER>

parent 17b95fb9
......@@ -356,6 +356,8 @@ filter.remove=Remove filter
filter.autocomplete-placeholder=Type more than 3 characters...
filter.collMissId=Collecting mission ID
filter.storage=Type of Germplasm storage
filter.string.equals=Equals
filter.string.like=Like
search.page.title=Full-text Search
......
......@@ -65,7 +65,7 @@
<div class="ui-front">
<div class="form-group input-group">
<span class="input-group-btn">
<input id="${normalizedKey}_input" class="span2 form-control autocomplete-filter" x-source="${filter.autocompleteUrl}" placeholder="<spring:message code="filter.autocomplete-placeholder" />" type="text"/>
<input id="${normalizedKey}_input" class="span2 form-control autocomplete-filter string-type" x-source="${filter.autocompleteUrl}" placeholder="<spring:message code="filter.autocomplete-placeholder" />" type="text"/>
<button class="btn notimportant filter-auto" norm-key="${normalizedKey}" >+</button>
</span>
</div>
......@@ -91,7 +91,11 @@
<div class="ui-front">
<div class="form-group input-group">
<span class="input-group-btn">
<input class="span2 form-control" id="${normalizedKey}_input" type="text"/>
<select id="like-switcher" class="form-control select-like">
<option value="like"><spring:message code="filter.string.like" /></option>
<option value="equals"><spring:message code="filter.string.equals" /></option>
</select>
<input class="span2 form-control string-type" id="${normalizedKey}_input" type="text"/>
<button class="btn notimportant filter-auto" norm-key="${normalizedKey}">+</button>
</span>
</div>
......
......@@ -124,7 +124,7 @@
<div class="ui-front">
<div class="form-group input-group">
<span class="input-group-btn">
<input id="${normalizedKey}_input" class="span2 form-control autocomplete-filter" x-source="${filter.autocompleteUrl}" placeholder="<spring:message code="filter.autocomplete-placeholder" />" type="text"/>
<input id="${normalizedKey}_input" class="span2 form-control autocomplete-filter string-type" x-source="${filter.autocompleteUrl}" placeholder="<spring:message code="filter.autocomplete-placeholder" />" type="text"/>
<button class="btn notimportant filter-auto" norm-key="${normalizedKey}" >+</button>
</span>
</div>
......@@ -159,10 +159,14 @@
</div>
</c:when>
<c:otherwise>
<div class="ui-front">
<div class="ui-front" >
<div class="form-group input-group">
<span class="input-group-btn">
<input class="span2 form-control" id="${normalizedKey}_input" type="text"/>
<select id="like-switcher" class="form-control select-like">
<option value="like"><spring:message code="filter.string.like" /></option>
<option value="equals"><spring:message code="filter.string.equals" /></option>
</select>
<input class="span2 form-control string-type" id="${normalizedKey}_input" type="text"/>
<button class="btn notimportant filter-auto" norm-key="${normalizedKey}">+</button>
</span>
</div>
......@@ -187,6 +191,10 @@
<c:set var="string" value="${fn:replace(value,'{max=','Less than ')}"/>
<c:set var="string" value="${fn:replace(string,'}','')}"/>
</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:if>
<c:if test="${string==null}">
<c:set var="string" value="null" />
</c:if>
......@@ -304,13 +312,31 @@
}
});
$("body").on("keypress", ".string-type", function (e) {
if(e.keyCode==13){
var btn=$(this).parent().find("button");
console.log(btn)
var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
if (selectedValue == "like") {
GenesysFilter.filterLike(btn, jsonData);
} else {
GenesysFilter.filterAutocomplete(btn, jsonData);
}
}
});
$("body").on("click", ".filter-list", function () {
GenesysFilter.filterList($(this), jsonData);
});
$("body").on("click", ".filter-auto", function () {
GenesysFilter.filterAutocomplete($(this), jsonData);
var selectedValue = $(this).parent().find("#like-switcher option:selected").val();
if (selectedValue == "like") {
GenesysFilter.filterLike($(this), jsonData);
} else {
GenesysFilter.filterAutocomplete($(this), jsonData);
}
});
$("body").on("click", ".filter-range", function () {
......
......@@ -1434,6 +1434,11 @@ html[dir="rtl"] #allfilters .filter-block .filter-name {
#allfilters .form-control {
background:#e7e5de;
}
#allfilters .select-like {
width: 80px;
padding-left: 6px;
}
......@@ -1937,3 +1942,20 @@ html[dir="rtl"] ul.statistics .stats-number {
float: right;
}
.filter-select{
background: none repeat scroll 0% 0% #B4B3AE;
border-width: 1px 1px 1px medium;
border-style: solid solid solid none;
border-color: #4D4D46 #4D4D46 #4D4D46 -moz-use-text-color;
-moz-border-top-colors: none;
-moz-border-right-colors: none;
-moz-border-bottom-colors: none;
-moz-border-left-colors: none;
border-image: none;
font-size: 17px;
font-weight: bold;
height: 27px;
line-height: 5px;
padding: 0px 8px;
}
......@@ -112,7 +112,7 @@ GenesysFilter = {
}
return jsonData;
},
//add filter with two input text fileds for enter values of range
//add filter with two input text fields for enter values of range
filterRange: function (element, jsonData) {
var key = $(element).attr("norm-key");
var inputId1 = "#" + key + "_input_1";
......@@ -134,9 +134,9 @@ GenesysFilter = {
jsonValue = jsonData[key.replace("_", ":")];
}
var notNull = inputValue1 != '' && inputValue2 != '';
// var notNull = inputValue1 != '' && inputValue2 != '';
if (!isNaN(inputValue1) && !isNaN(inputValue2) && notNull) {
if (!isNaN(inputValue1) && !isNaN(inputValue2)) {
if (inputValue1 == inputValue2) {
jsonValue.push(parseFloat(inputValue1));
......@@ -226,6 +226,24 @@ GenesysFilter = {
} else {
$("#menu2").hide();
}
},
filterLike: function (element, jsonData) {
var key = $(element).attr("norm-key");
var inputId = "#" + key + "_input";
var value = $(element).parent().find(inputId).val();
var likeArray = {};
likeArray["like"] = value;
var likeValue = "Like " + value;
if (!GenesysFilterUtil.existInJson(likeArray, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, likeValue, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, likeArray, jsonData);
$(inputId).val('');
}
return jsonData;
}
};
......@@ -258,7 +276,7 @@ GenesysFilterUtil = {
var array = jsonData[key];
for (var i=array.length-1; i>=0; i--) {
if (array[i] == input) {
if (JSON.stringify(array[i]) == JSON.stringify(input)) {
return true;
}
}
......
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