diff --git a/aliasDefinition/Data_alias/Data_alias.aod b/aliasDefinition/Data_alias/Data_alias.aod index aec18dc8411f79531fb688eb177365074ebf16b3..e40e586a51d7fbc4136cf571cbcdf6087a6c9562 100644 --- a/aliasDefinition/Data_alias/Data_alias.aod +++ b/aliasDefinition/Data_alias/Data_alias.aod @@ -3939,6 +3939,20 @@ <title></title> <description></description> </entityFieldDb> + <entityFieldDb> + <name>ATTRIBUTE_LEVEL</name> + <dbName></dbName> + <primaryKey v="false" /> + <columnType v="4" /> + <size v="10" /> + <scale v="0" /> + <notNull v="true" /> + <isUnique v="false" /> + <index v="false" /> + <documentation></documentation> + <title></title> + <description></description> + </entityFieldDb> </entityFields> </entityDb> <entityDb> diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 78bf584f6a1129b21d805f2e4141b7166ea4a1f4..255b79b1283658afabaf08f91c44d48adeb6e1cd 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -14,6 +14,7 @@ <name>ATTRIBUTE_NAME</name> <title>Name</title> <mandatory v="true" /> + <state>EDITABLE</state> <displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_name/displayValueProcess.js</displayValueProcess> </entityField> <entityField> @@ -51,6 +52,12 @@ <triggerRecalculation v="true" /> <mandatory v="false" /> </entityParameter> + <entityParameter> + <name>attributeLevel_param</name> + <code>%aditoprj%/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js</code> + <triggerRecalculation v="true" /> + <mandatory v="false" /> + </entityParameter> </children> </entityConsumer> <entityProvider> @@ -110,12 +117,22 @@ </entityParameter> </children> </entityConsumer> + <entityParameter> + <name>attributeLevel_param</name> + <expose v="true" /> + <description>PARAMETER</description> + </entityParameter> + <entityField> + <name>ATTRIBUTE_LEVEL</name> + <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js</valueProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> <name>db</name> <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Attribute_entity/recordcontainers/db/conditionProcess.js</conditionProcess> + <orderClauseProcess>%aditoprj%/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess> <onDBDelete>%aditoprj%/entity/Attribute_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> @@ -150,6 +167,10 @@ <name>ATTRIBUTE_NAME.value</name> <recordfield>AB_ATTRIBUTE.ATTRIBUTE_NAME</recordfield> </dbRecordFieldMapping> + <dbRecordFieldMapping> + <name>ATTRIBUTE_LEVEL.value</name> + <recordfield>AB_ATTRIBUTE.ATTRIBUTE_LEVEL</recordfield> + </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> </recordContainers> diff --git a/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..8e8d195242aa5735e81a244fedec148bcf5184cb --- /dev/null +++ b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js @@ -0,0 +1,11 @@ +import("system.neon"); +import("system.logging"); +import("system.result"); +import("system.vars"); + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + if (vars.exists("$param.attributeLevel_param") && vars.get("$param.attributeLevel_param") + && vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) + result.string(parseInt(vars.get("$param.attributeLevel_param")) + 1); + else + result.string("0"); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js b/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js new file mode 100644 index 0000000000000000000000000000000000000000..5790e0cc445659af95e472d70969cf8ac3d0394a --- /dev/null +++ b/entity/Attribute_entity/entityfields/attributechildren/children/attributelevel_param/code.js @@ -0,0 +1,4 @@ +import("system.vars"); +import("system.result"); + +result.string(vars.getString("$field.ATTRIBUTE_LEVEL")); \ 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 8ab4e3f8c3ff494e56f4617c5a004388b5cdc589..ae1a8f6dd3a557c43beae2a4afff19fdc265c3d5 100644 --- a/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js +++ b/entity/Attribute_entity/entityfields/attributechildren/children/attrparentid_param/code.js @@ -1,4 +1,8 @@ import("system.vars"); import("system.result"); +import("Attribute_lib"); -result.string(vars.getString("$field.AB_ATTRIBUTEID")); \ No newline at end of file +if (vars.getString("$field.ATTRIBUTE_TYPE").trim() == AttributeTypes.GROUP) + result.string(vars.getString("$field.AB_ATTRIBUTEID")); +else + result.string(""); \ No newline at end of file diff --git a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js index e9da10cf919b6044f3fd76a89e4be23741837ad1..2ba6046ff95f8c4b734f46de7971f8f875588ae8 100644 --- a/entity/Attribute_entity/recordcontainers/db/conditionProcess.js +++ b/entity/Attribute_entity/recordcontainers/db/conditionProcess.js @@ -1,8 +1,29 @@ +import("system.db"); import("system.vars"); import("system.result"); import("Sql_lib"); +var condition = "1=2"; + if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) - result.string("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID = '" + vars.getString("$param.attrParentId_param") + "'"); -else - result.string("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID is null"); \ No newline at end of file + condition = "AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + getAllChildren(vars.getString("$param.attrParentId_param")).join("','") + "')"; +else if (vars.get("$param.attrParentId_param") !== "") + condition = ""; + +result.string(condition); + +function getAllChildren (pAttributeId) +{ + var childIds = []; + var attributes= [pAttributeId]; + while (attributes.length > 0) + { + attributes = db.array(db.COLUMN, SqlCondition.begin() + .and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')") + .buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE") + ); + if (attributes.length > 0) + childIds = childIds.concat(attributes); + } + return childIds; +} \ No newline at end of file diff --git a/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js b/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js new file mode 100644 index 0000000000000000000000000000000000000000..7d38fd890e1751c5be85767520d81e8e362bbab3 --- /dev/null +++ b/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js @@ -0,0 +1,3 @@ +import("system.db"); +import("system.result"); +result.object({"AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING}); \ No newline at end of file diff --git a/neonView/AttributeFilter_view/AttributeFilter_view.aod b/neonView/AttributeFilter_view/AttributeFilter_view.aod index c3090529d6cd218b1fe2662d9930498bb9a1d86e..f832fe72dc58882788636fa74e9e1bf3e4aaa412 100644 --- a/neonView/AttributeFilter_view/AttributeFilter_view.aod +++ b/neonView/AttributeFilter_view/AttributeFilter_view.aod @@ -5,25 +5,17 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <filterable v="true" /> <layout> - <boxLayout> + <groupLayout> <name>layout</name> - </boxLayout> + </groupLayout> </layout> <children> - <tableViewTemplate> - <name>Table_template</name> + <treetableViewTemplate> + <name>Treetable</name> + <parentField>ATTRIBUTE_PARENT_ID</parentField> + <titleField>ATTRIBUTE_NAME</titleField> + <descriptionField>ATTRIBUTE_TYPE</descriptionField> <entityField>#ENTITY</entityField> - <title>Attributes</title> - <columns> - <neonTableColumn> - <name>a8065137-406d-49ea-9ebf-a04fbecba2fb</name> - <entityField>ATTRIBUTE_NAME</entityField> - </neonTableColumn> - <neonTableColumn> - <name>054d2c18-8434-4a47-bc0d-c8782f4d1a8f</name> - <entityField>ATTRIBUTE_TYPE</entityField> - </neonTableColumn> - </columns> - </tableViewTemplate> + </treetableViewTemplate> </children> </neonView> diff --git a/neonView/AttributeMain_view/AttributeMain_view.aod b/neonView/AttributeMain_view/AttributeMain_view.aod index 657bbd1e9b0995bdcc9a05b76b51e69da409ce36..b1260d0fc2779dd3459da486b41116a939784cd7 100644 --- a/neonView/AttributeMain_view/AttributeMain_view.aod +++ b/neonView/AttributeMain_view/AttributeMain_view.aod @@ -15,9 +15,9 @@ <view>AttributePreview_view</view> </neonViewReference> <neonViewReference> - <name>634c58b7-74db-42d3-a90c-029678e4fed4</name> + <name>981059c6-2f57-4c6b-86bb-45e5a0a8f138</name> <entityField>AttributeChildren</entityField> - <view>AttributeTree_view</view> + <view>AttributeFilter_view</view> </neonViewReference> <neonViewReference> <name>5dee1c0b-c670-4eb9-bd95-6f6474709aa2</name> diff --git a/neonView/AttributePreview_view/AttributePreview_view.aod b/neonView/AttributePreview_view/AttributePreview_view.aod index bcf16f07c694083818309d56f0ce92cbb61f7b60..bfab935dbe502f6c0453a6fcfeac9bd21856f143 100644 --- a/neonView/AttributePreview_view/AttributePreview_view.aod +++ b/neonView/AttributePreview_view/AttributePreview_view.aod @@ -14,5 +14,17 @@ <subtitleField>ATTRIBUTE_TYPE</subtitleField> <entityField>#ENTITY</entityField> </cardViewTemplate> + <genericViewTemplate> + <name>Generic</name> + <showDrawer v="true" /> + <entityField>#ENTITY</entityField> + <title></title> + <fields> + <entityFieldLink> + <name>e00bfeb1-7003-4d5a-b71a-c6921e255c9d</name> + <entityField>ATTRIBUTE_ACTIVE</entityField> + </entityFieldLink> + </fields> + </genericViewTemplate> </children> </neonView> diff --git a/others/db_changes/data_alias/struct/AditoBasic/create_ab_attribute.xml b/others/db_changes/data_alias/struct/AditoBasic/create_ab_attribute.xml index ff749c09fdc8d86a5b9b9b2b608dbe17640f9a39..c9ec02e4aedba03ecf96d4ecc98d541d951ce740 100644 --- a/others/db_changes/data_alias/struct/AditoBasic/create_ab_attribute.xml +++ b/others/db_changes/data_alias/struct/AditoBasic/create_ab_attribute.xml @@ -16,6 +16,9 @@ <column name="ATTRIBUTE_ACTIVE" type="TINYINT"> <constraints nullable="false"/> </column> + <column name="ATTRIBUTE_LEVEL" type="INTEGER"> + <constraints nullable="false"/> + </column> </createTable> </changeSet> </databaseChangeLog> \ No newline at end of file diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index bb03b95f164fbbacc77ed981a1d7f4e40efc4718..1397c6e86ec020ed0d186377e5adba7dec678f9d 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -26,14 +26,19 @@ AttributeUtil.getPossibleAttributes = function (pObjectType) if (pObjectType == null) return []; - var attrSql = "select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE" + var attrSql = "select AB_ATTRIBUTEID from AB_ATTRIBUTE" + " join AB_ATTRIBUTEUSAGE on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID"; attrSql = SqlCondition.begin() .andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType) + .and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'") .and("ATTRIBUTE_ACTIVE = 1") .buildSql(attrSql); - - return db.table(attrSql); + + var attributes = db.array(db.COLUMN, attrSql).map(function (id) + { + return [id, AttributeUtil.getAttributeNameById(id)]; + }); + return attributes; } /** @@ -47,20 +52,21 @@ AttributeUtil.getAttributeNameById = function (pAttributeId) { var attributeNames = []; var attribute; + var idType = SqlUtils.getSingleColumnType("AB_ATTRIBUTE.AB_ATTRIBUTEID"); do { attribute = db.array(db.ROW, SqlCondition.begin() - .andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", pAttributeId) + .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]; } else pAttributeId = ""; } while (pAttributeId); - + return attributeNames.reverse().join(" / "); }