Skip to content
Snippets Groups Projects
Commit 4fa901db authored by S.Listl's avatar S.Listl
Browse files

Parent attribute editable

parent 848cc08a
No related branches found
No related tags found
No related merge requests found
......@@ -14,7 +14,7 @@ if (attrType == $AttributeTypes.COMBO)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_ACTIVE", "1")
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.COMBOVALUE)
.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE");
.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE", "1=2", "order by ATTRIBUTE_NAME");
var valueList = db.table(valueSql);
result.object(valueList);
}
......
......@@ -36,12 +36,17 @@
<entityField>
<name>ATTRIBUTE_PARENT_ID</name>
<title>Superordinate Attribute</title>
<consumer>AttributeChildren</consumer>
<consumer>AttributeGroup</consumer>
<linkedContext>Attribute</linkedContext>
<searchable v="false" />
<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>
<onValueChange>%aditoprj%/entity/Attribute_entity/entityfields/attribute_parent_id/onValueChange.js</onValueChange>
<onValueChangeTypes>
<element>MASK</element>
<element>PROCESS</element>
</onValueChangeTypes>
</entityField>
<entityConsumer>
<name>AttributeChildren</name>
......@@ -90,8 +95,6 @@
</entityParameter>
<entityParameter>
<name>GetGroups_param</name>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributeparent/children/getgroups_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
</children>
</entityProvider>
......@@ -243,6 +246,37 @@
<title>Name</title>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/name_with_type/valueProcess.js</valueProcess>
</entityField>
<entityProvider>
<name>AttributeGroups</name>
<fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>db</recordContainer>
<children>
<entityParameter>
<name>GetGroups_param</name>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributegroups/children/getgroups_param/valueProcess.js</valueProcess>
<expose v="true" />
</entityParameter>
<entityParameter>
<name>AttrParentId_param</name>
<expose v="true" />
</entityParameter>
</children>
</entityProvider>
<entityConsumer>
<name>AttributeGroup</name>
<fieldType>DEPENDENCY_OUT</fieldType>
<dependency>
<name>dependency</name>
<entityName>Attribute_entity</entityName>
<fieldName>AttributeGroups</fieldName>
</dependency>
<children>
<entityParameter>
<name>AttrParentId_param</name>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attributegroup/children/attrparentid_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
</entityFields>
<recordContainers>
<dbRecordContainer>
......
import("system.db");
import("system.neon");
import("system.vars");
import("Attribute_lib");
if (vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_EDIT)
{
var level = 0;
if (vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
level = db.cell(SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", vars.get("$field.ATTRIBUTE_PARENT_ID"))
.buildSql("select ATTRIBUTE_LEVEL from AB_ATTRIBUTE"));
level = parseInt(level) + 1;
}
neon.setFieldValue("$field.ATTRIBUTE_LEVEL", level);
var table = "AB_ATTRIBUTE";
var columns = ["ATTRIBUTE_LEVEL"];
var types = db.getColumnTypes(table, columns);
var toUpdate = [];
var attributes = [vars.get("$field.AB_ATTRIBUTEID")];
while (attributes.length > 0)
{
var condition = SqlCondition.begin()
.and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')");
toUpdate.push([table, columns, types, [String(++level)], condition.build()]);
attributes = db.array(db.COLUMN, SqlCondition.begin()
.and("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID in ('" + attributes.join("','") + "')")
.buildSql("select AB_ATTRIBUTEID from AB_ATTRIBUTE")
);
}
db.updates(toUpdate);
}
\ No newline at end of file
import("system.result");
import("system.neon");
import("system.vars");
import("Attribute_lib");
var fieldState;
if(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
fieldState = neon.COMPONENTSTATE_AUTO;
else
if(vars.get("$field.ATTRIBUTE_TYPE").trim() == $AttributeTypes.COMBOVALUE)
fieldState = neon.COMPONENTSTATE_READONLY;
else
fieldState = neon.COMPONENTSTATE_AUTO;
result.string(fieldState);
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
result.string(vars.get("$sys.operatingstate") == neon.OPERATINGSTATE_NEW || "");
\ No newline at end of file
result.string(vars.get("$field.AB_ATTRIBUTEID"));
\ No newline at end of file
import("system.result");
result.string(true);
\ No newline at end of file
......@@ -10,8 +10,12 @@ var getGroups = vars.exists("$param.GetGroups_param") && vars.get("$param.GetGro
var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
if (getGroups)
{
//this is for the selection of the superordinate attribute, this condition
//filters out the own id and the children to prevent loops
condition = db.translateCondition(SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.GROUP)
.andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$param.AttrParentId_param", "# != ?")
.and("AB_ATTRIBUTE.AB_ATTRIBUTEID not in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')")
.build());
}
else if (objectType) //if there's an objectType, it comes from the AttributeRelation entity
......
import("system.db");
import("system.result");
result.object({"AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING});
\ No newline at end of file
result.object({
"AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING,
"AB_ATTRIBUTE.ATTRIBUTE_NAME" : db.ASCENDING
});
\ No newline at end of file
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