From 4f2025b7e229f14c6694ae1cce301cc29be3d3c6 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Wed, 20 Feb 2019 12:51:44 +0100 Subject: [PATCH] Combobox Attribute --- .../displayValueProcess.js | 20 +-- .../possibleItemsProcess.js | 36 +++--- .../attributerelation_value/valueProcess.js | 54 ++++---- entity/Attribute_entity/Attribute_entity.aod | 1 - .../attribute_name/displayValueProcess.js | 2 +- .../attribute_type/displayValueProcess.js | 24 ++-- .../attribute_type/valueProcess.js | 4 +- .../children/attrparentid_param/code.js | 2 +- .../recordcontainers/db/conditionProcess.js | 2 +- .../ab_keyword_entry/init_AttributeType.xml | 27 +++- process/Attribute_lib/process.js | 118 +++++++++--------- 11 files changed, 152 insertions(+), 138 deletions(-) diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js index 2abb4fdc0d..d335cd62e7 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/displayValueProcess.js @@ -1,11 +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) +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/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js index 5a3b4bd6a7..6aff0255e3 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js @@ -1,19 +1,19 @@ -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) -{ - var valueSql = SqlCondition.begin() - .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId) - .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", AttributeTypes.COMBOVALUE) - .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE"); - var valueList = db.table(valueSql); - - result.object(valueList); +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) +{ + var valueSql = SqlCondition.begin() + .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId) + .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE) + .buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE"); + var valueList = db.table(valueSql); + + result.object(valueList); } \ No newline at end of file diff --git a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js index 6edf4b6ff8..33a878bf68 100644 --- a/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js +++ b/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js @@ -1,28 +1,28 @@ -import("system.result"); -import("system.vars"); -import("Attribute_lib"); - -var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType(); - -if (attrType != null) //load the value from the correct field for the type -{ - switch (attrType) - { - case AttributeTypes.TEXT: - result.string(vars.get("$field.CHAR_VALUE")); - break; - case AttributeTypes.DATE: - result.string(vars.get("$field.DATE_VALUE")); - break; - case AttributeTypes.NUMBER: - result.string(vars.get("$field.NUMBER_VALUE")); - break; - case AttributeTypes.BOOLEAN: - result.string(vars.get("$field.BOOL_VALUE")); - break; - case AttributeTypes.COMBO: - result.string(vars.get("$field.ID_VALUE")); - break; - } - +import("system.result"); +import("system.vars"); +import("Attribute_lib"); + +var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType(); + +if (attrType != null) //load the value from the correct field for the type +{ + switch (attrType) + { + case $AttributeTypes.TEXT: + result.string(vars.get("$field.CHAR_VALUE")); + break; + case $AttributeTypes.DATE: + result.string(vars.get("$field.DATE_VALUE")); + break; + case $AttributeTypes.NUMBER: + result.string(vars.get("$field.NUMBER_VALUE")); + break; + case $AttributeTypes.BOOLEAN: + result.string(vars.get("$field.BOOL_VALUE")); + break; + case $AttributeTypes.COMBO: + result.string(vars.get("$field.ID_VALUE")); + break; + } + } \ No newline at end of file diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 33e1964169..3032d15a7f 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -35,7 +35,6 @@ <title>Parent Attribute</title> <consumer>AttributeChildren</consumer> <linkedContext>Attribute</linkedContext> - <groupable v="true" /> <stateProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js</stateProcess> <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js</valueProcess> <displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js</displayValueProcess> diff --git a/entity/Attribute_entity/entityfields/attribute_name/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_name/displayValueProcess.js index 25d46bcaae..12344946d5 100644 --- a/entity/Attribute_entity/entityfields/attribute_name/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_name/displayValueProcess.js @@ -2,4 +2,4 @@ import("system.vars"); import("system.result"); import("Attribute_lib"); -result.string(AttributeUtil.getAttributeNameById(vars.get("$field.AB_ATTRIBUTEID"))); \ No newline at end of file +result.string(AttributeUtil.getFullAttributeName(vars.get("$field.AB_ATTRIBUTEID"))); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js index 22960d0b70..619f63d8dc 100644 --- a/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js @@ -1,13 +1,13 @@ -import("system.db"); -import("system.neon"); -import("system.result"); -import("system.vars"); -import("Attribute_lib"); -import("Keyword_lib"); - -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") -{ - var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType(); - if (type == AttributeTypes.COMBO) - result.string(KeywordUtils.getViewValue($KeywordRegistry.get.AttributeType, AttributeTypes.COMBOVALUE)); +import("system.db"); +import("system.neon"); +import("system.result"); +import("system.vars"); +import("Attribute_lib"); +import("Keyword_lib"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") +{ + var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType(); + if (type == $AttributeTypes.COMBO) + result.string(KeywordUtils.getViewValue($KeywordRegistry.get.AttributeType, $AttributeTypes.COMBOVALUE)); } \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js index 6dff8bf600..149d8d0591 100644 --- a/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js @@ -7,6 +7,6 @@ import("Attribute_lib"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") { var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType(); - if (type == AttributeTypes.COMBO) - result.string(AttributeTypes.COMBOVALUE); + if (type == $AttributeTypes.COMBO) + result.string($AttributeTypes.COMBOVALUE); } \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js b/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js index 11e081d017..b63cf032dd 100644 --- a/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js +++ b/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js @@ -3,7 +3,7 @@ import("system.result"); import("Attribute_lib"); var type = vars.getString("$field.ATTRIBUTE_TYPE").trim(); -if (type == AttributeTypes.GROUP || type == AttributeTypes.COMBO) +if (type == $AttributeTypes.GROUP || type == $AttributeTypes.COMBO) result.string(vars.getString("$field.AB_ATTRIBUTEID")); else result.string(""); diff --git a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js index f43b26a529..1a5a7ef8aa 100644 --- a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js @@ -4,7 +4,7 @@ import("system.result"); import("Sql_lib"); import("Attribute_lib"); -var condition = "AB_ATTRIBUTE.ATTRIBUTE_TYPE = '" + AttributeTypes.GROUP + "'"; +var condition = "AB_ATTRIBUTE.ATTRIBUTE_TYPE = '" + $AttributeTypes.GROUP + "'"; if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) condition = "AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + getAllChildren(vars.getString("$param.attrParentId_param")).join("','") + "')"; diff --git a/others/db_changes/data_alias/data/AditoBasic/ab_keyword_entry/init_AttributeType.xml b/others/db_changes/data_alias/data/AditoBasic/ab_keyword_entry/init_AttributeType.xml index 958ebbabbf..dfb1c40eea 100644 --- a/others/db_changes/data_alias/data/AditoBasic/ab_keyword_entry/init_AttributeType.xml +++ b/others/db_changes/data_alias/data/AditoBasic/ab_keyword_entry/init_AttributeType.xml @@ -8,7 +8,7 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="0"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <insert tableName="AB_KEYWORD_ENTRY"> <column name="AB_KEYWORD_ENTRYID" value="cb7ecaea-b4e6-460e-9006-4a3d059b9857"/> @@ -17,7 +17,7 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="1"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <insert tableName="AB_KEYWORD_ENTRY"> <column name="AB_KEYWORD_ENTRYID" value="14de196a-aaa6-41b9-b503-3df1d45acc1e"/> @@ -26,7 +26,7 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="2"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <insert tableName="AB_KEYWORD_ENTRY"> <column name="AB_KEYWORD_ENTRYID" value="8a9791c1-655f-4340-91b4-cfdf6372fc75"/> @@ -35,7 +35,7 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="3"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <insert tableName="AB_KEYWORD_ENTRY"> <column name="AB_KEYWORD_ENTRYID" value="1390813c-6b94-4336-9986-9bcaddab69ac"/> @@ -44,7 +44,7 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="4"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <insert tableName="AB_KEYWORD_ENTRY"> <column name="AB_KEYWORD_ENTRYID" value="2c188a17-2961-45df-bd68-34b55352375c"/> @@ -53,7 +53,16 @@ <column name="CONTAINER" value="AttributeType"/> <column name="SORTING" valueNumeric="5"/> <column name="ISACTIVE" valueNumeric="1"/> - <column name="ISESSENTIAL" valueNumeric="0"/> + <column name="ISESSENTIAL" valueNumeric="1"/> + </insert> + <insert tableName="AB_KEYWORD_ENTRY"> + <column name="AB_KEYWORD_ENTRYID" value="75a67526-6b7c-400d-b958-e1f8f45466aa"/> + <column name="KEYID" value="COMBOVALUE"/> + <column name="TITLE" value="Combobox Value"/> + <column name="CONTAINER" value="AttributeType"/> + <column name="SORTING" valueNumeric="6"/> + <column name="ISACTIVE" valueNumeric="1"/> + <column name="ISESSENTIAL" valueNumeric="1"/> </insert> <rollback> <delete tableName="AB_KEYWORD_ENTRY"> @@ -92,6 +101,12 @@ <param value="2c188a17-2961-45df-bd68-34b55352375c"/> </whereParams> </delete> + <delete tableName="AB_KEYWORD_ENTRY"> + <where>AB_KEYWORD_ENTRYID = ?</where> + <whereParams> + <param value="75a67526-6b7c-400d-b958-e1f8f45466aa"/> + </whereParams> + </delete> </rollback> </changeSet> </databaseChangeLog> \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 239006faae..1e1e2a6037 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -31,11 +31,11 @@ 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_TYPE != '" + $AttributeTypes.COMBOVALUE + "'") .and("ATTRIBUTE_ACTIVE = 1"); if (!pIncludeGroups) - attrCond.and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'"); + attrCond.and("ATTRIBUTE_TYPE != '" + $AttributeTypes.GROUP + "'"); var attributes = db.array(db.COLUMN, attrCond.buildSql(attrSql)).map(function (id) { @@ -155,7 +155,7 @@ AttributeHandler.prototype.getAttributeType = function () //TODO: maybe the type */ AttributeHandler.prototype.getAttributeField = function () { - return AttributeTypes.getEntityField(this.getAttributeType()); + return $AttributeTypes.getEntityField(this.getAttributeType()); } /** @@ -165,7 +165,7 @@ AttributeHandler.prototype.getAttributeField = function () */ AttributeHandler.prototype.getAttributeContentType = function () { - return AttributeTypes.getContentType(this.getAttributeType()); + return $AttributeTypes.getContentType(this.getAttributeType()); } AttributeHandler.prototype.setAttributeValue = function (pValue) @@ -189,49 +189,49 @@ AttributeHandler.prototype.setAttributeValue = function (pValue) * * The display name is controlled by the keyword 'AttributeType' */ -var AttributeTypes = { - TEXT : { - toString : function () {return "TEXT"}, - contentType : "TEXT", - databaseField : "CHAR_VALUE", - entityField : "CHAR_VALUE" - }, - DATE : { - toString : function () {return "DATE"}, - contentType : "DATE", - databaseField : "DATE_VALUE", - entityField : "DATE_VALUE" - }, - NUMBER : { - toString : function () {return "NUMBER"}, - contentType : "NUMBER", - databaseField : "NUMBER_VALUE", - entityField : "NUMBER_VALUE" - }, - BOOLEAN : { - toString : function () {return "BOOLEAN"}, - contentType : "BOOLEAN", - databaseField : "BOOL_VALUE", - entityField : "BOOL_VALUE" - }, - COMBO : { - toString : function () {return "COMBO"}, - contentType : "TEXT", - databaseField : "ID_VALUE", - entityField : "ID_VALUE" - }, - COMBOVALUE : { - toString : function () {return "COMBOVALUE"}, - contentType : null, - databaseField : null, - entityField : null - }, - GROUP : { - toString : function () {return "GROUP"}, - contentType : null, - databaseField : null, - entityField : null - } +function $AttributeTypes () {} + +$AttributeTypes.TEXT = { + toString : function () {return "TEXT"}, + contentType : "TEXT", + databaseField : "CHAR_VALUE", + entityField : "CHAR_VALUE" +}; +$AttributeTypes.DATE = { + toString : function () {return "DATE"}, + contentType : "DATE", + databaseField : "DATE_VALUE", + entityField : "DATE_VALUE" +}; +$AttributeTypes.NUMBER = { + toString : function () {return "NUMBER"}, + contentType : "NUMBER", + databaseField : "NUMBER_VALUE", + entityField : "NUMBER_VALUE" +}; +$AttributeTypes.BOOLEAN = { + toString : function () {return "BOOLEAN"}, + contentType : "BOOLEAN", + databaseField : "BOOL_VALUE", + entityField : "BOOL_VALUE" +}; +$AttributeTypes.COMBO = { + toString : function () {return "COMBO"}, + contentType : "TEXT", + databaseField : "ID_VALUE", + entityField : "ID_VALUE" +}; +$AttributeTypes.COMBOVALUE = { + toString : function () {return "COMBOVALUE"}, + contentType : null, + databaseField : null, + entityField : null +}; +$AttributeTypes.GROUP = { + toString : function () {return "GROUP"}, + contentType : null, + databaseField : null, + entityField : null }; @@ -242,10 +242,10 @@ var AttributeTypes = { * (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT) * @return {String} the contentType for the attribute */ -AttributeTypes.getContentType = function (pAttributeType) +$AttributeTypes.getContentType = function (pAttributeType) { - if (pAttributeType in AttributeTypes) - return AttributeTypes[pAttributeType].contentType; + if (pAttributeType in $AttributeTypes) + return $AttributeTypes[pAttributeType].contentType; return null; } @@ -256,10 +256,10 @@ AttributeTypes.getContentType = function (pAttributeType) * (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT) * @return {String} the field for the attribute */ -AttributeTypes.getEntityField = function (pAttributeType) +$AttributeTypes.getEntityField = function (pAttributeType) { - if (pAttributeType in AttributeTypes) - return AttributeTypes[pAttributeType].entityField; + if (pAttributeType in $AttributeTypes) + return $AttributeTypes[pAttributeType].entityField; return null; } @@ -270,10 +270,10 @@ AttributeTypes.getEntityField = function (pAttributeType) * (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT) * @return {String} the database field for the attribute */ -AttributeTypes.getDatabaseField = function (pAttributeType) +$AttributeTypes.getDatabaseField = function (pAttributeType) { - if (pAttributeType in AttributeTypes) - return AttributeTypes[pAttributeType].databaseField; + if (pAttributeType in $AttributeTypes) + return $AttributeTypes[pAttributeType].databaseField; return null; } @@ -284,9 +284,9 @@ AttributeTypes.getDatabaseField = function (pAttributeType) * (use the values of the AttributeTypes object, e. g. AttributeTypes.TEXT) * @return {String} the name the attribute */ -AttributeTypes.getName = function (pAttributeType) +$AttributeTypes.getName = function (pAttributeType) { - if (pAttributeType in AttributeTypes) - return translate.text(AttributeTypes[pAttributeType].displayName); + if (pAttributeType in $AttributeTypes) + return translate.text($AttributeTypes[pAttributeType].displayName); return null; } -- GitLab