diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index d6f3d3eec9d5f1d00b7baf6ca7fb9a8a6afd2a62..07f9d8460ea70d95f25f9c471b5ab0d8741cf58d 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -7,7 +7,6 @@ <grantDeleteProcess>%aditoprj%/entity/Attribute_entity/grantDeleteProcess.js</grantDeleteProcess> <contentTitleProcess>%aditoprj%/entity/Attribute_entity/contentTitleProcess.js</contentTitleProcess> <afterUiInit>%aditoprj%/entity/Attribute_entity/afterUiInit.js</afterUiInit> - <onValidation>%aditoprj%/entity/Attribute_entity/onValidation.js</onValidation> <iconId>VAADIN:TAG</iconId> <titlePlural>Attributes</titlePlural> <recordContainer>jdito</recordContainer> @@ -390,6 +389,7 @@ <entityProvider> <name>AttributeChildren</name> <sortingField>SORTING</sortingField> + <documentation>%aditoprj%/entity/Attribute_entity/entityfields/attributechildren/documentation.adoc</documentation> <titlePlural>Child Attributes</titlePlural> <dependencies> <entityDependency> @@ -433,6 +433,10 @@ <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributechildren/children/getonlyfirstlevelchildren_param/valueProcess.js</valueProcess> <expose v="false" /> </entityParameter> + <entityParameter> + <name>ParentId_param</name> + <mandatory v="true" /> + </entityParameter> </children> </entityProvider> <entityConsumer> diff --git a/entity/Attribute_entity/entityfields/attributechildren/documentation.adoc b/entity/Attribute_entity/entityfields/attributechildren/documentation.adoc new file mode 100644 index 0000000000000000000000000000000000000000..f9ca1e5e2252e6299b78d0d10174f0a83a3d24e0 --- /dev/null +++ b/entity/Attribute_entity/entityfields/attributechildren/documentation.adoc @@ -0,0 +1,4 @@ += AttributeChildren + +This provider can be used to get all child Attributes of a given parent. It is intended for displaying and editing the childs of an Attribute in the +Attribute context and allows to sort them. Only the direct children are returned. \ No newline at end of file diff --git a/entity/Attribute_entity/onValidation.js b/entity/Attribute_entity/onValidation.js deleted file mode 100644 index f1b6c7fc1f437ab9ba090ab87e297514e884eb3a..0000000000000000000000000000000000000000 --- a/entity/Attribute_entity/onValidation.js +++ /dev/null @@ -1,25 +0,0 @@ -import("system.translate"); -import("system.db"); -import("system.vars"); -import("system.text"); -import("system.neon"); -import("Sql_lib"); - -//TODO: this should no happen in onValidation; waiting for #1032668 -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) -{ - var parentId = vars.get("$field.ATTRIBUTE_PARENT_ID"); - if (parentId) - { - var maskingHelper = new SqlMaskingUtils(); - var newCodeNumber = newSelect(maskingHelper.max("AB_ATTRIBUTE.SORTING")) - .from("AB_ATTRIBUTE") - .where("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", parentId) - .cell(); - - newCodeNumber = Number(newCodeNumber);//if no number exists till no, start value will be 1 (due to: ++0) - if (isNaN(newCodeNumber)) - throw new TypeError(translate.text("The code number is not a valid number.")); - neon.setFieldValue("$field.SORTING", ++newCodeNumber); - } -} \ No newline at end of file diff --git a/entity/Attribute_entity/recordcontainers/jdito/onInsert.js b/entity/Attribute_entity/recordcontainers/jdito/onInsert.js index 7e2f5457781d5b5447f6e032739c66e0bf7c775c..9678a3d086a347c391ac075a2efc38028f26259f 100644 --- a/entity/Attribute_entity/recordcontainers/jdito/onInsert.js +++ b/entity/Attribute_entity/recordcontainers/jdito/onInsert.js @@ -4,15 +4,25 @@ import("Attribute_lib"); var rowdata = vars.get("$local.rowdata"); +var sorting = rowdata["SORTING.value"]; +var parentId = rowdata["ATTRIBUTE_PARENT_ID.value"]; +if (!sorting && parentId) +{ + sorting = newSelect("max(SORTING) + 1") + .from("AB_ATTRIBUTE") + .where("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", parentId) + .cell() || 0; +} + new SqlBuilder().insertFields({ "AB_ATTRIBUTEID" : rowdata["UID.value"], - "ATTRIBUTE_PARENT_ID" : rowdata["ATTRIBUTE_PARENT_ID.value"], + "ATTRIBUTE_PARENT_ID" : parentId, "DROPDOWNDEFINITION" : rowdata["DROPDOWNDEFINITION.value"], "ATTRIBUTE_ACTIVE" : rowdata["ATTRIBUTE_ACTIVE.value"], "ATTRIBUTE_NAME" : rowdata["ATTRIBUTE_NAME.value"], "ATTRIBUTE_TYPE" : rowdata["ATTRIBUTE_TYPE.value"], "DROPDOWNFILTER" : rowdata["DROPDOWNFILTER.value"], - "SORTING" : rowdata["SORTING.value"] + "SORTING" : sorting }, "AB_ATTRIBUTE"); if (rowdata["ATTRIBUTE_PARENT_ID.value"] && rowdata["ATTRIBUTE_TYPE.value"] !== $AttributeTypes.COMBOVALUE.toString() && vars.get("$param.GetOnlyFirstLevelChildren_param")) diff --git a/neonView/AttributeList_view/AttributeList_view.aod b/neonView/AttributeList_view/AttributeList_view.aod index 774de73db92dae98b860089f56e553f5c7f544e4..167cf43d52b6481ab3ad36f745aa899f2e53cc3f 100644 --- a/neonView/AttributeList_view/AttributeList_view.aod +++ b/neonView/AttributeList_view/AttributeList_view.aod @@ -11,6 +11,9 @@ <titledListViewTemplate> <name>AttributeList</name> <entityField>#ENTITY</entityField> + <isDeletable v="false" /> + <isEditable v="false" /> + <isCreatable v="false" /> <columns> <neonTitledListTableColumn> <name>96544713-a302-4e2f-ab7f-6c02d44d9908</name>