From 6fdec02388ba7822ac4bd23116ff966a9831f37d Mon Sep 17 00:00:00 2001 From: "S.Listl" <S.Listl@SLISTL.aditosoftware.local> Date: Thu, 4 Apr 2019 13:49:25 +0200 Subject: [PATCH] Employee bugfix --- entity/Employee_entity/Employee_entity.aod | 5 ++-- .../entityfields/contact_id/onValueChange.js | 25 +++++++++++++++++++ .../entityfields/contact_id/stateProcess.js | 7 ++++++ .../email_address/onValidation.js | 13 ++++++---- .../email_address/possibleItemsProcess.js | 2 +- .../email_address/valueProcess.js | 17 ------------- .../entityfields/firstname/valueProcess.js | 16 ------------ .../entityfields/lastname/valueProcess.js | 16 ------------ .../_____PREFERENCES_PROJECT.aod | 2 +- 9 files changed, 44 insertions(+), 59 deletions(-) create mode 100644 entity/Employee_entity/entityfields/contact_id/onValueChange.js create mode 100644 entity/Employee_entity/entityfields/contact_id/stateProcess.js delete mode 100644 entity/Employee_entity/entityfields/email_address/valueProcess.js delete mode 100644 entity/Employee_entity/entityfields/firstname/valueProcess.js delete mode 100644 entity/Employee_entity/entityfields/lastname/valueProcess.js diff --git a/entity/Employee_entity/Employee_entity.aod b/entity/Employee_entity/Employee_entity.aod index c1a5ae6a1ca..748fd22d321 100644 --- a/entity/Employee_entity/Employee_entity.aod +++ b/entity/Employee_entity/Employee_entity.aod @@ -31,18 +31,18 @@ <consumer>Contacts</consumer> <linkedContext>Person</linkedContext> <mandatory v="true" /> + <stateProcess>%aditoprj%/entity/Employee_entity/entityfields/contact_id/stateProcess.js</stateProcess> <onValidation>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValidation.js</onValidation> + <onValueChange>%aditoprj%/entity/Employee_entity/entityfields/contact_id/onValueChange.js</onValueChange> </entityField> <entityField> <name>FIRSTNAME</name> <title>Firstname</title> - <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/firstname/valueProcess.js</valueProcess> </entityField> <entityField> <name>LASTNAME</name> <title>Lastname</title> <mandatory v="false" /> - <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/lastname/valueProcess.js</valueProcess> </entityField> <entityField> <name>ISACTIVE</name> @@ -57,7 +57,6 @@ <mandatory v="true" /> <possibleItemsProcess>%aditoprj%/entity/Employee_entity/entityfields/email_address/possibleItemsProcess.js</possibleItemsProcess> <newItemsAllowed v="true" /> - <valueProcess>%aditoprj%/entity/Employee_entity/entityfields/email_address/valueProcess.js</valueProcess> <onValidation>%aditoprj%/entity/Employee_entity/entityfields/email_address/onValidation.js</onValidation> </entityField> <entityField> diff --git a/entity/Employee_entity/entityfields/contact_id/onValueChange.js b/entity/Employee_entity/entityfields/contact_id/onValueChange.js new file mode 100644 index 00000000000..8b8af980eac --- /dev/null +++ b/entity/Employee_entity/entityfields/contact_id/onValueChange.js @@ -0,0 +1,25 @@ +import("Communication_lib"); +import("Entity_lib"); +import("system.result"); +import("system.db"); +import("system.neon"); +import("system.vars"); +import("Sql_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) + && contactId) +{ + var name = db.array( + db.ROW, + SqlCondition.begin() + .andPrepare("CONTACT.CONTACTID", contactId) + .buildSql("select FIRSTNAME, LASTNAME, (" + CommUtil.getStandardSubSqlMail() + ") from PERSON join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID") + ); + + neon.setFieldValues({ + "$field.FIRSTNAME" : name[0] || "", + "$field.LASTNAME" : name[1] || "", + "$field.EMAIL_ADDRESS" : name[2] || "" + }); +} \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/contact_id/stateProcess.js b/entity/Employee_entity/entityfields/contact_id/stateProcess.js new file mode 100644 index 00000000000..465a0be94ed --- /dev/null +++ b/entity/Employee_entity/entityfields/contact_id/stateProcess.js @@ -0,0 +1,7 @@ +import("system.neon"); +import("system.vars"); +import("system.result"); +import("Employee_lib") + +if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT && EmployeeUtils.hasRelations(vars.get("$field.CONTACT_ID"))) + result.string(neon.COMPONENTSTATE_READONLY); \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/email_address/onValidation.js b/entity/Employee_entity/entityfields/email_address/onValidation.js index f6a829134cf..35d65102d1e 100644 --- a/entity/Employee_entity/entityfields/email_address/onValidation.js +++ b/entity/Employee_entity/entityfields/email_address/onValidation.js @@ -1,10 +1,13 @@ -import("system.translate"); -import("system.neon"); +import("Entity_lib"); import("system.result"); import("system.vars"); import("system.tools"); -import("Entity_lib"); +import("system.translate"); var email = ProcessHandlingUtils.getOnValidationValue(vars.get("$field.EMAIL_ADDRESS")); -if (email != "" && tools.getUsersByAttribute(tools.EMAIL, [email]).length) - result.string(translate.text("Email must be unique!")); \ No newline at end of file +var isTaken = tools.getUserByAttribute(tools.EMAIL, [email]); +isTaken = isTaken + ? isTaken[tools.TITLE] != vars.get("$field.TITLE_ORIGINAL") + : false; +if (email && isTaken) + result.string(translate.text("Email must be unique!")); \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/email_address/possibleItemsProcess.js b/entity/Employee_entity/entityfields/email_address/possibleItemsProcess.js index a171cd824ec..21bbfcda32c 100644 --- a/entity/Employee_entity/entityfields/email_address/possibleItemsProcess.js +++ b/entity/Employee_entity/entityfields/email_address/possibleItemsProcess.js @@ -27,4 +27,4 @@ if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.r result.object(addresses); } else - result.object([]) + result.object([]); diff --git a/entity/Employee_entity/entityfields/email_address/valueProcess.js b/entity/Employee_entity/entityfields/email_address/valueProcess.js deleted file mode 100644 index 7931dce1d63..00000000000 --- a/entity/Employee_entity/entityfields/email_address/valueProcess.js +++ /dev/null @@ -1,17 +0,0 @@ -import("system.result"); -import("system.db"); -import("system.neon"); -import("system.vars"); -import("Sql_lib"); -import("Communication_lib"); - -var contactId = vars.get("$field.CONTACT_ID"); -if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) - && contactId && !vars.get("$field.EMAIL_ADDRESS")) -{ - var defaultMail = db.cell(SqlCondition.begin() - .andPrepare("CONTACT.CONTACTID", contactId) - .buildSql("select (" + CommUtil.getStandardSubSqlMail() + ") from CONTACT") - ); - result.string(defaultMail); -} \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/firstname/valueProcess.js b/entity/Employee_entity/entityfields/firstname/valueProcess.js deleted file mode 100644 index f118b02d965..00000000000 --- a/entity/Employee_entity/entityfields/firstname/valueProcess.js +++ /dev/null @@ -1,16 +0,0 @@ -import("system.result"); -import("system.db"); -import("system.neon"); -import("system.vars"); -import("Sql_lib"); - -var contactId = vars.get("$field.CONTACT_ID"); -if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) - && contactId && !vars.get("$field.FIRSTNAME")) -{ - var firstname = db.cell(SqlCondition.begin() - .andPrepare("CONTACT.CONTACTID", contactId) - .buildSql("select FIRSTNAME from PERSON join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID") - ); - result.string(firstname); -} \ No newline at end of file diff --git a/entity/Employee_entity/entityfields/lastname/valueProcess.js b/entity/Employee_entity/entityfields/lastname/valueProcess.js deleted file mode 100644 index d0f5d394fa6..00000000000 --- a/entity/Employee_entity/entityfields/lastname/valueProcess.js +++ /dev/null @@ -1,16 +0,0 @@ -import("system.result"); -import("system.db"); -import("system.neon"); -import("system.vars"); -import("Sql_lib"); - -var contactId = vars.get("$field.CONTACT_ID"); -if ((vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT) - && contactId && !vars.get("$field.LASTNAME")) -{ - var lastname = db.cell(SqlCondition.begin() - .andPrepare("CONTACT.CONTACTID", contactId) - .buildSql("select LASTNAME from PERSON join CONTACT on CONTACT.PERSON_ID = PERSON.PERSONID") - ); - result.string(lastname); -} \ No newline at end of file diff --git a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod index 35430f5089f..2e627c2e517 100644 --- a/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod +++ b/preferences/_____PREFERENCES_PROJECT/_____PREFERENCES_PROJECT.aod @@ -2,7 +2,7 @@ <preferences xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="3.1.0" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/preferences/3.1.0"> <name>_____PREFERENCES_PROJECT</name> <majorModelMode>DISTRIBUTED</majorModelMode> - <projectName>xRM-Basic5</projectName> + <projectName>xRM-Basic2019</projectName> <jditoMaxContentSize v="57671680" /> <calendarCategoriesEvent> <entry> -- GitLab