Skip to content
Snippets Groups Projects
Commit 38e22c9f authored by S.Listl's avatar S.Listl Committed by Sebastian Listl
Browse files

Attribute Filter fix

(cherry picked from commit f79a987f)
parent 015595b0
No related branches found
No related tags found
No related merge requests found
......@@ -3,12 +3,20 @@ import("system.vars");
import("system.result");
import("Attribute_lib");
var thisValueNotValid = "{\"entity\":\"\",\"filter\":{\"type\":\"group\",\"operator\":\"AND\",\"childs\":[]}}";
if (vars.get("$field.DROPDOWNDEFINITION") == $AttributeTypes.OBJECTSELECTION
&& vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && (vars.get("$this.value") == null || vars.get("$this.value") == thisValueNotValid))
if (vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.OBJECTSELECTION
&& (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW))
{
var entity = vars.getString("$field.DROPDOWNDEFINITION");
var condJson = JSON.stringify({entity: entity, filter: {type: "group", operator: "AND", childs: []}});
result.string(condJson);
var emptyFilter = {entity: entity, filter: {type: "group", operator: "AND", childs: []}};
var currentFilter = vars.get("$this.value");
if (currentFilter)
currentFilter = JSON.parse(currentFilter);
//if the filter field is empty or if the entity was changed, reset the filter
if (!vars.get("$this.value") || currentFilter.entity != emptyFilter.entity)
{
var condJson = JSON.stringify(emptyFilter);
result.string(condJson);
}
}
\ No newline at end of file
......@@ -166,8 +166,12 @@ AttributeUtil.getPossibleListValues = function (pAttributeId, pAttributeType, pI
var config = entities.createConfigForLoadingRows()
.entity(module)
.fields([uid, title]);
if (filter && filter.filter)
config.filter(filter.filter);
if (filter)
{
filter = JSON.parse(filter);
if (filter.filter)
config.filter(JSON.stringify(filter.filter));
}
var rows = entities.getRows(config);
for (let i = 0, l = rows.length; i < l; i++)
objects.push([rows[i][uid], rows[i][title]])
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment