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

MSTTeamLink_entity

parent abbbca2a
No related branches found
No related tags found
No related merge requests found
Showing
with 162 additions and 19 deletions
......@@ -2,6 +2,11 @@
<entity xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.3.17" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/entity/1.3.17">
<name>MSTTeamLink_entity</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<siblings>
<element>Salesproject_entity</element>
<element>Member_entity</element>
</siblings>
<afterUiInit>%aditoprj%/entity/MSTTeamLink_entity/afterUiInit.js</afterUiInit>
<recordContainer>db</recordContainer>
<entityFields>
<entityProvider>
......@@ -17,12 +22,16 @@
<entityField>
<name>MST_TEAM_ID</name>
<title>Team</title>
<mandatory v="true" />
<valueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/mst_team_id/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>OBJECT_ROWID</name>
<valueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/object_rowid/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>OBJECT_TYPE</name>
<valueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/object_type/valueProcess.js</valueProcess>
</entityField>
<entityParameter>
<name>ObjectRowId_param</name>
......@@ -32,6 +41,26 @@
<name>ObjectType_param</name>
<expose v="true" />
</entityParameter>
<entityConsumer>
<name>Teams</name>
<dependency>
<name>dependency</name>
<entityName>MSTTeam_entity</entityName>
<fieldName>TeamsByIdAndName</fieldName>
</dependency>
</entityConsumer>
<entityField>
<name>TEAMNAME</name>
<valueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/teamname/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>TEAM_ID_AND_NAME</name>
<documentation>%aditoprj%/entity/MSTTeamLink_entity/entityfields/team_id_and_name/documentation.adoc</documentation>
<title>Team</title>
<consumer>Teams</consumer>
<valueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/team_id_and_name/valueProcess.js</valueProcess>
<displayValueProcess>%aditoprj%/entity/MSTTeamLink_entity/entityfields/team_id_and_name/displayValueProcess.js</displayValueProcess>
</entityField>
</entityFields>
<recordContainers>
<dbRecordContainer>
......@@ -40,6 +69,7 @@
<fromClauseProcess>%aditoprj%/entity/MSTTeamLink_entity/recordcontainers/db/fromClauseProcess.js</fromClauseProcess>
<conditionProcess>%aditoprj%/entity/MSTTeamLink_entity/recordcontainers/db/conditionProcess.js</conditionProcess>
<onDBInsert>%aditoprj%/entity/MSTTeamLink_entity/recordcontainers/db/onDBInsert.js</onDBInsert>
<onDBUpdate>%aditoprj%/entity/MSTTeamLink_entity/recordcontainers/db/onDBUpdate.js</onDBUpdate>
<linkInformation>
<linkInformation>
<name>178230f3-4ee4-4ec0-a7f6-4f4ddddbbb22</name>
......@@ -74,7 +104,7 @@
<recordfield>MST_TEAMLINK.OBJECT_TYPE</recordfield>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>MST_TEAM_ID.displayValue</name>
<name>TEAMNAME.value</name>
<recordfield>MST_TEAM.TEAMNAME</recordfield>
</dbRecordFieldMapping>
</recordFieldMappings>
......
import("system.vars");
import("system.neon");
import("system.entities");
//reload the teams once, because the cache might not be up-to-date
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT)
{
entities.invalidateCache("MSTTeam_entity", "jdito");
entities.getRows(entities.createConfigForLoadingConsumerRows()
.consumer("Teams")
.fields(["UID", "TEAMNAME", "TEAMID_AND_NAME", "ISARCHIVED", "DESCRIPTION"])
);
}
\ No newline at end of file
import("system.result");
import("system.neon");
import("system.vars");
import("Util_lib");
var teamIdAndName = Utils.parseJSON(vars.get("$field.TEAM_ID_AND_NAME"));
if (teamIdAndName && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT))
result.string(teamIdAndName[0]);
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(vars.get("$param.ObjectRowId_param"));
\ No newline at end of file
import("system.neon");
import("system.vars");
import("system.result");
if (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW)
result.string(vars.get("$param.ObjectType_param"));
\ No newline at end of file
import("system.vars");
import("system.result");
result.string(vars.get("$field.TEAMNAME"));
\ No newline at end of file
= TEAM_ID_AND_NAME
This field is used for selecting a MST team for the teamLink. Because we need both the id and the name from the team, it can't be selected
directly in the MST_TEAM_ID field, which contains only the id (and fetching the name afterwards using the id would be rather slow).
In new- or edit-mode, the two fields MST_TEAM_ID and TEAMNAME pull their values from this field. In view-mode, this field gets the value
from MST_TEAM_ID and TEAMNAME, because only these two fields are connected to the recordContainer.
\ No newline at end of file
import("system.result");
import("system.neon");
import("system.vars");
//in view-mode, load the values from the fields that are connected to the recordcontainer
if (vars.get("$sys.recordstate") != neon.OPERATINGSTATE_NEW && vars.get("$sys.recordstate") != neon.OPERATINGSTATE_EDIT)
result.string(JSON.stringify([vars.get("$field.MST_TEAM_ID"), vars.get("$field.TEAMNAME")]));
\ No newline at end of file
import("system.result");
import("system.neon");
import("system.vars");
import("Util_lib");
var teamIdAndName = Utils.parseJSON(vars.get("$field.TEAM_ID_AND_NAME"));
if (teamIdAndName && (vars.get("$sys.recordstate") == neon.OPERATINGSTATE_NEW || vars.get("$sys.recordstate") == neon.OPERATINGSTATE_EDIT))
result.string(teamIdAndName[1]);
\ No newline at end of file
......@@ -4,4 +4,9 @@ import("MSTeams_lib");
var teamLinkId = vars.get("$local.uid");
var rowData = vars.get("$local.rowdata");
//if the linked context is configured to have just one teamLink but the object already has a teamLink, the old teamLink will be deleted
MSTeamsUtils.purgeCorruptTeamLinks(rowData["MST_TEAMLINK.OBJECT_ROWID"], rowData["MST_TEAMLINK.OBJECT_TYPE"], teamLinkId);
\ No newline at end of file
MSTeamsUtils.purgeCorruptTeamLinks(rowData["MST_TEAMLINK.OBJECT_ROWID"], rowData["MST_TEAMLINK.OBJECT_TYPE"], teamLinkId);
MSTeamsUtils.insertTeamIfMissing({
teamId: rowData["MST_TEAMLINK.MST_TEAM_ID"],
teamName: rowData["MST_TEAM.TEAMNAME"]
});
\ No newline at end of file
import("system.vars");
import("MSTeams_lib");
var rowData = vars.get("$local.rowdata");
MSTeamsUtils.insertTeamIfMissing({
teamId: rowData["MST_TEAMLINK.MST_TEAM_ID"],
teamName: rowData["MST_TEAM.TEAMNAME"]
});
\ No newline at end of file
......@@ -11,15 +11,6 @@
<entityFields>
<entityProvider>
<name>#PROVIDER</name>
<lookupIdfield>TEAMID_AND_NAME</lookupIdfield>
<dependencies>
<entityDependency>
<name>9794baf5-ffc8-498e-8aa8-f4eca945441c</name>
<entityName>MSTTeamLink_entity</entityName>
<fieldName>Teams</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityField>
<name>UID</name>
......@@ -108,6 +99,30 @@
<expose v="true" />
<description>PARAMETER</description>
</entityParameter>
<entityProvider>
<name>TeamsByIdAndName</name>
<lookupIdfield>TEAMID_AND_NAME</lookupIdfield>
<documentation>%aditoprj%/entity/MSTTeam_entity/entityfields/teamsbyidandname/documentation.adoc</documentation>
<children>
<entityParameter>
<name>UseCache_param</name>
<valueProcess>%aditoprj%/entity/MSTTeam_entity/entityfields/teamsbyidandname/children/usecache_param/valueProcess.js</valueProcess>
<expose v="false" />
</entityParameter>
</children>
<dependencies>
<entityDependency>
<name>e48136a2-5f66-4399-903a-cd1363fa30c6</name>
<entityName>MSTTeamLink_entity</entityName>
<fieldName>Teams</fieldName>
<isConsumer v="false" />
</entityDependency>
</dependencies>
</entityProvider>
<entityParameter>
<name>UseCache_param</name>
<expose v="true" />
</entityParameter>
</entityFields>
<recordContainers>
<jDitoRecordContainer>
......@@ -119,6 +134,8 @@
<onInsert>%aditoprj%/entity/MSTTeam_entity/recordcontainers/jdito/onInsert.js</onInsert>
<onUpdate>%aditoprj%/entity/MSTTeam_entity/recordcontainers/jdito/onUpdate.js</onUpdate>
<onDelete>%aditoprj%/entity/MSTTeam_entity/recordcontainers/jdito/onDelete.js</onDelete>
<cacheType>SESSION</cacheType>
<cacheKeyProcess>%aditoprj%/entity/MSTTeam_entity/recordcontainers/jdito/cacheKeyProcess.js</cacheKeyProcess>
<recordFieldMappings>
<jDitoRecordFieldMapping>
<name>UID.value</name>
......
import("system.result");
result.string(true);
\ No newline at end of file
= TeamsByIdAndName
The provider uses a JSON containing [teamId, teamName] as the lookupIdField for cases when both values are needed.
Because the request that loads the MST teams can be slow, the records will be cached if this provider is used.
\ No newline at end of file
import("system.result");
import("system.vars");
import("Util_lib");
import("CachedRecordContainer_lib");
if (Utils.toBoolean(vars.get("$param.UseCache_param")))
result.string(CachedRecordContainerUtils.getCommonKey("$param.UseCache_param"));
\ No newline at end of file
......@@ -62,12 +62,5 @@ if (internalMembers.length !== 0)
if (externalMembers.length !== 0)
teams.addExternalMembers(mstTeam.teamId, externalMembers);
new SqlBuilder().insertFields({
"MST_TEAMID": mstTeam.teamId,
"TEAMNAME": mstTeam.teamName,
"GENERAL_CHANNELID": mstTeam.generalChannelId,
"IS_ARCHIVED": 0,
"WEB_URL": mstTeam.webUrl
}, "MST_TEAM");
MSTeamsUtils.insertTeamIfMissing(mstTeam);
MSTeamsUtils.createTeamLink(mstTeam.teamId, vars.get("$param.ObjectRowId_param"), vars.get("$param.ObjectType_param"));
\ No newline at end of file
......@@ -6,6 +6,7 @@
<title>${SALESPROJECT_MEMBER}</title>
<siblings>
<element>MSTTeam_entity</element>
<element>MSTTeamLink_entity</element>
</siblings>
<grantUpdateProcess>%aditoprj%/entity/Member_entity/grantUpdateProcess.js</grantUpdateProcess>
<grantDeleteProcess>%aditoprj%/entity/Member_entity/grantDeleteProcess.js</grantDeleteProcess>
......
......@@ -8,6 +8,7 @@
<element>SalesprojectMilestone_entity</element>
<element>Member_entity</element>
<element>MSTTeam_entity</element>
<element>MSTTeamLink_entity</element>
</siblings>
<grantDeleteProcess>%aditoprj%/entity/Salesproject_entity/grantDeleteProcess.js</grantDeleteProcess>
<contentTitleProcess>%aditoprj%/entity/Salesproject_entity/contentTitleProcess.js</contentTitleProcess>
......
......@@ -2,6 +2,7 @@
<neonContext xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.1" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonContext/1.1.1">
<name>MSTTeamLink</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<editView>MSTTeamLinkEdit_view</editView>
<entity>MSTTeamLink_entity</entity>
<references>
<neonViewReference>
......
......@@ -2,9 +2,22 @@
<neonView xmlns="http://www.adito.de/2018/ao/Model" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" VERSION="1.1.6" xsi:schemaLocation="http://www.adito.de/2018/ao/Model adito://models/xsd/neonView/1.1.6">
<name>MSTTeamLinkEdit_view</name>
<majorModelMode>DISTRIBUTED</majorModelMode>
<size>SMALL</size>
<layout>
<boxLayout>
<name>layout</name>
</boxLayout>
</layout>
<children>
<genericViewTemplate>
<name>TeamSelection</name>
<editMode v="true" />
<fields>
<entityFieldLink>
<name>1b10e15e-0774-430d-8b76-36307abdff33</name>
<entityField>TEAM_ID_AND_NAME</entityField>
</entityFieldLink>
</fields>
</genericViewTemplate>
</children>
</neonView>
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