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

Combobox Attribute

parent f9ba323c
No related branches found
No related tags found
No related merge requests found
Showing
with 95 additions and 40 deletions
...@@ -34,6 +34,7 @@ ...@@ -34,6 +34,7 @@
<title>Value</title> <title>Value</title>
<contentTypeProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/contentTypeProcess.js</contentTypeProcess> <contentTypeProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/contentTypeProcess.js</contentTypeProcess>
<resolution>DAY</resolution> <resolution>DAY</resolution>
<possibleItemsProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/possibleItemsProcess.js</possibleItemsProcess>
<valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js</valueProcess> <valueProcess>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/valueProcess.js</valueProcess>
<onValueChange>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js</onValueChange> <onValueChange>%aditoprj%/entity/AttributeRelation_entity/entityfields/attributerelation_value/onValueChange.js</onValueChange>
</entityField> </entityField>
......
...@@ -2,4 +2,4 @@ import("system.vars"); ...@@ -2,4 +2,4 @@ import("system.vars");
import("system.result"); import("system.result");
import("Attribute_lib"); import("Attribute_lib");
result.object(AttributeUtil.getPossibleAttributes(vars.get("$param.objectType_param"))); result.object(AttributeUtil.getPossibleAttributes(vars.get("$param.objectType_param"), true));
import("system.db");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Sql_lib");
var attributeId = vars.get("$field.AB_ATTRIBUTE_ID");
var attrType = AttributeHandler.begin(attributeId).getAttributeType();
if (attrType == AttributeTypes.COMBO)
{
var valueSql = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", attributeId)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", AttributeTypes.COMBOVALUE)
.buildSql("select AB_ATTRIBUTEID, ATTRIBUTE_NAME from AB_ATTRIBUTE");
var valueList = db.table(valueSql);
result.object(valueList);
}
\ No newline at end of file
...@@ -2,25 +2,25 @@ import("system.result"); ...@@ -2,25 +2,25 @@ import("system.result");
import("system.vars"); import("system.vars");
import("Attribute_lib"); import("Attribute_lib");
var attrField = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeField(); var attrType = AttributeHandler.begin(vars.get("$field.AB_ATTRIBUTE_ID")).getAttributeType();
if (attrField != null) //load the value from the correct field for the type if (attrType != null) //load the value from the correct field for the type
{ {
switch (attrField) switch (attrType)
{ {
case "CHAR_VALUE": case AttributeTypes.TEXT:
result.string(vars.get("$field.CHAR_VALUE")); result.string(vars.get("$field.CHAR_VALUE"));
break; break;
case "DATE_VALUE": case AttributeTypes.DATE:
result.string(vars.get("$field.DATE_VALUE")); result.string(vars.get("$field.DATE_VALUE"));
break; break;
case "NUMBER_VALUE": case AttributeTypes.NUMBER:
result.string(vars.get("$field.NUMBER_VALUE")); result.string(vars.get("$field.NUMBER_VALUE"));
break; break;
case "BOOL_VALUE": case AttributeTypes.BOOLEAN:
result.string(vars.get("$field.BOOL_VALUE")); result.string(vars.get("$field.BOOL_VALUE"));
break; break;
case "ID_VALUE": case AttributeTypes.COMBO:
result.string(vars.get("$field.ID_VALUE")); result.string(vars.get("$field.ID_VALUE"));
break; break;
} }
......
...@@ -5,6 +5,7 @@ ...@@ -5,6 +5,7 @@
<majorModelMode>DISTRIBUTED</majorModelMode> <majorModelMode>DISTRIBUTED</majorModelMode>
<documentation>%aditoprj%/entity/Attribute_entity/documentation.adoc</documentation> <documentation>%aditoprj%/entity/Attribute_entity/documentation.adoc</documentation>
<iconId>VAADIN:TAG</iconId> <iconId>VAADIN:TAG</iconId>
<titleProcess>%aditoprj%/entity/Attribute_entity/titleProcess.js</titleProcess>
<recordContainer>db</recordContainer> <recordContainer>db</recordContainer>
<entityFields> <entityFields>
<entityProvider> <entityProvider>
...@@ -22,6 +23,8 @@ ...@@ -22,6 +23,8 @@
<title>Type</title> <title>Type</title>
<consumer>KeywordAttributeType</consumer> <consumer>KeywordAttributeType</consumer>
<mandatory v="true" /> <mandatory v="true" />
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js</displayValueProcess>
</entityField> </entityField>
<entityField> <entityField>
<name>AB_ATTRIBUTEID</name> <name>AB_ATTRIBUTEID</name>
...@@ -53,12 +56,6 @@ ...@@ -53,12 +56,6 @@
<triggerRecalculation v="true" /> <triggerRecalculation v="true" />
<mandatory v="false" /> <mandatory v="false" />
</entityParameter> </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> </children>
</entityConsumer> </entityConsumer>
<entityProvider> <entityProvider>
...@@ -124,11 +121,6 @@ ...@@ -124,11 +121,6 @@
</entityParameter> </entityParameter>
</children> </children>
</entityConsumer> </entityConsumer>
<entityParameter>
<name>attributeLevel_param</name>
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityField> <entityField>
<name>ATTRIBUTE_LEVEL</name> <name>ATTRIBUTE_LEVEL</name>
<title>Level</title> <title>Level</title>
......
import("system.db");
import("system.neon"); import("system.neon");
import("system.result"); import("system.result");
import("system.vars"); import("system.vars");
import("Sql_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW) if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
if (vars.exists("$param.attributeLevel_param") && vars.get("$param.attributeLevel_param") if (vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
&& vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) {
result.string(parseInt(vars.get("$param.attributeLevel_param")) + 1); var level = db.cell(SqlCondition.begin()
.andPrepare("AB_ATTRIBUTE.AB_ATTRIBUTEID", vars.get("$field.ATTRIBUTE_PARENT_ID"))
.buildSql("select ATTRIBUTE_LEVEL from AB_ATTRIBUTE"));
result.string(parseInt(level) + 1);
}
else else
result.string("0"); result.string("0");
import("system.neon");
import("system.result"); import("system.result");
import("system.vars"); import("system.vars");
import("Attribute_lib"); 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("$field.ATTRIBUTE_PARENT_ID")))
result.string(AttributeUtil.getAttributeNameById(vars.get("$param.attrParentId_param"))); \ No newline at end of file
else
result.string(AttributeUtil.getAttributeNameById(vars.get("$field.ATTRIBUTE_PARENT_ID")))
\ No newline at end of file
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
import("Keyword_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType();
if (type == AttributeTypes.COMBO)
result.string(KeywordUtils.getViewValue($KeywordRegistry.get.AttributeType, AttributeTypes.COMBOVALUE));
}
\ No newline at end of file
import("system.db");
import("system.neon");
import("system.result");
import("system.vars");
import("Attribute_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "")
{
var type = AttributeHandler.begin(vars.get("$field.ATTRIBUTE_PARENT_ID")).getAttributeType();
if (type == AttributeTypes.COMBO)
result.string(AttributeTypes.COMBOVALUE);
}
\ No newline at end of file
...@@ -2,7 +2,8 @@ import("system.vars"); ...@@ -2,7 +2,8 @@ import("system.vars");
import("system.result"); import("system.result");
import("Attribute_lib"); import("Attribute_lib");
if (vars.getString("$field.ATTRIBUTE_TYPE").trim() == AttributeTypes.GROUP) var type = vars.getString("$field.ATTRIBUTE_TYPE").trim();
if (type == AttributeTypes.GROUP || type == AttributeTypes.COMBO)
result.string(vars.getString("$field.AB_ATTRIBUTEID")); result.string(vars.getString("$field.AB_ATTRIBUTEID"));
else else
result.string(""); result.string("");
...@@ -2,8 +2,9 @@ import("system.db"); ...@@ -2,8 +2,9 @@ import("system.db");
import("system.vars"); import("system.vars");
import("system.result"); import("system.result");
import("Sql_lib"); import("Sql_lib");
import("Attribute_lib");
var condition = "1=2"; var condition = "AB_ATTRIBUTE.ATTRIBUTE_TYPE = '" + AttributeTypes.GROUP + "'";
if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param")) if (vars.exists("$param.attrParentId_param") && vars.get("$param.attrParentId_param"))
condition = "AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + getAllChildren(vars.getString("$param.attrParentId_param")).join("','") + "')"; condition = "AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + getAllChildren(vars.getString("$param.attrParentId_param")).join("','") + "')";
......
import("system.vars"); import("system.vars");
import("system.result"); import("system.result");
result.string(vars.getString("$field.ATTRIBUTE_LEVEL")); result.string(vars.get("$field.ATTRIBUTE_NAME"));
\ No newline at end of file \ No newline at end of file
...@@ -27,7 +27,9 @@ ...@@ -27,7 +27,9 @@
</tableViewTemplate> </tableViewTemplate>
<treetableViewTemplate> <treetableViewTemplate>
<name>Tree</name> <name>Tree</name>
<titleField>ATTRIBUTERELATION_VALUE</titleField> <parentField>ATTRIBUTE_PARENT_ID</parentField>
<titleField>AB_ATTRIBUTE_ID</titleField>
<descriptionField>ATTRIBUTERELATION_VALUE</descriptionField>
<entityField>#ENTITY</entityField> <entityField>#ENTITY</entityField>
</treetableViewTemplate> </treetableViewTemplate>
</children> </children>
......
...@@ -18,23 +18,25 @@ function AttributeUtil () {} ...@@ -18,23 +18,25 @@ function AttributeUtil () {}
* process for the attribute id in AttributeRelation * process for the attribute id in AttributeRelation
* *
* @param {String} pObjectType the object type (= context) * @param {String} pObjectType the object type (= context)
* @param {boolean} pIncludeGroups
* *
* @return {String[][]} two-dimensional array of attributeIds and names * @return {String[][]} two-dimensional array of attributeIds and names
*/ */
AttributeUtil.getPossibleAttributes = function (pObjectType) AttributeUtil.getPossibleAttributes = function (pObjectType, pIncludeGroups)
{ {
if (pObjectType == null) if (pObjectType == null)
return []; return [];
var attrSql = "select AB_ATTRIBUTEID from AB_ATTRIBUTE" var attrSql = "select AB_ATTRIBUTEID from AB_ATTRIBUTE"
+ " join AB_ATTRIBUTEUSAGE on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID"; + " join AB_ATTRIBUTEUSAGE on AB_ATTRIBUTEID = AB_ATTRIBUTE_ID";
attrSql = SqlCondition.begin() attrCond = SqlCondition.begin()
.andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType) .andPrepare("AB_ATTRIBUTEUSAGE.OBJECT_TYPE", pObjectType)
.and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'") .and("ATTRIBUTE_ACTIVE = 1");
.and("ATTRIBUTE_ACTIVE = 1")
.buildSql(attrSql); if (!pIncludeGroups)
attrCond.and("ATTRIBUTE_TYPE != '" + AttributeTypes.GROUP + "'");
var attributes = db.array(db.COLUMN, attrSql).map(function (id) var attributes = db.array(db.COLUMN, attrCond.buildSql(attrSql)).map(function (id)
{ {
return [id, AttributeUtil.getAttributeNameById(id)]; return [id, AttributeUtil.getAttributeNameById(id)];
}); });
...@@ -115,7 +117,7 @@ AttributeHandler.begin = function (pAttrId) ...@@ -115,7 +117,7 @@ AttributeHandler.begin = function (pAttrId)
* *
* @return {String} attribute type * @return {String} attribute type
*/ */
AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the type should be an own field in the entity instead of getting the type from the attribute id AttributeHandler.prototype.getAttributeType = function () //TODO: maybe the type should be an own field in the entity instead of getting the type from the attribute id
{ {
if (this._attributeType == null && this.attributeId != null) if (this._attributeType == null && this.attributeId != null)
{ {
...@@ -135,7 +137,7 @@ AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the typ ...@@ -135,7 +137,7 @@ AttributeHandler.prototype._getAttributeType = function () //TODO: maybe the typ
*/ */
AttributeHandler.prototype.getAttributeField = function () AttributeHandler.prototype.getAttributeField = function ()
{ {
return AttributeTypes.getEntityField(this._getAttributeType()); return AttributeTypes.getEntityField(this.getAttributeType());
} }
/** /**
...@@ -145,7 +147,7 @@ AttributeHandler.prototype.getAttributeField = function () ...@@ -145,7 +147,7 @@ AttributeHandler.prototype.getAttributeField = function ()
*/ */
AttributeHandler.prototype.getAttributeContentType = function () AttributeHandler.prototype.getAttributeContentType = function ()
{ {
return AttributeTypes.getContentType(this._getAttributeType()); return AttributeTypes.getContentType(this.getAttributeType());
} }
AttributeHandler.prototype.setAttributeValue = function (pValue) AttributeHandler.prototype.setAttributeValue = function (pValue)
...@@ -200,6 +202,12 @@ var AttributeTypes = { ...@@ -200,6 +202,12 @@ var AttributeTypes = {
databaseField : "ID_VALUE", databaseField : "ID_VALUE",
entityField : "ID_VALUE" entityField : "ID_VALUE"
}, },
COMBOVALUE : {
toString : function () {return "COMBOVALUE"},
contentType : null,
databaseField : null,
entityField : null
},
GROUP : { GROUP : {
toString : function () {return "GROUP"}, toString : function () {return "GROUP"},
contentType : null, contentType : null,
......
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