From ef7b6d29687cb321f56e2fb17baa16bb93beb517 Mon Sep 17 00:00:00 2001 From: Johannes Hoermann <j.hoermann@adito.de> Date: Mon, 3 Jun 2019 16:25:03 +0200 Subject: [PATCH] fix unfiltered attributes-usage --- entity/Address_entity/Address_entity.aod | 2 ++ .../recordcontainers/jdito/contentProcess.js | 3 ++- .../recordcontainers/jdito/onInsert.js | 3 +++ .../recordcontainers/jdito/contentProcess.js | 24 +++++++++++-------- .../_____PREFERENCES_PROJECT.aod | 6 ++--- 5 files changed, 24 insertions(+), 14 deletions(-) diff --git a/entity/Address_entity/Address_entity.aod b/entity/Address_entity/Address_entity.aod index a0a7f3e02d..c33c1ae417 100644 --- a/entity/Address_entity/Address_entity.aod +++ b/entity/Address_entity/Address_entity.aod @@ -39,6 +39,7 @@ <entityField> <name>CITY</name> <title>City</title> + <consumer>CityValidation</consumer> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/city/mandatoryProcess.js</mandatoryProcess> <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/city/displayValueProcess.js</displayValueProcess> <onValueChange>%aditoprj%/entity/Address_entity/entityfields/city/onValueChange.js</onValueChange> @@ -76,6 +77,7 @@ <entityField> <name>ZIP</name> <title>Postcode</title> + <consumer>ZipValidation</consumer> <mandatoryProcess>%aditoprj%/entity/Address_entity/entityfields/zip/mandatoryProcess.js</mandatoryProcess> <displayValueProcess>%aditoprj%/entity/Address_entity/entityfields/zip/displayValueProcess.js</displayValueProcess> <onValueChange>%aditoprj%/entity/Address_entity/entityfields/zip/onValueChange.js</onValueChange> diff --git a/entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js b/entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js index e559a74fcf..cf0aff000c 100644 --- a/entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/AttributeRelation_entity/recordcontainers/jdito/contentProcess.js @@ -59,6 +59,7 @@ else if (showEmpty || rowId) } if (vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param")) { + logging.log("------------------------ " + vars.getString("$param.FilteredAttributeIds_param") ) let filteredIds = JSON.parse(vars.getString("$param.FilteredAttributeIds_param")); logging.log(filteredIds.toSource()) @@ -69,7 +70,7 @@ else if (showEmpty || rowId) { this.orPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", id); }, subCondition); - + // return nothing if filteredAttributeIds is an empty array. (--> and 1=2) sqlCondition.andSqlCondition(subCondition, "1=2"); } diff --git a/entity/AttributeRelation_entity/recordcontainers/jdito/onInsert.js b/entity/AttributeRelation_entity/recordcontainers/jdito/onInsert.js index 783ef19d53..2bec300e90 100644 --- a/entity/AttributeRelation_entity/recordcontainers/jdito/onInsert.js +++ b/entity/AttributeRelation_entity/recordcontainers/jdito/onInsert.js @@ -1,3 +1,4 @@ +import("system.logging"); import("system.datetime"); import("system.util"); import("system.db"); @@ -14,6 +15,8 @@ var columns = [ ]; var uid = vars.get("$field.UID"); +logging.log(uid) +logging.log(vars.get("$param.ObjectRowId_param")) var values = [ uid[0] == "," ? uid.substr(1) : uid, // if first char is "," it is a newly generated UUID vars.get("$field.AB_ATTRIBUTE_ID"), diff --git a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js index efe182d5df..9f4ea8e69b 100644 --- a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js @@ -50,18 +50,22 @@ else if (getGroups) //if getGroups == true, it is the lookup for selecting the s else if (objectType) //if there's an objectType, it comes from the AttributeRelation entity { logging.log(vars.get("$param.FilteredAttributeIds_param")) + var filteredAttributes = null; + if (vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param")) { - var filteredAttributes = JSON.parse(vars.getString("$param.FilteredAttributeIds_param")); - var attributeCount; - if (vars.exists("$param.AttributeCount_param") && vars.get("$param.AttributeCount_param")) - attributeCount = JSON.parse(vars.getString("$param.AttributeCount_param")); - var ids = AttributeUtil.getPossibleAttributes(objectType, false, filteredAttributes, attributeCount); - - if (filteredAttributes.length > 0) - condition.and("SELF.AB_ATTRIBUTEID in ('" + ids.join("','") + "')"); - else // do not return anything, if parameter is there but an empty array - condition.and("1=2"); + filteredAttributes = JSON.parse(vars.getString("$param.FilteredAttributeIds_param")); } + + var attributeCount; + if (vars.exists("$param.AttributeCount_param") && vars.get("$param.AttributeCount_param")) + attributeCount = JSON.parse(vars.getString("$param.AttributeCount_param")); + var ids = AttributeUtil.getPossibleAttributes(objectType, false, filteredAttributes, attributeCount); + + if (ids.length > 0) + condition.and("SELF.AB_ATTRIBUTEID in ('" + ids.join("','") + "')"); + else if (filteredAttributes != null) // do not return anything, if parameter is there but an empty array + condition.and("1=2"); + } else if (parentType) diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index b92c9d977f..8fefbd4dbf 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -39,7 +39,7 @@ <customProperties> <customBooleanProperty> <name>addressValidation.enable</name> - <property v="false" /> + <property v="true" /> </customBooleanProperty> <customStringProperty> <name>addressValidation.url</name> @@ -59,7 +59,7 @@ </customStringProperty> <customBooleanProperty> <name>zipCityValidation.enable</name> - <property v="false" /> + <property v="true" /> </customBooleanProperty> <customStringProperty> <name>zipCityValidation.url</name> @@ -80,7 +80,7 @@ <customBooleanProperty> <name>phoneValidation.enable</name> <description></description> - <property v="false" /> + <property v="true" /> </customBooleanProperty> <customStringProperty> <name>phoneValidation.url</name> -- GitLab