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

Attribute groups

parent 84056c69
No related branches found
No related tags found
No related merge requests found
Showing
with 120 additions and 29 deletions
......@@ -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>
......
......@@ -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>
......
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
import("system.vars");
import("system.result");
result.string(vars.getString("$field.ATTRIBUTE_LEVEL"));
\ No newline at end of file
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
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
import("system.db");
import("system.result");
result.object({"AB_ATTRIBUTE.ATTRIBUTE_LEVEL" : db.ASCENDING});
\ No newline at end of file
......@@ -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>
......@@ -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>
......
......@@ -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>
......@@ -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
......@@ -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(" / ");
}
......
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