From 4adfdfcb061dc2a2f090b106d4a7b5670120ce66 Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Mon, 27 Jan 2020 11:05:10 +0100 Subject: [PATCH] Employee department selection fixed --- entity/Attribute_entity/Attribute_entity.aod | 10 ++++--- .../attribute_type/displayValueProcess.js | 4 +-- .../attribute_type/valueProcess.js | 2 +- .../recordcontainers/jdito/contentProcess.js | 21 ++++++++++----- entity/Employee_entity/Employee_entity.aod | 10 +++---- .../department/displayValueProcess.js | 2 +- .../attrparenttype_param/valueProcess.js | 3 --- .../valueProcess.js | 0 entity/Employee_entity/onValidation.js | 5 ++-- .../recordcontainers/jdito/contentProcess.js | 2 +- .../recordcontainers/jdito/onUpdate.js | 26 ++++++++++--------- .../recordcontainers/jdito/contentProcess.js | 8 ++++-- process/Attribute_lib/process.js | 22 ++++++++++------ 13 files changed, 65 insertions(+), 50 deletions(-) delete mode 100644 entity/Employee_entity/entityfields/departments/children/attrparenttype_param/valueProcess.js rename entity/Employee_entity/entityfields/departments/children/{attrparentid_param => parentid_param}/valueProcess.js (100%) diff --git a/entity/Attribute_entity/Attribute_entity.aod b/entity/Attribute_entity/Attribute_entity.aod index 2c91847336..26495570d6 100644 --- a/entity/Attribute_entity/Attribute_entity.aod +++ b/entity/Attribute_entity/Attribute_entity.aod @@ -144,6 +144,12 @@ <fieldName>ProjectTypeAttribute</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>26b85665-7914-45c4-b611-081ffe9502a4</name> + <entityName>Employee_entity</entityName> + <fieldName>Departments</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> <children> <entityParameter> @@ -167,10 +173,6 @@ <name>ChildType_param</name> <expose v="false" /> </entityParameter> - <entityParameter> - <name>ParentId_param</name> - <expose v="false" /> - </entityParameter> </children> </entityProvider> <entityField> diff --git a/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js index 48488c2d20..841ccf95e8 100644 --- a/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_type/displayValueProcess.js @@ -6,10 +6,8 @@ import("Attribute_lib"); import("Keyword_lib"); import("KeywordRegistry_basic"); -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID")) { var type = vars.get("$field.ATTRIBUTE_TYPE"); - for (let i = 0; l = 36 - type.length; i++) //the key is always 36 characters long - type += " "; result.string(KeywordUtils.getViewValue($KeywordRegistry.attributeType(), type)); } \ No newline at end of file diff --git a/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js index f71767310a..8ce11bd55e 100644 --- a/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js +++ b/entity/Attribute_entity/entityfields/attribute_type/valueProcess.js @@ -4,7 +4,7 @@ import("system.result"); import("system.vars"); import("Attribute_lib"); -if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID") != "") +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW && vars.get("$field.ATTRIBUTE_PARENT_ID")) { var type = AttributeUtil.getAttributeType(vars.get("$field.ATTRIBUTE_PARENT_ID")); var possibleTypes = AttributeTypeUtil.getPossibleChildren(type); diff --git a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js index def1321e09..362a002d70 100644 --- a/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Attribute_entity/recordcontainers/jdito/contentProcess.js @@ -9,15 +9,17 @@ import("system.result"); import("Sql_lib"); import("Attribute_lib"); -var childId = vars.exists("$param.ChildId_param") && vars.get("$param.ChildId_param"); -var childType = vars.exists("$param.ChildType_param") && vars.get("$param.ChildType_param"); +var childId = vars.get("$param.ChildId_param"); +var childType = vars.get("$param.ChildType_param"); -var objectType = vars.exists("$param.ObjectType_param") && vars.get("$param.ObjectType_param"); -var filteredIds = vars.exists("$param.FilteredAttributeIds_param") && vars.getString("$param.FilteredAttributeIds_param") ? JSON.parse(vars.getString("$param.FilteredAttributeIds_param")) : null -var attributeCountObj = vars.exists("$param.AttributeCount_param") && vars.get("$param.AttributeCount_param") ? JSON.parse(vars.getString("$param.AttributeCount_param")) : null; -var displaySimpleName = vars.exists("$param.DisplaySimpleName_param") && vars.get("$param.DisplaySimpleName_param"); +var objectType = vars.get("$param.ObjectType_param"); +var filteredIds = vars.getString("$param.FilteredAttributeIds_param") ? JSON.parse(vars.getString("$param.FilteredAttributeIds_param")) : null +var attributeCountObj = vars.get("$param.AttributeCount_param") ? JSON.parse(vars.getString("$param.AttributeCount_param")) : null; +var displaySimpleName = vars.get("$param.DisplaySimpleName_param"); -var themeObjectRowId = vars.exists("$param.ThemeObjectRowId_param") && vars.get("$param.ThemeObjectRowId_param"); +var themeObjectRowId = vars.get("$param.ThemeObjectRowId_param"); + +var parentId = vars.get("$param.ParentId_param"); var fetchUsages = false; var translateName = false; @@ -53,6 +55,11 @@ var emptyResult = function () condition.and("AB_ATTRIBUTE.ATTRIBUTE_TYPE", $AttributeTypes.THEME, !themeObjectRowId ? SqlBuilder.NOT_EQUAL() : undefined); } + else if (parentId) + { + condition.and("AB_ATTRIBUTE.AB_ATTRIBUTEID", AttributeUtil.getAllChildren(parentId), SqlBuilder.IN()); + translateName = true; + } else { fetchUsages = true; diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod index a68bb61e81..d749296985 100644 --- a/entity/Employee_entity/Employee_entity.aod +++ b/entity/Employee_entity/Employee_entity.aod @@ -279,15 +279,13 @@ <name>Departments</name> <dependency> <name>dependency</name> + <entityName>Attribute_entity</entityName> + <fieldName>SpecificAttribute</fieldName> </dependency> <children> <entityParameter> - <name>AttrParentId_param</name> - <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/departments/children/attrparentid_param/valueProcess.js</valueProcess> - </entityParameter> - <entityParameter> - <name>AttrParentType_param</name> - <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/departments/children/attrparenttype_param/valueProcess.js</valueProcess> + <name>ParentId_param</name> + <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/departments/children/parentid_param/valueProcess.js</valueProcess> </entityParameter> </children> </entityConsumer> diff --git a/entity/Employee_entity/entityfields/department/displayValueProcess.js b/entity/Employee_entity/entityfields/department/displayValueProcess.js index 054924b0a3..9b37b41042 100644 --- a/entity/Employee_entity/entityfields/department/displayValueProcess.js +++ b/entity/Employee_entity/entityfields/department/displayValueProcess.js @@ -2,4 +2,4 @@ import("system.result"); import("system.vars"); import("Attribute_lib"); -result.string(AttributeUtil.getFullAttributeName(vars.get("$field.DEPARTMENT"))); \ No newline at end of file +result.string(AttributeUtil.getFullAttributeName(vars.get("$field.DEPARTMENT"), undefined, undefined, 1)); \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/departments/children/attrparenttype_param/valueProcess.js b/entity/Employee_entity/entityfields/departments/children/attrparenttype_param/valueProcess.js deleted file mode 100644 index 67a485769c..0000000000 --- a/entity/Employee_entity/entityfields/departments/children/attrparenttype_param/valueProcess.js +++ /dev/null @@ -1,3 +0,0 @@ -import("system.result"); -import("Attribute_lib"); -result.string($AttributeTypes.VOID); \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/departments/children/attrparentid_param/valueProcess.js b/entity/Employee_entity/entityfields/departments/children/parentid_param/valueProcess.js similarity index 100% rename from entity/Employee_entity/entityfields/departments/children/attrparentid_param/valueProcess.js rename to entity/Employee_entity/entityfields/departments/children/parentid_param/valueProcess.js diff --git a/entity/Employee_entity/onValidation.js b/entity/Employee_entity/onValidation.js index d10cbbc9b0..9c20b6a43f 100644 --- a/entity/Employee_entity/onValidation.js +++ b/entity/Employee_entity/onValidation.js @@ -2,5 +2,6 @@ import("system.translate"); import("system.result"); import("system.vars"); -if (vars.get("$field.PASSWORD") != vars.get("$field.CONFIRM_PASSWORD")) - result.string(translate.text("Password and confirmation must be the same!")); \ No newline at end of file +if (vars.exists("$param.PasswordChange_param") && vars.get("$param.PasswordChange_param") + && vars.get("$field.PASSWORD") != vars.get("$field.CONFIRM_PASSWORD")) + result.string(translate.text("Password and confirmation must be the same!")); \ No newline at end of file diff --git a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js index 19d308f3b3..025da7c21d 100644 --- a/entity/Employee_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/Employee_entity/recordcontainers/jdito/contentProcess.js @@ -34,8 +34,8 @@ users = users.map(function (user) user[tools.PARAMS][tools.EMAIL], user[tools.DESCRIPTION], user[tools.PARAMS][tools.CONTACTID], //8 - null, //9 user[tools.PARAMS].department, + null, "", fetchRoles ? tools.getRoles(user[tools.TITLE]) : [] //for filtering ]; diff --git a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js index 678bac1f03..fc86fe0666 100644 --- a/entity/Employee_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/Employee_entity/recordcontainers/jdito/onUpdate.js @@ -19,22 +19,24 @@ FieldChanges.assimilateChangeAndDispose("$field.IMAGE", function (state, value) PersUtils.removeImage(personId); }); -var user = tools.getUserByAttribute(tools.NAME, vars.get("$field.UID")); +var rowdata = vars.get("$local.rowdata"); -user[tools.TITLE] = vars.get("$field.TITLE"); -user[tools.PARAMS][tools.ISACTIVE] = vars.get("$field.ISACTIVE"); -user[tools.PARAMS][tools.FIRSTNAME] = vars.get("$field.FIRSTNAME"); -user[tools.PARAMS][tools.LASTNAME] = vars.get("$field.LASTNAME"); -user[tools.PARAMS][tools.EMAIL] = vars.get("$field.EMAIL_ADDRESS"); -user[tools.PARAMS][tools.CALENDARID] = vars.get("$field.EMAIL_ADDRESS"); -user[tools.PARAMS][tools.CONTACTID] = vars.get("$field.CONTACT_ID"); -user[tools.PARAMS][tools.DESCRIPTION] = vars.get("$field.DESCRIPTION"); -user[tools.PARAMS].department = vars.get("$field.DEPARTMENT"); +var user = tools.getUserByAttribute(tools.NAME, rowdata["UID.value"]); + +user[tools.TITLE] = rowdata["TITLE.value"]; +user[tools.PARAMS][tools.ISACTIVE] = rowdata["ISACTIVE.value"]; +user[tools.PARAMS][tools.FIRSTNAME] = rowdata["FIRSTNAME.value"]; +user[tools.PARAMS][tools.LASTNAME] = rowdata["LASTNAME.value"]; +user[tools.PARAMS][tools.EMAIL] = rowdata["EMAIL_ADDRESS.value"]; +user[tools.PARAMS][tools.CALENDARID] = rowdata["EMAIL_ADDRESS.value"]; +user[tools.PARAMS][tools.CONTACTID] = rowdata["CONTACT_ID.value"]; +user[tools.PARAMS][tools.DESCRIPTION] = rowdata["DESCRIPTION.value"]; +user[tools.PARAMS].department = rowdata["DEPARTMENT.value"]; if (vars.exists("$param.PasswordChange_param") && vars.get("$param.PasswordChange_param") - && vars.get("$field.PASSWORD") == vars.get("$field.CONFIRM_PASSWORD")) + && rowdata["PASSWORD.value"] == rowdata["CONFIRM_PASSWORD.value"]) { - user[tools.PASSWORD] = vars.getString("$field.PASSWORD"); + user[tools.PASSWORD] = rowdata["PASSWORD.value"]; } tools.updateUser(user); \ No newline at end of file diff --git a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js index 83b7fa427b..56da69ea93 100644 --- a/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/ObjectTree_entity/recordcontainers/jdito/contentProcess.js @@ -41,7 +41,7 @@ if (vars.exists("$param.Uid_param") && vars.get("$param.Uid_param")) else if(vars.exists("$local.idvalues") && vars.get("$local.idvalues") && vars.get("$local.idvalues").length > 0) uidParam = vars.get("$local.idvalues")[0]; -if (uidParam) +if (uidParam && uidParam.includes("[")) // "[" -> is JSON { // Load one by uid. Basically the data to return is also encoded in the uid itself -> no extra data loading is needed. let uid = JSON.parse(uidParam); @@ -53,6 +53,10 @@ if (uidParam) _insertEntry(tree, _getEntryData(uid[UID.objectId], relationTypeData[3], relationTypeData[7], relationTypeData[8], undefined, false, uid[UID.objectRelationId]), "", 0, uid[UID.otherObjectType], relationTypeData[10], relationTypeData[12], relationTypeData[4]); } +} +else if (uidParam) +{ + } else { @@ -231,7 +235,7 @@ function _loadObjectRelationTree(pObjectId, pObjectType, pObjectRelationTypeId, * @param {String} pRelationType2 * @param {String} [pPrevId=undefined] Id of the previous node to exclude it * @param {Boolean} [pNoRecursion=false] if false: select for direction "same" the other direction, if result is empty. - * @param {Boolean} [pObjectRelationId=false] provide if only one special node is needed + * @param {String} [pObjectRelationId] provide if only one special node is needed * * @return {[][]} */ diff --git a/process/Attribute_lib/process.js b/process/Attribute_lib/process.js index 7490f12d5f..d897d664cb 100644 --- a/process/Attribute_lib/process.js +++ b/process/Attribute_lib/process.js @@ -205,10 +205,13 @@ AttributeUtil.getPossibleListValues = function (pAttributeId, pAttributeType, pI * @param {String} pAttributeId the id of the attribute * @param {Boolean} [pSimpleName=false] Use only the name of the attribute and not the names of the parents. * @param {Boolean} [pTranslate=true] translate the name + * @param {Number} [pStartLayer=0] Group names to omit. Example: The attribute is "Departments / Distribution / Field staff". + * If you set this value to 1, "Departments / " will be removed, if set to 2, "Departments / Distribution / " will be removed and so on. + * The last name will never be removed to avoid an empty result if something is wrong. * * @return {String} the name of the attribute */ -AttributeUtil.getFullAttributeName = function (pAttributeId, pSimpleName, pTranslate) +AttributeUtil.getFullAttributeName = function (pAttributeId, pSimpleName, pTranslate, pStartLayer) { if (pSimpleName === undefined) pSimpleName = false; @@ -231,25 +234,28 @@ AttributeUtil.getFullAttributeName = function (pAttributeId, pSimpleName, pTrans if (attribute.length > 0) { - attributeNames.push(attribute[0]); + attributeNames.unshift(attribute[0]); if (attribute[1]) - attributeNames.push(attribute[1]); + attributeNames.unshift(attribute[1]); if (attribute[2]) - attributeNames.push(attribute[2]); + attributeNames.unshift(attribute[2]); pAttributeId = attribute[3]; } else pAttributeId = ""; } while (pAttributeId); + if (pStartLayer) + attributeNames = attributeNames.slice(pStartLayer < attributeNames.length ? pStartLayer : -1); + if (pTranslate) { - for (let i = 0; i < attributeNames.length; i++) + attributeNames = attributeNames.map(function (name) { - attributeNames[i] = translate.text(attributeNames[i]); - } + return translate.text(name); + }); } - return attributeNames.reverse().join(" / "); + return attributeNames.join(" / "); } /** -- GitLab