From d84c7ec3f2525ade7324c170512be1930597dcef Mon Sep 17 00:00:00 2001 From: "j.goderbauer" <j.goderbauer@adito.de> Date: Wed, 16 Sep 2020 16:21:25 +0200 Subject: [PATCH] MSTeams: disabling should hide all fields --- entity/Member_entity/Member_entity.aod | 5 --- .../children/addapp/stateProcess.js | 36 +++++++++++-------- .../children/changetomsteam/stateProcess.js | 30 +++++++++------- .../children/deleteteam/stateProcess.js | 34 +++++++++++------- .../children/editteam/stateProcess.js | 34 +++++++++++------- .../children/restoreteam/stateProcess.js | 33 +++++++++++------ .../Salesproject_entity.aod | 2 +- .../mst_team_id/displayValueProcess.js | 16 ++++++--- .../entityfields/mst_team_id/stateProcess.js | 8 ++++- 9 files changed, 125 insertions(+), 73 deletions(-) diff --git a/entity/Member_entity/Member_entity.aod b/entity/Member_entity/Member_entity.aod index b0538033f66..f30e99f773a 100644 --- a/entity/Member_entity/Member_entity.aod +++ b/entity/Member_entity/Member_entity.aod @@ -229,7 +229,6 @@ <iconId>NEON:PLUS</iconId> <state>EDITABLE</state> <stateProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/createteam/stateProcess.js</stateProcess> - <tooltip>Erstelle ein neues MicrosoftTeams Team</tooltip> </entityActionField> <entityActionField> <name>editTeam</name> @@ -244,7 +243,6 @@ <onActionProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/onActionProcess.js</onActionProcess> <iconId>VAADIN:MOBILE</iconId> <stateProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/stateProcess.js</stateProcess> - <tooltip>Adds the MST ADITO App to the MSTTeam</tooltip> </entityActionField> <entityActionField> <name>chooseTeam</name> @@ -252,7 +250,6 @@ <onActionProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/chooseteam/onActionProcess.js</onActionProcess> <iconId>NEON:GROUP_APPOINTMENT</iconId> <stateProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/chooseteam/stateProcess.js</stateProcess> - <tooltip>Wähle ein bereits hinterlegtes Team</tooltip> </entityActionField> <entityActionField> <name>restoreTeam</name> @@ -260,7 +257,6 @@ <onActionProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/onActionProcess.js</onActionProcess> <iconId>VAADIN:ARROW_BACKWARD</iconId> <stateProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/stateProcess.js</stateProcess> - <tooltip>Stelle das Team wieder her</tooltip> </entityActionField> <entityActionField> <name>changeToMSTeam</name> @@ -275,7 +271,6 @@ <onActionProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/onActionProcess.js</onActionProcess> <iconId>NEON:TRASH</iconId> <stateProcess>%aditoprj%/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/stateProcess.js</stateProcess> - <tooltip>Lösche das verknüpfte MSTeams Team</tooltip> </entityActionField> </children> </entityActionGroup> diff --git a/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/stateProcess.js b/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/stateProcess.js index 2446336fdb5..8c22d355887 100644 --- a/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/stateProcess.js +++ b/entity/Member_entity/entityfields/msteamsactiongroup/children/addapp/stateProcess.js @@ -1,25 +1,31 @@ +import("MSTeams_lib"); import("system.vars"); import("system.neon"); import("system.result"); import("Sql_lib"); +var res = neon.COMPONENTSTATE_DISABLED; var teamId = vars.exists("$param.MSTTeamId_param") ? vars.get("$param.MSTTeamId_param") : null; +if (teamId && MSTeamsUtils.isTeamsEnabled()) +{ + var isArchived, serviceUrl; + var teamData = newSelect("IS_ARCHIVED, SERVICE_URL") + .from("MST_TEAM") + .whereIfSet("MST_TEAM.MST_TEAMID", teamId) + .arrayRow(true); -var isArchived, serviceUrl; -var teamData = newSelect("IS_ARCHIVED, SERVICE_URL") - .from("MST_TEAM") - .whereIfSet("MST_TEAM.MST_TEAMID", teamId) - .arrayRow(true); + if (teamData) + [isArchived, serviceUrl] = teamData; -if (teamData) - [isArchived, serviceUrl] = teamData; - -if (teamId == "" || isArchived == 1 || serviceUrl) -{ - result.string(neon.COMPONENTSTATE_DISABLED); + if (isArchived == 1 || serviceUrl) + { + res = neon.COMPONENTSTATE_DISABLED; + } + else + { + res = neon.COMPONENTSTATE_EDITABLE; + } } -else -{ - result.string(neon.COMPONENTSTATE_EDITABLE); -} \ No newline at end of file + +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/entityfields/msteamsactiongroup/children/changetomsteam/stateProcess.js b/entity/Member_entity/entityfields/msteamsactiongroup/children/changetomsteam/stateProcess.js index 5a91fdde73f..43b7cdd5ead 100644 --- a/entity/Member_entity/entityfields/msteamsactiongroup/children/changetomsteam/stateProcess.js +++ b/entity/Member_entity/entityfields/msteamsactiongroup/children/changetomsteam/stateProcess.js @@ -1,20 +1,26 @@ +import("MSTeams_lib"); import("system.vars"); import("system.neon"); import("system.result"); import("Sql_lib"); +var res = neon.COMPONENTSTATE_DISABLED; var teamId = vars.exists("$param.MSTTeamId_param") ? vars.get("$param.MSTTeamId_param") : null; - -var isArchived = newSelect("IS_ARCHIVED") - .from("MST_TEAM") - .whereIfSet("MST_TEAM.MST_TEAMID", teamId) - .cell(true); +if (teamId && MSTeamsUtils.isTeamsEnabled()) +{ + var isArchived = newSelect("IS_ARCHIVED") + .from("MST_TEAM") + .whereIfSet("MST_TEAM.MST_TEAMID", teamId) + .cell(true); -if (teamId == "" || isArchived == 1) -{ - result.string(neon.COMPONENTSTATE_DISABLED); + if (isArchived == 1) + { + res = neon.COMPONENTSTATE_DISABLED; + } + else + { + res = neon.COMPONENTSTATE_EDITABLE; + } } -else -{ - result.string(neon.COMPONENTSTATE_EDITABLE); -} \ No newline at end of file + +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/stateProcess.js b/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/stateProcess.js index d1432e9d7c5..ff7327ea214 100644 --- a/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/stateProcess.js +++ b/entity/Member_entity/entityfields/msteamsactiongroup/children/deleteteam/stateProcess.js @@ -1,21 +1,31 @@ +import("MSTeams_lib"); import("system.vars"); import("system.neon"); import("system.result"); import("Sql_lib"); -import("MSTeams_lib"); +var res = neon.COMPONENTSTATE_DISABLED; var teamId = vars.exists("$param.MSTTeamId_param") ? vars.get("$param.MSTTeamId_param") : null; - -var isArchived = newSelect("IS_ARCHIVED") +if (teamId && MSTeamsUtils.isTeamsEnabled()) +{ + var isArchived, serviceUrl; + var teamData = newSelect("IS_ARCHIVED, SERVICE_URL") .from("MST_TEAM") .whereIfSet("MST_TEAM.MST_TEAMID", teamId) - .cell(true); - -if (!teamId || isArchived == 1 || !MSTeamsUtils.isUserTeamOwner(teamId)) -{ - result.string(neon.COMPONENTSTATE_DISABLED); + .arrayRow(true); + + if (teamData) + [isArchived, serviceUrl] = teamData; + + + if (isArchived == 1 || serviceUrl || !MSTeamsUtils.isUserTeamOwner(teamId)) + { + res = neon.COMPONENTSTATE_DISABLED; + } + else + { + res = neon.COMPONENTSTATE_EDITABLE; + } } -else -{ - result.string(neon.COMPONENTSTATE_EDITABLE); -} \ No newline at end of file + +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/entityfields/msteamsactiongroup/children/editteam/stateProcess.js b/entity/Member_entity/entityfields/msteamsactiongroup/children/editteam/stateProcess.js index d1432e9d7c5..19d44a29c7a 100644 --- a/entity/Member_entity/entityfields/msteamsactiongroup/children/editteam/stateProcess.js +++ b/entity/Member_entity/entityfields/msteamsactiongroup/children/editteam/stateProcess.js @@ -1,21 +1,31 @@ +import("MSTeams_lib"); import("system.vars"); import("system.neon"); import("system.result"); import("Sql_lib"); -import("MSTeams_lib"); +var res = neon.COMPONENTSTATE_DISABLED; var teamId = vars.exists("$param.MSTTeamId_param") ? vars.get("$param.MSTTeamId_param") : null; - -var isArchived = newSelect("IS_ARCHIVED") +if (teamId && MSTeamsUtils.isTeamsEnabled()) +{ + var isArchived, serviceUrl; + var teamData = newSelect("IS_ARCHIVED, SERVICE_URL") .from("MST_TEAM") .whereIfSet("MST_TEAM.MST_TEAMID", teamId) - .cell(true); - -if (!teamId || isArchived == 1 || !MSTeamsUtils.isUserTeamOwner(teamId)) -{ - result.string(neon.COMPONENTSTATE_DISABLED); + .arrayRow(true); + + if (teamData) + [isArchived, serviceUrl] = teamData; + + + if (isArchived == 1 || !MSTeamsUtils.isUserTeamOwner(teamId)) + { + res = neon.COMPONENTSTATE_DISABLED; + } + else + { + res = neon.COMPONENTSTATE_EDITABLE; + } } -else -{ - result.string(neon.COMPONENTSTATE_EDITABLE); -} \ No newline at end of file + +result.string(res); \ No newline at end of file diff --git a/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/stateProcess.js b/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/stateProcess.js index 97ff04f9a94..f6f0a5da097 100644 --- a/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/stateProcess.js +++ b/entity/Member_entity/entityfields/msteamsactiongroup/children/restoreteam/stateProcess.js @@ -1,20 +1,31 @@ +import("MSTeams_lib"); import("system.vars"); import("system.neon"); import("system.result"); import("Sql_lib"); +var res = neon.COMPONENTSTATE_DISABLED; var teamId = vars.exists("$param.MSTTeamId_param") ? vars.get("$param.MSTTeamId_param") : null; - -var isArchived = newSelect("IS_ARCHIVED") +if (teamId && MSTeamsUtils.isTeamsEnabled()) +{ + var isArchived, serviceUrl; + var teamData = newSelect("IS_ARCHIVED, SERVICE_URL") .from("MST_TEAM") .whereIfSet("MST_TEAM.MST_TEAMID", teamId) - .cell(true); - -if (teamId == "" || isArchived == 0) -{ - result.string(neon.COMPONENTSTATE_DISABLED); + .arrayRow(true); + + if (teamData) + [isArchived, serviceUrl] = teamData; + + + if (isArchived == 0) + { + res = neon.COMPONENTSTATE_DISABLED; + } + else + { + res = neon.COMPONENTSTATE_EDITABLE; + } } -else -{ - result.string(neon.COMPONENTSTATE_EDITABLE); -} \ No newline at end of file + +result.string(res); \ No newline at end of file diff --git a/entity/Salesproject_entity/Salesproject_entity.aod b/entity/Salesproject_entity/Salesproject_entity.aod index 412fcc0f202..1d915910da7 100644 --- a/entity/Salesproject_entity/Salesproject_entity.aod +++ b/entity/Salesproject_entity/Salesproject_entity.aod @@ -754,7 +754,7 @@ <name>MST_TEAM_ID</name> <title>Teams group</title> <linkedContext>MSTTeam</linkedContext> - <state>READONLY</state> + <state>INVISIBLE</state> <stateProcess>%aditoprj%/entity/Salesproject_entity/entityfields/mst_team_id/stateProcess.js</stateProcess> <displayValueProcess>%aditoprj%/entity/Salesproject_entity/entityfields/mst_team_id/displayValueProcess.js</displayValueProcess> </entityField> diff --git a/entity/Salesproject_entity/entityfields/mst_team_id/displayValueProcess.js b/entity/Salesproject_entity/entityfields/mst_team_id/displayValueProcess.js index daf9387bb01..14271e09111 100644 --- a/entity/Salesproject_entity/entityfields/mst_team_id/displayValueProcess.js +++ b/entity/Salesproject_entity/entityfields/mst_team_id/displayValueProcess.js @@ -1,7 +1,15 @@ +import("MSTeams_lib"); import("system.result"); import("Sql_lib"); -result.string(newSelect("TEAMNAME") - .from("MST_TEAM") - .whereIfSet("MST_TEAM.MST_TEAMID", "$field.MST_TEAM_ID") - .cell(true)); \ No newline at end of file +var res; + +if (MSTeamsUtils.isTeamsEnabled()) + res = newSelect("TEAMNAME") + .from("MST_TEAM") + .whereIfSet("MST_TEAM.MST_TEAMID", "$field.MST_TEAM_ID") + .cell(true); +else + res = ""; + +result.string(res); \ No newline at end of file diff --git a/entity/Salesproject_entity/entityfields/mst_team_id/stateProcess.js b/entity/Salesproject_entity/entityfields/mst_team_id/stateProcess.js index ddf69aa437e..0a84b37c599 100644 --- a/entity/Salesproject_entity/entityfields/mst_team_id/stateProcess.js +++ b/entity/Salesproject_entity/entityfields/mst_team_id/stateProcess.js @@ -1,5 +1,11 @@ +import("MSTeams_lib"); import("system.result"); import("system.vars"); import("system.neon"); -result.string(vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT ? neon.COMPONENTSTATE_INVISIBLE : neon.COMPONENTSTATE_READONLY); \ No newline at end of file +var res = neon.COMPONENTSTATE_INVISIBLE; +var recordState = vars.get("$sys.recordstate"); +if (MSTeamsUtils.isTeamsEnabled() && recordState != neon.OPERATINGSTATE_NEW && recordState != neon.OPERATINGSTATE_EDIT) + res = neon.COMPONENTSTATE_READONLY; + +result.string(res); \ No newline at end of file -- GitLab