Skip to content
Snippets Groups Projects
Commit f46f2b44 authored by Sebastian Listl's avatar Sebastian Listl :speech_balloon:
Browse files

MSTeams actions stateProcesses

parent 8d159233
No related branches found
No related tags found
No related merge requests found
Showing
with 136 additions and 144 deletions
......@@ -22,20 +22,6 @@
<name>CampaignParticipantsProvider</name>
<documentation>%aditoprj%/entity/CampaignParticipant_entity/entityfields/campaignparticipantsprovider/documentation.adoc</documentation>
<recordContainer>db</recordContainer>
<dependencies>
<entityDependency>
<name>f28945cd-4613-4dfa-91f7-a7d9d64cef58</name>
<entityName>Campaign_entity</entityName>
<fieldName>CampaignParticipants</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>7ad08378-b36f-4512-8891-db727c6ddcd7</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignParticipantsConsumer</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
<children>
<entityParameter>
<name>ContactId_param</name>
......@@ -50,6 +36,20 @@
<expose v="true" />
</entityParameter>
</children>
<dependencies>
<entityDependency>
<name>f28945cd-4613-4dfa-91f7-a7d9d64cef58</name>
<entityName>Campaign_entity</entityName>
<fieldName>CampaignParticipants</fieldName>
<isConsumer v="false" />
</entityDependency>
<entityDependency>
<name>7ad08378-b36f-4512-8891-db727c6ddcd7</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignParticipantsConsumer</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityParameter>
<name>CampaignStepId_param</name>
......@@ -144,11 +144,6 @@
<entityConsumer>
<name>CampaignSteps</name>
<refreshParent v="true" />
<dependency>
<name>dependency</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignSteps</fieldName>
</dependency>
<children>
<entityParameter>
<name>campaignId_param</name>
......@@ -156,6 +151,11 @@
<expose v="true" />
</entityParameter>
</children>
<dependency>
<name>dependency</name>
<entityName>CampaignStep_entity</entityName>
<fieldName>CampaignSteps</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>CONTACTCONTEXT</name>
......@@ -203,17 +203,17 @@
</entityConsumer>
<entityConsumer>
<name>CommRestrictionIcon</name>
<dependency>
<name>dependency</name>
<entityName>KeywordAttribute_entity</entityName>
<fieldName>SpecificContainerKeyword</fieldName>
</dependency>
<children>
<entityParameter>
<name>ContainerName_param</name>
<valueProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/commrestrictionicon/children/containername_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
<dependency>
<name>dependency</name>
<entityName>KeywordAttribute_entity</entityName>
<fieldName>SpecificContainerKeyword</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>STANDARD_EMAIL_COMMUNICATION</name>
......@@ -271,7 +271,7 @@
</entityConsumer>
<entityField>
<name>RESPONSIBLE_CONTACT_ID</name>
<title>Verantwortlicher</title>
<title>Responsible</title>
<consumer>ResponsibleEmployees</consumer>
<groupable v="true" />
<linkedContext>Person</linkedContext>
......
import("Util_lib");
import("MSTeams_lib");
import("system.vars");
import("system.neon");
import("system.result");
import("Sql_lib");
var isArchived = Utils.toBoolean(newSelect("IS_ARCHIVED")
.from("MST_TEAM")
.whereIfSet("MST_TEAM.MST_TEAMID", "$param.MSTTeamId_param")
.cell(true));
result.string(isArchived ? neon.COMPONENTSTATE_DISABLED : neon.COMPONENTSTATE_EDITABLE);
\ No newline at end of file
var isEnabled = MSTeamsUtils.isTeamsEnabled() && MSTeamsUtils.isTeamActive(vars.get("$param.MSTTeamId_param"));
result.string(isEnabled ? neon.COMPONENTSTATE_EDITABLE : neon.COMPONENTSTATE_DISABLED);
\ No newline at end of file
......@@ -3,5 +3,5 @@ import("system.project");
import("system.vars");
var appId = project.getInstanceConfigValue("teamsAppId", null);
if (appId != null)
if (appId)
teams.addApp(vars.get("$param.MSTTeamId_param"), appId);
\ No newline at end of file
......@@ -5,27 +5,12 @@ 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 teamId = vars.get("$param.MSTTeamId_param");
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);
if (teamData)
[isArchived, serviceUrl] = teamData;
if (isArchived == 1 || serviceUrl)
{
res = neon.COMPONENTSTATE_DISABLED;
}
else
{
var teamInfo = MSTeamsUtils.getTeamInfo(teamId);
if (teamInfo && !teamInfo.isArchived && !teamInfo.serviceUrl)
res = neon.COMPONENTSTATE_EDITABLE;
}
}
result.string(res);
\ No newline at end of file
......@@ -2,30 +2,14 @@ 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 teamId = vars.get("$param.MSTTeamId_param");
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);
if (teamData)
[isArchived, serviceUrl] = teamData;
if (isArchived == 1 || serviceUrl || !MSTeamsUtils.isUserTeamOwner(teamId))
{
res = neon.COMPONENTSTATE_DISABLED;
}
else
{
var teamInfo = MSTeamsUtils.getTeamInfo(teamId);
if (teamInfo && !teamInfo.isArchived && !teamInfo.serviceUrl && MSTeamsUtils.isUserTeamOwner(teamId))
res = neon.COMPONENTSTATE_EDITABLE;
}
}
result.string(res);
\ No newline at end of file
......@@ -2,30 +2,12 @@ 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);
if (teamData)
[isArchived, serviceUrl] = teamData;
if (isArchived == 1 || !MSTeamsUtils.isUserTeamOwner(teamId))
{
res = neon.COMPONENTSTATE_DISABLED;
}
else
{
res = neon.COMPONENTSTATE_EDITABLE;
}
var teamId = vars.get("$param.MSTTeamId_param");
if (teamId && MSTeamsUtils.isTeamsEnabled() && MSTeamsUtils.isTeamActive(teamId) && MSTeamsUtils.isUserTeamOwner(teamId))
{
res = neon.COMPONENTSTATE_EDITABLE;
}
result.string(res);
\ No newline at end of file
import("Sql_lib");
import("MSTeams_lib");
import("system.vars");
import("system.neon");
var webUrl = newSelect("WEB_URL")
.from("MST_TEAM")
.whereIfSet("MST_TEAM.MST_TEAMID", "$param.MSTTeamId_param")
.cell(true);
var teamInfo = MSTeamsUtils.getTeamInfo(vars.get("$param.MSTTeamId_param"));
if (webUrl)
neon.openUrl(webUrl, true);
if (teamInfo && teamInfo.webUrl)
neon.openUrl(teamInfo.webUrl, true);
......@@ -5,22 +5,10 @@ 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 teamId = vars.get("$param.MSTTeamId_param");
if (teamId && MSTeamsUtils.isTeamsEnabled() && MSTeamsUtils.isTeamActive(teamId))
{
var isArchived = newSelect("IS_ARCHIVED")
.from("MST_TEAM")
.whereIfSet("MST_TEAM.MST_TEAMID", teamId)
.cell(true);
if (isArchived == 1)
{
res = neon.COMPONENTSTATE_DISABLED;
}
else
{
res = neon.COMPONENTSTATE_EDITABLE;
}
res = neon.COMPONENTSTATE_EDITABLE;
}
result.string(res);
\ No newline at end of file
......@@ -5,27 +5,12 @@ 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 teamId = vars.get("$param.MSTTeamId_param");
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);
if (teamData)
[isArchived, serviceUrl] = teamData;
if (isArchived == 0)
{
res = neon.COMPONENTSTATE_DISABLED;
}
else
{
{
var teamInfo = MSTeamsUtils.getTeamInfo(teamId);
if (teamInfo && teamInfo.isArchived)
res = neon.COMPONENTSTATE_EDITABLE;
}
}
result.string(res);
\ No newline at end of file
......@@ -7566,6 +7566,12 @@
<entry>
<key>Exports the knowledge entry as a html file</key>
</entry>
<entry>
<key>The max participants count can not be equal or less then 0</key>
</entry>
<entry>
<key>Illegal Parent Operator in buildFilterObj-Function:</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
<sqlModels>
......
......@@ -7647,6 +7647,12 @@
<entry>
<key>Exports the knowledge entry as a html file</key>
</entry>
<entry>
<key>The max participants count can not be equal or less then 0</key>
</entry>
<entry>
<key>Illegal Parent Operator in buildFilterObj-Function:</key>
</entry>
</keyValueMap>
<font name="Dialog" style="0" size="11" />
</language>
......@@ -5,7 +5,7 @@
<dashletConfigurations>
<neonDashletConfiguration>
<name>CampaignCostsChart</name>
<title>Campaign costs</title>
<title>Campaign Costs</title>
<description>Shows campaing costs graphically processed</description>
<fragment>Campaign/full</fragment>
<singleton v="true" />
......
......@@ -8,7 +8,7 @@
<dashletConfigurations>
<neonDashletConfiguration>
<name>CurrentUsersOwnedCampaigns</name>
<title>My campaigns</title>
<title>My Campaigns</title>
<description>Show my campaigns</description>
<fragment>Campaign/filter</fragment>
<singleton v="true" />
......
......@@ -195,7 +195,10 @@ MSTeamsUtils.getLinkedTeam = function (pRowId, pObjectType)
}
/**
* Loads the contactIds associated with the given azureIds
*
* @param {String[]} pAzureIds azureIds of the users
* @return {Object} object with the azureIds as keys and the corresponding contactIds as values
*/
MSTeamsUtils.getContactIdsByAzureIds = function (pAzureIds)
{
......@@ -213,21 +216,32 @@ MSTeamsUtils.getContactIdsByAzureIds = function (pAzureIds)
}
/**
* Generates a sql expression to resolve the roles in a team for the contacts
*
* @param {String} pTeamId id of the team
* @param {String} pContactIdField sql field that contains the contactId that is used for selecting the role
* @return {String} sql expression
*/
MSTeamsUtils.getTeamRoleSubSql = function (pTeamId, pContactIdField)
{
if (!pTeamId)
return "''";
var ownerIds = Object.keys(teams.getAllOwners(pTeamId));
var ownerContactIds = MSTeamsUtils.getContactIdsByAzureIds(ownerIds);
ownerContactIds = Utils.objectValues(ownerContactIds);
var members = teams.getAllMembers(pTeamId);
var memberIds = Object.keys(members);
var memberContactIds = MSTeamsUtils.getContactIdsByAzureIds(memberIds);
memberContactIds = Utils.objectValues(memberContactIds);
try {
var ownerIds = Object.keys(teams.getAllOwners(pTeamId));
var ownerContactIds = MSTeamsUtils.getContactIdsByAzureIds(ownerIds);
ownerContactIds = Utils.objectValues(ownerContactIds);
var members = teams.getAllMembers(pTeamId);
var memberIds = Object.keys(members);
var memberContactIds = MSTeamsUtils.getContactIdsByAzureIds(memberIds);
memberContactIds = Utils.objectValues(memberContactIds);
}
catch (err)
{
logging.log(err, logging.ERROR);
return "''";
}
if (ownerContactIds.length === 0 && memberContactIds.length === 0)
return "''";
......@@ -246,7 +260,11 @@ MSTeamsUtils.getTeamRoleSubSql = function (pTeamId, pContactIdField)
}
/**
* Checks if the user is an owner of the team
*
* @param {String} pTeamId the id of the team
* @param {String} [pUserId=current user] the userId of the user
* @return {Boolean} true if the user is an owner
*/
MSTeamsUtils.isUserTeamOwner = function (pTeamId, pUserId)
{
......@@ -259,4 +277,50 @@ MSTeamsUtils.isUserTeamOwner = function (pTeamId, pUserId)
if (!user)
return false;
return user[tools.PARAMS][tools.TEAMS_AZUREID] in teams.getAllOwners(pTeamId);
}
/**
* Loads the properties of the team from the database.
*
* @param {String} pTeamId the id of the team
* @return {Object} Object with these properties:
* <ul>
* <li>teamName</li>
* <li>webUrl</li>
* <li>serviceUrl</li>
* <li>isArchived</li>
* <li>generalChannelId</li>
* </ul>
* If the team was not found, null is returned.
*/
MSTeamsUtils.getTeamInfo = function (pTeamId)
{
var teamInfo = new SqlBuilder("Data_alias")
.select(["TEAMNAME", "WEB_URL", "SERVICE_URL", "IS_ARCHIVED", "GENERAL_CHANNELID"])
.from("MST_TEAM")
.whereIfSet("MST_TEAM.MST_TEAMID", pTeamId)
.arrayRow(true);
if (teamInfo.length === 0)
return null;
return {
teamName: teamInfo[0],
webUrl: teamInfo[1],
serviceUrl: teamInfo[2],
isArchived: Utils.toBoolean(teamInfo[3]),
generalChannelId: teamInfo[4]
};
}
/**
* Checks if the team is active
*
* @param {String} pTeamId the id of the team
* @return {Boolean} true, if the team exists and is not archived
*/
MSTeamsUtils.isTeamActive = function (pTeamId)
{
var teamInfo = MSTeamsUtils.getTeamInfo(pTeamId);
return teamInfo != null && !teamInfo.isArchived;
}
\ No newline at end of file
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