Skip to content
Snippets Groups Projects
Commit 0f0a1719 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

Attribute sorting fixed

parent ace7d86c
No related branches found
No related tags found
No related merge requests found
......@@ -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>
......
= 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
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
......@@ -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"))
......
......@@ -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>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment