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

Attribute level removed

parent 5b9f7f42
No related branches found
No related tags found
No related merge requests found
Showing
with 382 additions and 486 deletions
...@@ -12,6 +12,9 @@ ...@@ -12,6 +12,9 @@
<dropColumn tableName="AB_ATTRIBUTERELATION"> <dropColumn tableName="AB_ATTRIBUTERELATION">
<column name="BOOL_VALUE"/> <column name="BOOL_VALUE"/>
</dropColumn> </dropColumn>
<dropColumn tableName="AB_ATTRIBUTE">
<column name="ATTRIBUTE_LEVEL"/>
</dropColumn>
<modifyDataType tableName="AB_ATTRIBUTERELATION" columnName="CHAR_VALUE" newDataType="NVARCHAR(512)"/> <modifyDataType tableName="AB_ATTRIBUTERELATION" columnName="CHAR_VALUE" newDataType="NVARCHAR(512)"/>
<createIndex indexName="IDX_ATTRPARENT" tableName="AB_ATTRIBUTE"> <createIndex indexName="IDX_ATTRPARENT" tableName="AB_ATTRIBUTE">
<column name="ATTRIBUTE_PARENT_ID"/> <column name="ATTRIBUTE_PARENT_ID"/>
......
...@@ -44,11 +44,10 @@ function _sortArrayForTree (pArray) ...@@ -44,11 +44,10 @@ function _sortArrayForTree (pArray)
{ {
var rows = {}; var rows = {};
var allIds = {}; var allIds = {};
var idIndex = 1; var idIndex = 0;
var parentIdIndex = 4; var parentIdIndex = 1;
pArray.forEach(function (row) {allIds[row[idIndex]] = true;}); pArray.forEach(function (row) {allIds[row[idIndex]] = true;});
var index = 0; var index = 0;
for (let itemsAdded = true; itemsAdded; itemsAdded = oldIndex != index) for (let itemsAdded = true; itemsAdded; itemsAdded = oldIndex != index)
...@@ -63,9 +62,8 @@ function _sortArrayForTree (pArray) ...@@ -63,9 +62,8 @@ function _sortArrayForTree (pArray)
}; };
}, rows); }, rows);
} }
var sortedArray = new Array(Object.keys(rows).length); var sortedArray = new Array(index);
for (let i in rows) for (let i in rows)
sortedArray[rows[i].index] = rows[i].data; sortedArray[rows[i].index] = rows[i].data;
return sortedArray; return sortedArray;
} }
\ No newline at end of file
...@@ -75,7 +75,6 @@ ...@@ -75,7 +75,6 @@
<entityProvider> <entityProvider>
<name>AttributeParent</name> <name>AttributeParent</name>
<fieldType>DEPENDENCY_IN</fieldType> <fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>db</recordContainer>
<dependencies> <dependencies>
<entityDependency> <entityDependency>
<name>18bd148d-bed3-429f-ba54-c5eac76c5083</name> <name>18bd148d-bed3-429f-ba54-c5eac76c5083</name>
...@@ -238,19 +237,13 @@ ...@@ -238,19 +237,13 @@
</entityParameter> </entityParameter>
<entityField> <entityField>
<name>USAGELIST</name> <name>USAGELIST</name>
<title>Usages</title> <title>Usage</title>
<state>READONLY</state> <state>READONLY</state>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/usagelist/valueProcess.js</valueProcess> <valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/usagelist/valueProcess.js</valueProcess>
</entityField> </entityField>
<entityField>
<name>NAME_WITH_TYPE</name>
<title>Name</title>
<valueProcess>%aditoprj%/entity/Attribute_entity/entityfields/name_with_type/valueProcess.js</valueProcess>
</entityField>
<entityProvider> <entityProvider>
<name>AttributeGroups</name> <name>AttributeGroups</name>
<fieldType>DEPENDENCY_IN</fieldType> <fieldType>DEPENDENCY_IN</fieldType>
<recordContainer>db</recordContainer>
<children> <children>
<entityParameter> <entityParameter>
<name>GetGroups_param</name> <name>GetGroups_param</name>
......
import("system.translate");
import("system.result");
import("system.vars");
import("Attribute_lib");
var name = vars.get("$field.ATTRIBUTE_NAME");
if (vars.get("$field.ATTRIBUTE_TYPE").trim() != $AttributeTypes.COMBOVALUE)
name += " (" + translate.text("Type") + ": " + vars.get("$field.ATTRIBUTE_TYPE.displayValue") + ")";
result.string(name);
\ No newline at end of file
import("system.translate"); import("system.translate");
import("system.result"); import("system.result");
import("system.db"); import("system.db");
import("system.vars"); import("system.vars");
import("Sql_lib"); import("Sql_lib");
import("Attribute_lib"); import("Attribute_lib");
var retStr = "\u00A0"; // \u00A0 -> space character that doesn't get trimmed var retStr = "\u00A0"; // \u00A0 -> space character that doesn't get trimmed
if (vars.get("$field.ATTRIBUTE_TYPE").trim() != $AttributeTypes.COMBOVALUE) if (vars.get("$field.ATTRIBUTE_TYPE").trim() != $AttributeTypes.COMBOVALUE)
{ {
var usages = db.array(db.COLUMN, SqlCondition.begin() var usages = db.array(db.COLUMN, SqlCondition.begin()
.andPrepare("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", vars.get("$field.AB_ATTRIBUTEID")) .andPrepare("AB_ATTRIBUTEUSAGE.AB_ATTRIBUTE_ID", vars.get("$field.AB_ATTRIBUTEID"))
.buildSql("select OBJECT_TYPE from AB_ATTRIBUTEUSAGE")); .buildSql("select OBJECT_TYPE from AB_ATTRIBUTEUSAGE"));
if (usages.length) if (usages.length)
retStr = translate.text("Usage") + ": " + usages.join(", "); retStr = usages.join(", ");
} }
result.string(retStr); result.string(retStr);
\ No newline at end of file
import("system.logging");
import("system.datetime");
import("JditoFilter_lib"); import("JditoFilter_lib");
import("KeywordRegistry_basic"); import("KeywordRegistry_basic");
import("Keyword_lib"); import("Keyword_lib");
...@@ -7,11 +9,19 @@ import("system.result"); ...@@ -7,11 +9,19 @@ import("system.result");
import("Sql_lib"); import("Sql_lib");
import("Attribute_lib"); import("Attribute_lib");
var sqlSelect = "select AB_ATTRIBUTEID, AB_ATTRIBUTEID, ATTRIBUTE_ACTIVE, "
+ "ATTRIBUTE_NAME, ATTRIBUTE_PARENT_ID, ATTRIBUTE_TYPE, "
+ KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.attributeType(), "ATTRIBUTE_TYPE")
+ ", KEYWORD_CONTAINER from AB_ATTRIBUTE";
var condition = new SqlCondition(); var condition = new SqlCondition();
var getGroups = vars.exists("$param.GetGroups_param") && vars.get("$param.GetGroups_param"); var getGroups = vars.exists("$param.GetGroups_param") && vars.get("$param.GetGroups_param");
var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param"); var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param");
if (getGroups)
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
condition.and("AB_ATTRIBUTEID in ('" + vars.get("$local.idvalues").join("','") + "')");
else if (getGroups)
{ {
//this is for the selection of the superordinate attribute, this condition //this is for the selection of the superordinate attribute, this condition
//filters out the own id and the children to prevent loops //filters out the own id and the children to prevent loops
...@@ -19,7 +29,7 @@ if (getGroups) ...@@ -19,7 +29,7 @@ if (getGroups)
.andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.GROUP) .andPrepare("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.GROUP)
.andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$param.AttrParentId_param", "# != ?") .andPrepareVars("AB_ATTRIBUTE.AB_ATTRIBUTEID", "$param.AttrParentId_param", "# != ?")
.and("AB_ATTRIBUTE.AB_ATTRIBUTEID not in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')") .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 else if (objectType) //if there's an objectType, it comes from the AttributeRelation entity
{ {
...@@ -34,33 +44,27 @@ else ...@@ -34,33 +44,27 @@ else
{ {
var type = vars.exists("$param.AttrParentType_param") && vars.get("$param.AttrParentType_param"); var type = vars.exists("$param.AttrParentType_param") && vars.get("$param.AttrParentType_param");
if (type == $AttributeTypes.COMBO) if (type == $AttributeTypes.COMBO)
condition = SqlCondition.begin() condition.andPrepareVars("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", "$param.AttrParentId_param");
.andPrepareVars("AB_ATTRIBUTE.ATTRIBUTE_PARENT_ID", "$param.AttrParentId_param") else if (type == $AttributeTypes.GROUP)
.build();
else if (type)
{ {
var parentId = vars.exists("$param.AttrParentId_param") && vars.get("$param.AttrParentId_param"); var parentId = vars.exists("$param.AttrParentId_param") && vars.get("$param.AttrParentId_param");
if (parentId) if (parentId)
condition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')"); condition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID in ('" + AttributeUtil.getAllChildren(vars.getString("$param.AttrParentId_param")).join("','") + "')");
} }
else if (type)
condition.and("1=2");
} }
var sql = "select AB_ATTRIBUTEID, AB_ATTRIBUTEID, ATTRIBUTE_ACTIVE, " //when there are filters selected, add them to the conditon
+ "ATTRIBUTE_NAME, ATTRIBUTE_PARENT_ID, ATTRIBUTE_TYPE, " if (vars.exists("$local.filter") && vars.get("$local.filter"))
+ KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.attributeType(), "ATTRIBUTE_TYPE")
+ ", KEYWORD_CONTAINER from AB_ATTRIBUTE";
if (vars.exists("$local.idvalues") && vars.get("$local.idvalues"))
condition.and(" AB_ATTRIBUTEID in ('" + vars.get("$local.idvalues").join("','") + "')");
else if (vars.exists("$local.filter") && vars.get("$local.filter"))
{ {
var filter = vars.get("$local.filter"); var filter = vars.get("$local.filter");
condition.andSqlCondition((JditoFilterUtils.getSqlCondition(filter, "AB_ATTRIBUTE"))); condition.andSqlCondition((JditoFilterUtils.getSqlCondition(filter, "AB_ATTRIBUTE")));
} }
var attributes = db.table(condition.buildSql(sql, "1=1")); var attributes = db.table(condition.buildSql(sqlSelect, "1=1"));
if (!(vars.exists("$local.idvalues") && vars.get("$local.idvalues"))) if (attributes.length > 1)
attributes = _sortArrayForTree(attributes); attributes = _sortArrayForTree(attributes);
result.object(attributes); result.object(attributes);
...@@ -82,6 +86,8 @@ function _sortArrayForTree (pArray) ...@@ -82,6 +86,8 @@ function _sortArrayForTree (pArray)
var oldIndex = index; var oldIndex = index;
pArray.forEach(function (row) pArray.forEach(function (row)
{ {
//item will be added if the id is not already in the object and
//the parent is already added (or the parent is not in the array)
if (!(row[idIndex] in this) && (row[parentIdIndex] in this || !allIds[row[parentIdIndex]])) if (!(row[idIndex] in this) && (row[parentIdIndex] in this || !allIds[row[parentIdIndex]]))
this[row[idIndex]] = { this[row[idIndex]] = {
data : row, data : row,
......
This diff is collapsed.
import("Communication_lib"); import("Communication_lib");
import("Entity_lib"); import("Entity_lib");
import("system.result"); import("system.result");
import("system.db"); import("system.db");
import("system.neon"); import("system.neon");
import("system.vars"); import("system.vars");
import("Sql_lib"); import("Sql_lib");
import("Employee_lib");
var contactId = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTACT_ID"));
if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) var contactId = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.CONTACT_ID"));
&& contactId) if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{ && contactId)
var name = db.array( {
db.ROW, var name = db.array(
SqlCondition.begin() db.ROW,
.andPrepare("CONTACT.CONTACTID", contactId) SqlCondition.begin()
.buildSql("select FIRSTNAME, LASTNAME, (" + CommUtil.getStandardSubSqlMail() + ") from PERSON join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID") .andPrepare("CONTACT.CONTACTID", contactId)
); .buildSql("select FIRSTNAME, LASTNAME, (" + CommUtil.getStandardSubSqlMail() + ") from PERSON join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID")
);
neon.setFieldValues({ var username = EmployeeUtils.generateUserName(name[0], name[1], "f.l+");
"$field.FIRSTNAME" : name[0] || "",
"$field.LASTNAME" : name[1] || "", neon.setFieldValues({
"$field.EMAIL_ADDRESS" : name[2] || "" "$field.FIRSTNAME" : name[0] || "",
}); "$field.LASTNAME" : name[1] || "",
"$field.EMAIL_ADDRESS" : name[2] || "",
"$field.TITLE" : username
});
} }
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
import("Employee_lib");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT && !vars.get("$field.TITLE"))
result.string(EmployeeUtils.generateUserName(vars.get("$field.FIRSTNAME"), vars.get("$field.LASTNAME"), "f.l+"));
\ No newline at end of file
...@@ -10,14 +10,27 @@ ...@@ -10,14 +10,27 @@
</groupLayout> </groupLayout>
</layout> </layout>
<children> <children>
<treeViewTemplate> <treeTableViewTemplate>
<name>AttributesTreetable</name> <name>AttributeTreeTable</name>
<parentField>ATTRIBUTE_PARENT_ID</parentField> <parentField>ATTRIBUTE_PARENT_ID</parentField>
<favoriteActionGroup1>AttributeActions</favoriteActionGroup1> <favoriteActionGroup1>AttributeActions</favoriteActionGroup1>
<titleField>NAME_WITH_TYPE</titleField> <showChildrenCount v="false" />
<descriptionField>USAGELIST</descriptionField>
<entityField>#ENTITY</entityField> <entityField>#ENTITY</entityField>
</treeViewTemplate> <columns>
<neonTableColumn>
<name>a776a053-6712-44f9-943f-da26d1ce11ee</name>
<entityField>ATTRIBUTE_NAME</entityField>
</neonTableColumn>
<neonTableColumn>
<name>b975154d-8bac-4182-9030-e3b3d744c642</name>
<entityField>ATTRIBUTE_TYPE</entityField>
</neonTableColumn>
<neonTableColumn>
<name>ad92d325-6cdb-4fa0-a99b-27c937c89936</name>
<entityField>USAGELIST</entityField>
</neonTableColumn>
</columns>
</treeTableViewTemplate>
<tableViewTemplate> <tableViewTemplate>
<name>AttributesTable</name> <name>AttributesTable</name>
<entityField>#ENTITY</entityField> <entityField>#ENTITY</entityField>
......
...@@ -112,6 +112,23 @@ JditoFilterUtils.filterRecords = function (pColumns, pRecords, pFilter) ...@@ -112,6 +112,23 @@ JditoFilterUtils.filterRecords = function (pColumns, pRecords, pFilter)
}, filter); }, filter);
} }
/**
* builds an sql condition from the given filter
*
* @param {String|Object} pFilter the filter as JSON
* @param {String} pTable the database table
* @param {Object} pColumnMap custom mapping for the fields to the DB columns, this is necessary
* if the fields are from different tables
*
* @example
* if (vars.exists("$local.filter") && vars.get("$local.filter"))
* {
* var filter = vars.get("$local.filter");
* condition.andSqlCondition((JditoFilterUtils.getSqlCondition(filter, "AB_ATTRIBUTE")));
* }
*
* @return {SqlCondition} the SqlCondition object
*/
JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pColumnMap) JditoFilterUtils.getSqlCondition = function (pFilter, pTable, pColumnMap)
{ {
var condition = new SqlCondition(); var condition = new SqlCondition();
......
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