Commit 7553b35e authored by Matija Obreza's avatar Matija Obreza

Genesys filters use new notation

parent 0b20469a
......@@ -61,7 +61,7 @@ public interface FaoInstituteRepository extends JpaRepository<FaoInstitute, Long
@Query("update FaoInstitute fi set accessionCount=(select count(a) from Accession a where a.institute = :institute ) where fi=:institute")
void updateInstituteAccessionCount(@Param("institute") FaoInstitute institute);
@Query("select distinct fi from FaoInstitute fi where fi.code like ?1 or fi.fullName like ?1 or fi.acronym like ?1")
@Query("select distinct fi from FaoInstitute fi where fi.code like ?1 or fi.fullName like ?1 or fi.acronym like ?1 order by fi.accessionCount desc")
List<FaoInstitute> autocomplete(String string, Pageable pageable);
}
......@@ -89,9 +89,9 @@ public class DirectMysqlQuery {
}
protected DirectMysqlQuery join(ObjectNode jsonTree) {
if (hasFilter(jsonTree, "crop") || hasFilter(jsonTree, "genus") || hasFilter(jsonTree, "species") || hasFilter(jsonTree, "taxon")) {
if (hasFilter(jsonTree, "crops") || hasFilter(jsonTree, "taxonomy.genus") || hasFilter(jsonTree, "taxonomy.species") || hasFilter(jsonTree, "taxonomy.sciName")) {
innerJoin("taxonomy2", "t", "t.id=a.taxonomyId2");
if (hasFilter(jsonTree, "crop")) {
if (hasFilter(jsonTree, "crops")) {
innerJoin("croptaxonomy", "ct", "ct.taxonomyId=t.id");
innerJoin("crop", null, "crop.id=ct.cropId");
}
......@@ -102,15 +102,15 @@ public class DirectMysqlQuery {
innerJoin("organization", "org", "org.id=oi.organizationId");
}
if (hasFilter(jsonTree, "latitude") || hasFilter(jsonTree, "longitude") || hasFilter(jsonTree, "elevation")) {
if (hasFilter(jsonTree, "geo.latitude") || hasFilter(jsonTree, "geo.longitude") || hasFilter(jsonTree, "geo.elevation")) {
innerJoin("accessiongeo", "geo", "geo.accessionId=a.id");
}
if (hasFilter(jsonTree, "acceName")) {
if (hasFilter(jsonTree, "alias")) {
innerJoin("accessionalias", "accename", "accename.accessionId=a.id");
}
if (hasFilter(jsonTree, "collMissId")) {
if (hasFilter(jsonTree, "coll.collMissId")) {
innerJoin("accessioncollect", "col", "col.accessionId=a.id");
}
......@@ -131,23 +131,23 @@ public class DirectMysqlQuery {
createQuery(whereBuffer, "a.taxGenus", jsonTree.get("genusId"), params);
createQuery(whereBuffer, "a.taxSpecies", jsonTree.get("speciesId"), params);
createQuery(whereBuffer, "a.acceNumb", jsonTree.get("acceNumb"), params);
createQuery(whereBuffer, "a.orgCty", jsonTree.get("orgCty"), params);
createQuery(whereBuffer, "a.instCode", jsonTree.get("instCode"), params);
createQuery(whereBuffer, "a.inSGSV", jsonTree.get("inSvalbard"), params);
createQuery(whereBuffer, "a.mlsStat", jsonTree.get("mlsStat"), params);
createQuery(whereBuffer, "a.inTrust", jsonTree.get("inTrust"), params);
createQuery(whereBuffer, "a.orgCty", jsonTree.get("orgCty.iso3"), params);
createQuery(whereBuffer, "a.instCode", jsonTree.get("institute.code"), params);
createQuery(whereBuffer, "a.inSGSV", jsonTree.get("svalbard"), params);
createQuery(whereBuffer, "a.mlsStat", jsonTree.get("mlsStatus"), params);
createQuery(whereBuffer, "a.inTrust", jsonTree.get("art15"), params);
createQuery(whereBuffer, "a.sampStat", jsonTree.get("sampStat"), params);
createQuery(whereBuffer, "a.available", jsonTree.get("available"), params);
createQuery(whereBuffer, "org.slug", jsonTree.get("organization"), params);
createQuery(whereBuffer, "t.genus", jsonTree.get("genus"), params);
createQuery(whereBuffer, "t.species", jsonTree.get("species"), params);
createQuery(whereBuffer, "t.taxonName", jsonTree.get("taxon"), params);
createQuery(whereBuffer, "geo.longitude", jsonTree.get("longitude"), params);
createQuery(whereBuffer, "geo.latitude", jsonTree.get("latitude"), params);
createQuery(whereBuffer, "geo.elevation", jsonTree.get("elevation"), params);
createQuery(whereBuffer, "crop.shortName", jsonTree.get("crop"), params);
createQuery(whereBuffer, "accename.name", jsonTree.get("acceName"), params);
createQuery(whereBuffer, "col.collMissId", jsonTree.get("collMissId"), params);
createQuery(whereBuffer, "t.genus", jsonTree.get("taxonomy.genus"), params);
createQuery(whereBuffer, "t.species", jsonTree.get("taxonomy.species"), params);
createQuery(whereBuffer, "t.taxonName", jsonTree.get("taxonomy.sciName"), params);
createQuery(whereBuffer, "geo.longitude", jsonTree.get("geo.longitude"), params);
createQuery(whereBuffer, "geo.latitude", jsonTree.get("geo.latitude"), params);
createQuery(whereBuffer, "geo.elevation", jsonTree.get("geo.elevation"), params);
createQuery(whereBuffer, "crop.shortName", jsonTree.get("crops"), params);
createQuery(whereBuffer, "accename.name", jsonTree.get("alias"), params);
createQuery(whereBuffer, "col.collMissId", jsonTree.get("coll.collMissId"), params);
createQuery(whereBuffer, "storage.storage", jsonTree.get("storage"), params);
for (final Iterator<String> it = jsonTree.fieldNames(); it.hasNext();) {
......
......@@ -111,27 +111,27 @@ public class GenesysFilterServiceImpl implements GenesysFilterService {
public GenesysFilterServiceImpl() {
this.availableFilters = new ArrayList<GenesysFilter>();
this.availableFilters.add(new GenesysFilterImpl("crop", DataType.STRING));
this.availableFilters.add(new GenesysFilterImpl("crops", DataType.STRING));
this.availableFilters.add(new GenesysI18nListFilterImpl<Integer>("sampStat", DataType.NUMERIC).build("accession.sampleStatus", new Integer[] { 100,
110, 120, 130, 200, 300, 400, 410, 411, 412, 413, 414, 415, 416, 420, 421, 422, 423, 500, 600, 999 }));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("genus", "/explore/ac/genus"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("species", "/explore/ac/species"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("taxon", "/explore/ac/taxonomy"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("taxonomy.genus", "/explore/ac/genus"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("taxonomy.species", "/explore/ac/species"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("taxonomy.sciName", "/explore/ac/taxonomy"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("orgCty", "/explore/ac/country"));
this.availableFilters.add(new GenesysFilterImpl("latitude", DataType.NUMERIC));
this.availableFilters.add(new GenesysFilterImpl("longitude", DataType.NUMERIC));
this.availableFilters.add(new GenesysFilterImpl("elevation", DataType.NUMERIC));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("orgCty.iso3", "/explore/ac/country"));
this.availableFilters.add(new GenesysFilterImpl("geo.latitude", DataType.NUMERIC));
this.availableFilters.add(new GenesysFilterImpl("geo.longitude", DataType.NUMERIC));
this.availableFilters.add(new GenesysFilterImpl("geo.elevation", DataType.NUMERIC));
this.availableFilters.add(new GenesysFilterImpl("organization", DataType.STRING));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("instCode", "/explore/ac/instCode"));
this.availableFilters.add(new GenesysAutocompleteFilterImpl("institute.code", "/explore/ac/instCode"));
this.availableFilters.add(new GenesysFilterImpl("acceNumb", DataType.STRING, FilterType.RANGE));
this.availableFilters.add(new GenesysFilterImpl("acceName", DataType.STRING, FilterType.RANGE));
this.availableFilters.add(new GenesysFilterImpl("inSvalbard", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("mlsStat", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("inTrust", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("alias", DataType.STRING, FilterType.RANGE));
this.availableFilters.add(new GenesysFilterImpl("sgsv", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("mlsStatus", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("art15", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("available", DataType.BOOLEAN));
this.availableFilters.add(new GenesysFilterImpl("collMissId", DataType.STRING));
this.availableFilters.add(new GenesysFilterImpl("coll.collMissId", DataType.STRING));
this.availableFilters.add(new GenesysI18nListFilterImpl<Integer>("storage", DataType.NUMERIC).build("accession.storage", new Integer[] { 10, 11, 12,
13, 20, 30, 40, 50, 99 }));
}
......
......@@ -134,7 +134,7 @@ public class AccessionController extends BaseController {
throw new ResourceNotFoundException("No taxonomy with genus=" + genus);
}
model.addAttribute("filter", "{\"genus\":[\"" + taxonomy.getGenus() + "\"]}");
model.addAttribute("filter", "{\"taxonomy.genus\":[\"" + taxonomy.getGenus() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
......@@ -160,7 +160,7 @@ public class AccessionController extends BaseController {
throw new ResourceNotFoundException("No taxonomy with genus=" + genus);
}
model.addAttribute("filter", "{\"genus\":[\"" + taxonomy.getGenus() + "\"], \"species\":[\"" + taxonomy.getSpecies() + "\"]}");
model.addAttribute("filter", "{\"taxonomy.genus\":[\"" + taxonomy.getGenus() + "\"], \"taxonomy.species\":[\"" + taxonomy.getSpecies() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
......
......@@ -126,7 +126,7 @@ public class CountryController extends BaseController {
throw new ResourceNotFoundException();
}
model.addAttribute("filter", "{\"orgCty\":[\"" + country.getCode3() + "\"]}");
model.addAttribute("filter", "{\"orgCty.iso3\":[\"" + country.getCode3() + "\"]}");
return "redirect:/explore";
}
......
......@@ -95,7 +95,7 @@ public class CropController extends BaseController {
throw new ResourceNotFoundException();
}
model.addAttribute("filter", "{\"crop\":[\"" + crop.getShortName() + "\"]}");
model.addAttribute("filter", "{\"crops\":[\"" + crop.getShortName() + "\"]}");
return "redirect:/explore";
}
......
......@@ -114,7 +114,7 @@ public class ExplorerController extends BaseController {
throw new ResourceNotFoundException("No crop " + shortName);
}
model.addAttribute("filter", "{\"crop\":[\"" + crop.getShortName() + "\"]}");
model.addAttribute("filter", "{\"crops\":[\"" + crop.getShortName() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
}
......@@ -191,7 +191,7 @@ public class ExplorerController extends BaseController {
final List<GenesysFilterService.GenesysFilter> additionalFilters = filterService.selectFilters(selectedFilters);
model.addAttribute("additionalFilters", additionalFilters);
if (ArrayUtils.contains(selectedFilters, "crop")) {
if (ArrayUtils.contains(selectedFilters, "crops")) {
_logger.debug("Adding crop list");
model.addAttribute("crops", cropService.list(getLocale()));
}
......
......@@ -165,7 +165,7 @@ public class WiewsController extends BaseController {
throw new ResourceNotFoundException();
}
model.addAttribute("filter", "{\"instCode\":[\"" + faoInstitute.getCode() + "\"]}");
model.addAttribute("filter", "{\"institute.code\":[\"" + faoInstitute.getCode() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
}
......@@ -186,7 +186,7 @@ public class WiewsController extends BaseController {
}
_logger.debug("Got " + taxonomy2);
model.addAttribute("filter", "{\"instCode\":[\"" + faoInstitute.getCode() + "\"],\"genus\":[\"" + taxonomy2.getGenus() + "\"]}");
model.addAttribute("filter", "{\"institute.code\":[\"" + faoInstitute.getCode() + "\"],\"taxonomy.genus\":[\"" + taxonomy2.getGenus() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
}
......@@ -207,7 +207,7 @@ public class WiewsController extends BaseController {
}
_logger.debug("Got " + taxonomy2);
model.addAttribute("filter", "{\"instCode\":[\"" + faoInstitute.getCode() + "\"],\"genus\":[\"" + taxonomy2.getGenus() + "\"],\"species\":[\""
model.addAttribute("filter", "{\"institute.code\":[\"" + faoInstitute.getCode() + "\"],\"taxonomy.genus\":[\"" + taxonomy2.getGenus() + "\"],\"taxonomy.species\":[\""
+ taxonomy2.getSpecies() + "\"]}");
model.addAttribute("page", page);
return "redirect:/explore";
......
......@@ -328,24 +328,23 @@ filter.filters-not-applied=You can filter the data.
filters.data-is-filtered=The data is filtered.
filters.toggle-filters=Filters
filter.taxonomy=Scientific name
filter.inTrust=ITPGRFA Art. 15 accession
filter.art15=ITPGRFA Art. 15 accession
filter.acceNumb=Accession number
filter.acceName=Accession name
filter.crop=Crop name
filter.countryOfOrigin=Country of Origin
filter.holdingInstitute=Holding Institute name
filter.orgCty=Country of Origin
filter.alias=Accession name
filter.crops=Crop name
filter.orgCty.iso3=Country of Origin
filter.institute.code=Holding Institute name
filter.sampStat=Biological status of accession
filter.instCode=Holding Institute
filter.latitude=Latitude
filter.longitude=Longitude
filter.elevation=Elevation
filter.genus=Genus
filter.species=Species
filter.institute.code=Holding Institute
filter.geo.latitude=Latitude
filter.geo.longitude=Longitude
filter.geo.elevation=Elevation
filter.taxonomy.genus=Genus
filter.taxonomy.species=Species
filter.taxSpecies=Species
filter.taxon=Scientific name
filter.inSvalbard=Safety duplicated in Svalbard
filter.mlsStat=MLS status of the accession
filter.taxonomy.sciName=Scientific name
filter.sgsv=Safety duplicated in Svalbard
filter.mlsStatus=MLS status of the accession
filter.available=Available for distribution
filter.download-dwca=Download ZIP
filter.add=Add filter
......
......@@ -9,10 +9,9 @@
<c:forEach items="${additionalFilters}" var="filter">
<c:set var="normalizedKey" value="${fn:replace(filter.key,':', '_')}"/>
<c:set var="filterKey" value="${filter.key}"/>
<c:set var="normalizedKey" value="${filter.key.replace(':', '_').replace('.','-')}"/>
<div class="clearfix filter-block" id="${normalizedKey}_filter" key="${normalizedKey}">
<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}">
......@@ -25,10 +24,10 @@
</div>
<div class="col-lg-5 filter-new">
<c:choose>
<c:when test="${filter.name=='crop'}">
<c:when test="${filter.name=='crops'}">
<div class="form-group input-group">
<span class="input-group-btn">
<select name="crop" id="cropselector" i-key = "${filterKey}" class="form-control filter-crop">
<select name="crops" id="cropselector" i-key="<c:out value="${filter.key}" />" class="form-control filter-crop">
<option value=""></option>
<c:forEach items="${crops}" var="c">
<option value="${c.shortName}" ${c.shortName== crop.shortName?'selected':''} ><c:out value="${c.getName(pageContext.response.locale)}" /></option>
......@@ -42,7 +41,7 @@
<c:forEach items="${filter.options}" var="option">
<div>
<label>
<input class="filter-list" id="${option.value}_input" ${fn:contains(filters[filter.key], option.value)?'checked':''} norm-key="${normalizedKey}" i-key="${normalizedKey}${option.value}" type="checkbox" value="${option.value}" />
<input class="filter-list" id="<c:out value="${normalizedKey}${option.value}" />_input" ${fn:contains(filters[filter.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>
......@@ -54,7 +53,7 @@
<c:forEach items="${filter.options}" var="option">
<div>
<label>
<input class="filter-list" id="${option.value}_input" ${fn:contains(filters[filter.key], option.value)?'checked':''} norm-key="${normalizedKey}" i-key="${normalizedKey}${option.value}" type="checkbox" value="${option.value}" />
<input class="filter-list" id="<c:out value="${normalizedKey}${option.value}" />_input" ${fn:contains(filters[filter.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>
......@@ -66,7 +65,7 @@
<div class="form-group input-group">
<span class="input-group-btn">
<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>
<button class="btn notimportant filter-auto" norm-key="<c:out value="${normalizedKey}" />" i-key="<c:out value="${filter.key}" />">+</button>
</span>
</div>
</div>
......@@ -76,15 +75,15 @@
<span class="input-group-btn">
<input id="${normalizedKey}_input_1" class="span5 form-control" type="text"/>
<input id="${normalizedKey}_input_2" class="span5 form-control" type="text"/>
<button class="btn notimportant filter-range" norm-key="${normalizedKey}">+</button>
<button class="btn notimportant filter-range" norm-key="${normalizedKey}" i-key="<c:out value="${filter.key}" />">+</button>
</span>
</div>
</c:when>
<c:when test="${filter.dataType=='BOOLEAN'}">
<div class="">
<div><label><input type="checkbox" ${fn:contains(filters[filter.key], 'true')?'checked':''} class="filter-bool" i-key="${normalizedKey}true" id="${normalizedKey}" value="true"><spring:message code="boolean.true"/></label></div>
<div><label><input type="checkbox" ${fn:contains(filters[filter.key], 'false')?'checked':''} class="filter-bool" i-key="${normalizedKey}false" id="${normalizedKey}" value="false"><spring:message code="boolean.false"/></label></div>
<div><label><input type="checkbox" ${fn:contains(filters[filter.key], 'null')?'checked':''} class="filter-bool" i-key="${normalizedKey}null" id="${normalizedKey}" value="null"><spring:message code="boolean.null"/></label></div>
<div><label><input type="checkbox" ${fn:contains(filters[filter.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[filter.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>
<div><label><input type="checkbox" ${fn:contains(filters[filter.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:otherwise>
......@@ -96,7 +95,7 @@
<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>
<button class="btn notimportant filter-auto" norm-key="${normalizedKey}" i-key="<c:out value="${filter.key}" />">+</button>
</span>
</div>
</div>
......@@ -104,7 +103,7 @@
</c:choose>
</div>
<div class="col-lg-9">
<div class="filter-values" id="${normalizedKey}_value">
<div class="filter-values" id="<c:out value="${normalizedKey}" />_value">
</div>
<div style="margin-top: 3px" class="filter-apply-btn">
<button class="btn btn-primary apply"><spring:message code="filter.apply"/></button>
......
......@@ -97,26 +97,31 @@ GenesysMaps.BoundingBox.prototype.getBounds = function() {
};
GenesysFilter = {
normKey: function(key) {
return key.replace('.','-').replace(':','_');
},
//add filter with autocomplete or exact field
filterAutocomplete: function (element, jsonData) {
var key = $(element).attr("norm-key");
var key = $(element).attr("i-key");
var normKey = GenesysFilter.normKey(key);
var inputId = "#" + key + "_input";
var inputId = "#" + normKey + "_input";
var value = $(element).parent().find(inputId).val();
if (! GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value,value, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
$(inputId).val('');
}
return jsonData;
},
//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";
var inputId2 = "#" + key + "_input_2";
var key = $(element).attr("i-key");
var normKey = GenesysFilter.normKey(key);
var inputId1 = "#" + normKey + "_input_1";
var inputId2 = "#" + normKey + "_input_2";
var inputValue1 = $(inputId1).val();
var inputValue2 = $(inputId2).val();
......@@ -129,9 +134,9 @@ GenesysFilter = {
var jsonValue = [];
var exist = jsonData[key.replace("_", ":")] != null;
var exist = jsonData[key] != null;
if (exist) {
jsonValue = jsonData[key.replace("_", ":")];
jsonValue = jsonData[key];
}
// var notNull = inputValue1 != '' && inputValue2 != '';
......@@ -163,7 +168,7 @@ GenesysFilter = {
GenesysFilterUtil.appendHtml(key, value,range, element);
jsonData[key.replace("_", ":")] = jsonValue;
jsonData[key] = jsonValue;
$(inputId1).val('');
$(inputId2).val('');
return jsonData;
......@@ -171,20 +176,21 @@ GenesysFilter = {
},
//add filter with few checkboxes
filterList: function (element, jsonData) {
var key = $(element).attr("norm-key");
var key = $(element).attr("i-key");
var normKey = GenesysFilter.normKey(key);
var option = $(element).val();
var inputId = "#" + option + "_input";
var inputId = "#" + normKey + option + "_input";
var value = $(element).parent().find(inputId).val();
var checked = $(element).parent().find(inputId).is(":checked");
if (checked && ! GenesysFilterUtil.existInJson(value, key, jsonData)) {
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
GenesysFilterUtil.appendHtml(key, value,value, element);
} else {
var xkey = key + value;
var xkey = normKey + value;
GenesysFilterUtil.removeValue(value, key, jsonData);
$('div[x-key=' + xkey + ']').remove();
}
......@@ -195,15 +201,17 @@ GenesysFilter = {
if (value=="null") value=null;
if (value=="true") value=true;
if (value=="false") value=false;
var key = $(element).attr("id");
var key = $(element).attr("i-key");
var normKey = GenesysFilter.normKey(key);
var checked = $(element).is(":checked");
if (checked && ! GenesysFilterUtil.existInJson(value, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, value,value, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, value, jsonData);
jsonData[key] = GenesysFilterUtil.collectData(key, value, jsonData);
} else {
var xkey = key + value;
var xkey = normKey + value;
GenesysFilterUtil.removeValue(value, key, jsonData);
$('div[x-key=' + xkey + ']').remove();
}
......@@ -215,7 +223,6 @@ GenesysFilter = {
var value = selectBox.options[selectBox.selectedIndex].value;
if (value=="null") value=null;
var key = $(element).attr("i-key");
delete jsonData[key];
$(selectBox).parent().parent().parent().parent().find('.complex').remove()
......@@ -229,9 +236,10 @@ GenesysFilter = {
},
filterLike: function (element, jsonData) {
var key = $(element).attr("norm-key");
var key = $(element).attr("i-key");
var normKey = GenesysFilter.normKey(key);
var inputId = "#" + key + "_input";
var inputId = "#" + normKey + "_input";
var value = $(element).parent().find(inputId).val();
var likeArray = {};
......@@ -240,7 +248,7 @@ GenesysFilter = {
if (!GenesysFilterUtil.existInJson(likeArray, key, jsonData)) {
GenesysFilterUtil.appendHtml(key, likeValue,likeArray, element);
jsonData[key.replace("_", ":")] = GenesysFilterUtil.collectData(key, likeArray, jsonData);
jsonData[key] = GenesysFilterUtil.collectData(key, likeArray, jsonData);
$(inputId).val('');
}
return jsonData;
......@@ -272,7 +280,6 @@ GenesysFilterUtil = {
},
//check that value exist in json array
existInJson: function (input, key, jsonData) {
key = key.replace("_", ":");
var array = jsonData[key];
for (var i=array.length-1; i>=0; i--) {
......@@ -285,7 +292,6 @@ GenesysFilterUtil = {
//form json array
collectData: function (key, value, jsonData) {
if (value=="null") value=null;
key = key.replace("_", ":");
var jsonValue = [];
var exist = jsonData[key] != null;
......@@ -298,7 +304,8 @@ GenesysFilterUtil = {
},
//add in html value of filter
appendHtml: function (key, value,jsonValue, element) {
var normKey = GenesysFilter.normKey(key);
if (value==null) value="null";
if (jsonValue==null) jsonValue="null";
......@@ -306,12 +313,11 @@ GenesysFilterUtil = {
jsonValue = JSON.stringify(jsonValue);
}
var div = "<div class='filtval complex' x-key='" + key + jsonValue + "' id='" + key + "'>" + value + "</div>";
var div = "<div class='filtval complex' x-key='" + normKey + jsonValue + "' i-key='" + 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("_", ":");
var array = jsonData[key];
try {
......
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