From b2aef50b8cb1dcbcd6a74f6fce6e13f574622edb Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Wed, 16 Sep 2020 15:45:27 +0200 Subject: [PATCH] MSTeams: Member: validation bugfixing --- .../MSTTeamMember_entity.aod | 4 ++-- .../entityfields/invite/mandatoryProcess.js | 4 ---- .../entityfields/role/mandatoryProcess.js | 4 ---- entity/MSTTeamMember_entity/onValidation.js | 21 +++++++++++++++++++ .../recordcontainers/jdito/onUpdate.js | 2 ++ .../recordcontainers/jdito/onUpdate.js | 11 ++++++++-- 6 files changed, 34 insertions(+), 12 deletions(-) delete mode 100644 entity/MSTTeamMember_entity/entityfields/invite/mandatoryProcess.js delete mode 100644 entity/MSTTeamMember_entity/entityfields/role/mandatoryProcess.js create mode 100644 entity/MSTTeamMember_entity/onValidation.js create mode 100644 entity/MSTTeamMember_entity/recordcontainers/jdito/onUpdate.js diff --git a/entity/MSTTeamMember_entity/MSTTeamMember_entity.aod b/entity/MSTTeamMember_entity/MSTTeamMember_entity.aod index 5dfff61a5e..4847be9300 100644 --- a/entity/MSTTeamMember_entity/MSTTeamMember_entity.aod +++ b/entity/MSTTeamMember_entity/MSTTeamMember_entity.aod @@ -4,6 +4,7 @@ <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/MSTTeamMember_entity/documentation.adoc</documentation> <siblings /> + <onValidation>%aditoprj%/entity/MSTTeamMember_entity/onValidation.js</onValidation> <recordContainer>jdito</recordContainer> <entityFields> <entityProvider> @@ -89,14 +90,12 @@ <entityField> <name>ROLE</name> <title>Role</title> - <mandatoryProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/role/mandatoryProcess.js</mandatoryProcess> <dropDownProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/role/dropDownProcess.js</dropDownProcess> <stateProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/role/stateProcess.js</stateProcess> </entityField> <entityField> <name>INVITE</name> <title>Invitation</title> - <mandatoryProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/invite/mandatoryProcess.js</mandatoryProcess> <dropDownProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/invite/dropDownProcess.js</dropDownProcess> <stateProcess>%aditoprj%/entity/MSTTeamMember_entity/entityfields/invite/stateProcess.js</stateProcess> </entityField> @@ -112,6 +111,7 @@ <contentProcess>%aditoprj%/entity/MSTTeamMember_entity/recordcontainers/jdito/contentProcess.js</contentProcess> <hasDependentRecords v="true" /> <onInsert>%aditoprj%/entity/MSTTeamMember_entity/recordcontainers/jdito/onInsert.js</onInsert> + <onUpdate>%aditoprj%/entity/MSTTeamMember_entity/recordcontainers/jdito/onUpdate.js</onUpdate> <onDelete>%aditoprj%/entity/MSTTeamMember_entity/recordcontainers/jdito/onDelete.js</onDelete> <recordFieldMappings> <jDitoRecordFieldMapping> diff --git a/entity/MSTTeamMember_entity/entityfields/invite/mandatoryProcess.js b/entity/MSTTeamMember_entity/entityfields/invite/mandatoryProcess.js deleted file mode 100644 index 5d08620853..0000000000 --- a/entity/MSTTeamMember_entity/entityfields/invite/mandatoryProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.result"); -import("system.vars"); - -result.string(!vars.get("$field.MEMBERNAME") && vars.get("$field.ISEXTERN") == "true"); \ No newline at end of file diff --git a/entity/MSTTeamMember_entity/entityfields/role/mandatoryProcess.js b/entity/MSTTeamMember_entity/entityfields/role/mandatoryProcess.js deleted file mode 100644 index 5015e9937f..0000000000 --- a/entity/MSTTeamMember_entity/entityfields/role/mandatoryProcess.js +++ /dev/null @@ -1,4 +0,0 @@ -import("system.result"); -import("system.vars"); - -result.string(vars.get("$field.ISEXTERN") != "true"); \ No newline at end of file diff --git a/entity/MSTTeamMember_entity/onValidation.js b/entity/MSTTeamMember_entity/onValidation.js new file mode 100644 index 0000000000..9db830c5c6 --- /dev/null +++ b/entity/MSTTeamMember_entity/onValidation.js @@ -0,0 +1,21 @@ +import("system.translate"); +import("system.result"); +import("system.vars"); + +var isExtern = vars.getString("$field.ISEXTERN") == "true"; +var res; + +if (vars.get("$field.CONTACT_ID")) +{ + if (isExtern && !vars.get("$field.INVITE")) + { + res = translate.withArguments("Required value for %0 is missing", [vars.get("$property.INVITE.title")]); + } + else if(!isExtern && !vars.get("$field.ROLE")) + { + res = translate.withArguments("Required value for %0 is missing", [vars.get("$property.ROLE.title")]); + } +} + +if (res) + result.string(res); \ No newline at end of file diff --git a/entity/MSTTeamMember_entity/recordcontainers/jdito/onUpdate.js b/entity/MSTTeamMember_entity/recordcontainers/jdito/onUpdate.js new file mode 100644 index 0000000000..1df92b6ad9 --- /dev/null +++ b/entity/MSTTeamMember_entity/recordcontainers/jdito/onUpdate.js @@ -0,0 +1,2 @@ +//updating is done in the MSTTeam_entity +var dummy = "dummy"; \ No newline at end of file diff --git a/entity/MSTTeam_entity/recordcontainers/jdito/onUpdate.js b/entity/MSTTeam_entity/recordcontainers/jdito/onUpdate.js index 9219ab01d6..07569b024b 100644 --- a/entity/MSTTeam_entity/recordcontainers/jdito/onUpdate.js +++ b/entity/MSTTeam_entity/recordcontainers/jdito/onUpdate.js @@ -10,12 +10,12 @@ var teamId = rowData["UID.value"]; var teamName = rowData["TEAMNAME.value"]; var description = rowData["DESCRIPTION.value"]; var insertedTeamMembers = vars.get("$field.TeamMembers.insertedRows"); +var changedTeamMembers = vars.get("$field.TeamMembers.changedRows"); var deletedTeamMembers = vars.get("$field.TeamMembers.deletedRows"); var internalMembers = []; var externalMembers = []; -insertedTeamMembers.forEach(function (teamMember) -{ +insertedTeamMembers.forEach(function (teamMember){ var memberUser = EmployeeUtils.getUserByContactId(teamMember["CONTACT_ID"]); if (!memberUser) { @@ -45,6 +45,13 @@ if (internalMembers.length !== 0) if (externalMembers.length !== 0) teams.addExternalMembers(teamId, externalMembers); +changedTeamMembers.forEach(function (teamMember){ + var memberUser = EmployeeUtils.getUserByContactId(teamMember["CONTACT_ID"]); + + //teams.changeRole(teamId, ); +}); + + var owners = teams.getAllOwners(teamId); var removeMembers = deletedTeamMembers.map(function (member) { -- GitLab