From d03439ba2c820a0f8e61d29975987c2169797b59 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Tue, 19 Feb 2019 10:21:50 +0100 Subject: [PATCH] Attribute groups --- entity/Attribute_entity/Attribute_entity.aod | 5 +++ .../attribute_level/valueProcess.js | 3 +- .../displayValueProcess.js | 2 ++ .../attribute_parent_id/stateProcess.js | 11 +++++++ .../attribute_parent_id/valueProcess.js | 1 - .../recordcontainers/db/onDBInsert.js | 31 +++++++++++++++++++ .../AttributeEdit_view/AttributeEdit_view.aod | 4 +++ .../AttributePreview_view.aod | 4 +++ .../AttributeUsageFilter_view.aod | 9 +----- .../AttributeUsageMultiEdit_view.aod | 12 ------- 10 files changed, 59 insertions(+), 23 deletions(-) create mode 100644 entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js create mode 100644 entity/Attribute_entity/recordcontainers/db/onDBInsert.js diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index c822242ce8..6a7b129788 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -33,6 +33,7 @@ <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> </entityField> @@ -130,6 +131,9 @@ </entityParameter> <entityField> <name>ATTRIBUTE_LEVEL</name> + <title>Level</title> + <contentType>NUMBER</contentType> + <state>INVISIBLE</state> <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js</valueProcess> </entityField> </entityFields> @@ -139,6 +143,7 @@ <alias>Data_alias</alias> <conditionProcess>%aditoprj%/entity/Attribute_entity/recordcontainers/db/conditionProcess.js</conditionProcess> <orderClauseProcess>%aditoprj%/entity/Attribute_entity/recordcontainers/db/orderClauseProcess.js</orderClauseProcess> + <onDBInsert>%aditoprj%/entity/Attribute_entity/recordcontainers/db/onDBInsert.js</onDBInsert> <onDBDelete>%aditoprj%/entity/Attribute_entity/recordcontainers/db/onDBDelete.js</onDBDelete> <linkInformation> <linkInformation> diff --git a/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js index 8e8d195242..5098441456 100644 --- a/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_level/valueProcess.js @@ -1,5 +1,4 @@ import("system.neon"); -import("system.logging"); import("system.result"); import("system.vars"); @@ -8,4 +7,4 @@ if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) && 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 + result.string("0"); diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js index 9f1862b572..24c340a034 100644 --- a/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_parent_id/displayValueProcess.js @@ -5,3 +5,5 @@ import("Attribute_lib"); if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) result.string(AttributeUtil.getAttributeNameById(vars.get("$param.attrParentId_param"))); +else + result.string(AttributeUtil.getAttributeNameById(vars.get("$field.ATTRIBUTE_PARENT_ID"))) \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js new file mode 100644 index 0000000000..876969048d --- /dev/null +++ b/entity/Attribute_entity/entityfields/attribute_parent_id/stateProcess.js @@ -0,0 +1,11 @@ +import("system.result"); +import("system.neon"); +import("system.vars"); + +var fieldState; +if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) + fieldState = neon.COMPONENTSTATE_AUTO; +else + fieldState = neon.COMPONENTSTATE_READONLY; + +result.string(fieldState); \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js index 6698c1cd9b..331013e78c 100644 --- a/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_parent_id/valueProcess.js @@ -1,5 +1,4 @@ import("system.neon"); -import("system.logging"); import("system.result"); import("system.vars"); diff --git a/entity/Attribute_entity/recordcontainers/db/onDBInsert.js b/entity/Attribute_entity/recordcontainers/db/onDBInsert.js new file mode 100644 index 0000000000..4d04bd35a2 --- /dev/null +++ b/entity/Attribute_entity/recordcontainers/db/onDBInsert.js @@ -0,0 +1,31 @@ +import("system.db"); +import("system.neon"); +import("system.result"); +import("system.vars"); +import("system.util"); +import("Sql_lib"); + +if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) +{ + var parentId = vars.get("$param.attrParentId_param"); + var attributeId = vars.get("$field.AB_ATTRIBUTEID"); + var cols = [ + "AB_ATTRIBUTEUSAGEID", + "OBJECT_TYPE", + "AB_ATTRIBUTE_ID" + ]; + var usageSql = SqlCondition.begin() + .andPrepare("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", parentId) + .buildSql("select " + cols.join(", ") + " from AB_ATTRIBUTEUSAGE", "1=0"); + var usages = db.table(usageSql); + + var table = "AB_ATTRIBUTEUSAGE"; + var types = db.getColumnTypes(table, cols); + + var toInsert = usages.map(function (row) + { + return [table, cols, types, [util.getNewUUID(), row[1], attributeId]]; + }); + + db.inserts(toInsert); +} \ No newline at end of file diff --git a/neonView/AttributeEdit_view/AttributeEdit_view.aod b/neonView/AttributeEdit_view/AttributeEdit_view.aod index e68bf0bc07..bae017aaf8 100644 --- a/neonView/AttributeEdit_view/AttributeEdit_view.aod +++ b/neonView/AttributeEdit_view/AttributeEdit_view.aod @@ -29,6 +29,10 @@ <name>d26696ac-199c-45f0-9147-b75dee3f4b65</name> <entityField>ATTRIBUTE_ACTIVE</entityField> </entityFieldLink> + <entityFieldLink> + <name>c8a5f45e-8092-45f4-ac22-681700447235</name> + <entityField>ATTRIBUTE_LEVEL</entityField> + </entityFieldLink> </fields> </genericViewTemplate> <neonViewReference> diff --git a/neonView/AttributePreview_view/AttributePreview_view.aod b/neonView/AttributePreview_view/AttributePreview_view.aod index 58359b8d75..59adbab341 100644 --- a/neonView/AttributePreview_view/AttributePreview_view.aod +++ b/neonView/AttributePreview_view/AttributePreview_view.aod @@ -24,6 +24,10 @@ <name>e00bfeb1-7003-4d5a-b71a-c6921e255c9d</name> <entityField>ATTRIBUTE_ACTIVE</entityField> </entityFieldLink> + <entityFieldLink> + <name>00a51564-0eca-43f9-8235-b811df1dbafd</name> + <entityField>ATTRIBUTE_LEVEL</entityField> + </entityFieldLink> </fields> </genericViewTemplate> </children> diff --git a/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod b/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod index ebd9d7f89a..eeb1eed20e 100644 --- a/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod +++ b/neonView/AttributeUsageFilter_view/AttributeUsageFilter_view.aod @@ -11,20 +11,13 @@ <children> <tableViewTemplate> <name>UsageTable_template</name> + <autoNewRow v="true" /> <entityField>#ENTITY</entityField> <columns> <neonTableColumn> <name>ba8d5468-4e59-4ab8-8174-afcca1ae0d9e</name> <entityField>OBJECT_TYPE</entityField> </neonTableColumn> - <neonTableColumn> - <name>7e7ebe69-2c09-402c-9264-5c5ea48a202b</name> - <entityField>MIN_COUNT</entityField> - </neonTableColumn> - <neonTableColumn> - <name>07683f36-9b32-43aa-8bd5-51c3d7761c76</name> - <entityField>MAX_COUNT</entityField> - </neonTableColumn> </columns> </tableViewTemplate> </children> diff --git a/neonView/AttributeUsageMultiEdit_view/AttributeUsageMultiEdit_view.aod b/neonView/AttributeUsageMultiEdit_view/AttributeUsageMultiEdit_view.aod index d4c4405974..231d9cf048 100644 --- a/neonView/AttributeUsageMultiEdit_view/AttributeUsageMultiEdit_view.aod +++ b/neonView/AttributeUsageMultiEdit_view/AttributeUsageMultiEdit_view.aod @@ -17,18 +17,6 @@ <entityField>OBJECT_TYPE</entityField> <width v="75" /> </neonTableColumn> - <neonTableColumn> - <name>0ea0ead0-99a7-460a-ab8a-d3ef5f780682</name> - <entityField>MIN_COUNT</entityField> - <width v="75" /> - <expandRatio v="100" /> - </neonTableColumn> - <neonTableColumn> - <name>6fcd2a5b-641f-4b8f-aee0-cb18987b8a04</name> - <entityField>MAX_COUNT</entityField> - <width v="75" /> - <expandRatio v="100" /> - </neonTableColumn> </columns> </genericMultipleViewTemplate> </children> -- GitLab