From 2c5b96991893405ae6b25771ce789c01c83cca61 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Tue, 19 Feb 2019 15:38:39 +0100 Subject: [PATCH] Combobox Attribute -> Anzeige gefixt --- .../AttributeRelation_entity.aod | 1 + .../displayValueProcess.js | 11 ++++++++ .../displayValueProcess.js | 2 +- process/Attribute_lib/process.js | 28 +++++++++++++++---- 4 files changed, 36 insertions(+), 6 deletions(-) create mode 100644 entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js diff --git a/entity/AttributeRelation_entity/AttributeRelation_entity.aod b/entity/AttributeRelation_entity/AttributeRelation_entity.aod index a9171ba77e..c13c98c8e8 100644 --- a/entity/AttributeRelation_entity/AttributeRelation_entity.aod +++ b/entity/AttributeRelation_entity/AttributeRelation_entity.aod @@ -36,6 +36,7 @@ <resolution>DAY</resolution> <possibleItemsProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js</possibleItemsProcess> <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js</valueProcess> + <displayValueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js</displayValueProcess> <onValueChange>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js</onValueChange> </entityField> <entityField> diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js new file mode 100644 index 0000000000..2abb4fdc0d --- /dev/null +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js @@ -0,0 +1,11 @@ +import("system.db"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); +import("Sql_lib"); + +var attributeId = vars.get("$field.AB_ATTRIBUTE_ID"); +var attrType = AttributeHandler.begin(attributeId).getAttributeType(); + +if (attrType == AttributeTypes.COMBO) + result.string(AttributeUtil.getSimpleAttributeName(vars.get("$field.ID_VALUE"))); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js index c220255e0c..1777b7dcc5 100644 --- a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js @@ -2,4 +2,4 @@ import("system.result"); import("system.vars"); import("Attribute_lib"); -result.string(AttributeUtil.getAttributeNameById(vars.get("$field.ATTRIBUTE_PARENT_ID"))) \ No newline at end of file +result.string(AttributeUtil.getSimpleAttributeName(vars.get("$field.ATTRIBUTE_PARENT_ID"))) \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index dac5966054..239006faae 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -31,6 +31,7 @@ AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups) + " join AB_ATTRIBUTEUSAGE on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID"; attrCond = SqlCondition.begin() .andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType) + .and("ATTRIBUTE_TYPE != '" + AttributeTypes.COMBOVALUE + "'") .and("ATTRIBUTE_ACTIVE = 1"); if (!pIncludeGroups) @@ -38,19 +39,19 @@ AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups) var attributes = db.array(db.COLUMN, attrCond.buildSql(attrSql)).map(function (id) { - return [id, AttributeUtil.getAttributeNameById(id)]; + return [id, AttributeUtil.getFullAttributeName(id)]; }); return attributes; } /** - * returns the name of an attribute + * returns the name of an attribute with all parent attribute names * * @param {String} pAttributeId the id of the attribute * * @return {String} the name of the attribute */ -AttributeUtil.getAttributeNameById = function (pAttributeId) +AttributeUtil.getFullAttributeName = function (pAttributeId) { var attributeNames = []; var attribute; @@ -59,9 +60,9 @@ AttributeUtil.getAttributeNameById = function (pAttributeId) attribute = db.array(db.ROW, SqlCondition.begin() .andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", pAttributeId, "# = ?", idType) .buildSql("select ATTRIBUTE_NAME, ATTRIBUTE_PARENT_ID from AB_ATTRIBUTE") - ); + ); if (attribute.length > 0) - { + { attributeNames.push(attribute[0]); pAttributeId = attribute[1]; } @@ -72,6 +73,23 @@ AttributeUtil.getAttributeNameById = function (pAttributeId) return attributeNames.reverse().join(" / "); } +/** + * returns the name of an attribute + * + * @param {String} pAttributeId the id of the attribute + * + * @return {String} the name of the attribute + */ +AttributeUtil.getSimpleAttributeName = function (pAttributeId) +{ + var attributeName = db.cell(SqlCondition.begin() + .andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", pAttributeId) + .buildSql("select ATTRIBUTE_NAME from AB_ATTRIBUTE") + ); + + return attributeName; +} + /** * gets the value of an attribute for one dataset (e. g. a person) */ -- GitLab