diff --git a/entity/AttributeRelation_entity/entityfields/value/onValidation.js b/entity/AttributeRelation_entity/entityfields/value/onValidation.js index d2f774193b62a68cfde69f37ce3ee9b740f1ac3c..81af77d1176502b787ed26e0cb8845f754ec87dc 100644 --- a/entity/AttributeRelation_entity/entityfields/value/onValidation.js +++ b/entity/AttributeRelation_entity/entityfields/value/onValidation.js @@ -1,12 +1,25 @@ +import("system.translate"); import("Util_lib"); import("system.result"); import("system.vars"); import("Attribute_lib"); +if(vars.get("$field.AB_ATTRIBUTE_ID") && !AttributeRelationUtils.validateSingleCount( + vars.get("$param.ObjectType_param"), + vars.get("$param.ObjectRowId_param"), + vars.get("$field.AB_ATTRIBUTE_ID") +)) { + result.string(translate.text("Invalid attribute count")); +} +else +{ var attributeType = AttributeTypes.get(vars.get("$field.ATTRIBUTE_TYPE")); if (attributeType && !attributeType.useLookup) { var validationResult = attributeType.validateValue(vars.get("$local.value"), Utils.parseJSON(vars.get("$field.VALIDATIONPARAMETERS"))); if (validationResult && validationResult !== true) + { result.string(validationResult); + } +} } \ No newline at end of file diff --git a/entity/AttributeRelation_entity/entityfields/value_lookup/onValidation.js b/entity/AttributeRelation_entity/entityfields/value_lookup/onValidation.js index 26590927b278e6a71b75d42c2f5e9d5a4b5da26e..38d6db89efb9db9a63dcd3c508e5dd25bb3f9e3d 100644 --- a/entity/AttributeRelation_entity/entityfields/value_lookup/onValidation.js +++ b/entity/AttributeRelation_entity/entityfields/value_lookup/onValidation.js @@ -1,12 +1,25 @@ +import("system.translate"); import("Util_lib"); import("system.result"); import("system.vars"); import("Attribute_lib"); +if(vars.get("$field.AB_ATTRIBUTE_ID") && !AttributeRelationUtils.validateSingleCount( + vars.get("$param.ObjectType_param"), + vars.get("$param.ObjectRowId_param"), + vars.get("$field.AB_ATTRIBUTE_ID") +)) { + result.string(translate.text("Invalid attribute count")); +} +else +{ var attributeType = AttributeTypes.get(vars.get("$field.ATTRIBUTE_TYPE")); if (attributeType && attributeType.useLookup) { var validationResult = attributeType.validateValue(vars.get("$local.value"), Utils.parseJSON(vars.get("$field.VALIDATIONPARAMETERS"))); if (validationResult && validationResult !== true) + { result.string(validationResult); -} \ No newline at end of file + } +} +} diff --git a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod index eb5f6d899382563d9994fb31fb5e1d158f76c1b1..cb3fe32e32ad5ed8bbc107b2cd0843472021dd49 100644 --- a/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod +++ b/language/_____LANGUAGE_EXTRA/_____LANGUAGE_EXTRA.aod @@ -8214,6 +8214,36 @@ <entry> <key>Shows the new daily Covid Cases</key> </entry> + <entry> + <key>Shows the global Covid Cases in a Table</key> + </entry> + <entry> + <key>Buyer</key> + </entry> + <entry> + <key>Internal responsible</key> + </entry> + <entry> + <key>Global Cases Table</key> + </entry> + <entry> + <key>Global Cases</key> + </entry> + <entry> + <key>Initiator</key> + </entry> + <entry> + <key>New Cases</key> + </entry> + <entry> + <key>Internal Sales</key> + </entry> + <entry> + <key>Influencer</key> + </entry> + <entry> + <key>Shows the new daily Covid Cases</key> + </entry> </keyValueMap> <font name="Dialog" style="0" size="11" /> <sqlModels> diff --git a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod index 29b9146ab17b441881641ec0ef4e704891e4fc25..cf46e6ae2e0492e8d3babcb600aed6f008a9e9a0 100644 --- a/language/_____LANGUAGE_de/_____LANGUAGE_de.aod +++ b/language/_____LANGUAGE_de/_____LANGUAGE_de.aod @@ -10789,6 +10789,10 @@ Bitte Datumseingabe prüfen</value> <key>Internal responsible</key> <value>Intern: Gebietsverantwortlich</value> </entry> + <entry> + <key>Invalid attribute count</key> + <value>Unzulässige Attributanzahl</value> + </entry> <entry> <key>Set not completed</key> <value>Nicht erledigt setzen</value> diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 7d900715602b77d44d300fd575a1ba088fed6f1e..f7ed889c7010152235989623fecc09548a9abb04 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -808,6 +808,30 @@ AttributeRelationUtils.countAttributeRelations = function (pRowId, pObjectType, return countObj; } +/** + * Checks weather the passed attribute can be added to the given object using the min and max count. + * + * @param {string} pObjectType the object type + * @param {string} pObjectRowId the id of the object + * @param {string} pAttributeId the attribute witch needs to be validated + * + * @returns {boolean} weather it is valid to add the attribute or not + */ +AttributeRelationUtils.validateSingleCount = function(pObjectType, pObjectRowId, pAttributeId) +{ + var [min, max] = newSelect(["AB_ATTRIBUTEUSAGE.MIN_COUNT", "AB_ATTRIBUTEUSAGE.MAX_COUNT"]) + .from("AB_ATTRIBUTEUSAGE") + .where("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", pAttributeId) + .and("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType).arrayRow(); + var attrCount = AttributeRelationUtils.countAttributeRelations( + pObjectRowId, + pObjectType, + {} + ); + var count = attrCount[vars.get("$field.AB_ATTRIBUTE_ID")] || 0; + return count >= parseInt(min || -Infinity) && count <= parseInt(max || Infinity); +} + /*********************************************************************************************************************/