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

1080071 communication rejection summary in preview

parent 8052a320
No related branches found
No related tags found
No related merge requests found
Showing
with 72 additions and 60 deletions
......@@ -149,6 +149,10 @@
<name>ContainerName_param</name>
<valueProcess>%aditoprj%/entity/CommunicationSettings_entity/entityfields/mediumkeyword/children/containername_param/valueProcess.js</valueProcess>
</entityParameter>
<entityParameter>
<name>BlacklistIds_param</name>
<valueProcess>%aditoprj%/entity/CommunicationSettings_entity/entityfields/mediumkeyword/children/blacklistids_param/valueProcess.js</valueProcess>
</entityParameter>
</children>
</entityConsumer>
<entityConsumer>
......
import("KeywordRegistry_basic");
import("system.result");
result.string(JSON.stringify([$KeywordRegistry.communicationMediumCampaign$letter()]));
\ No newline at end of file
......@@ -958,7 +958,7 @@
<name>COMMRESTRICTIONS_ACTIVE</name>
<title>Commrestrictions</title>
<color>$priority-high-color</color>
<displayValueProcess>%aditoprj%/entity/Organisation_entity/entityfields/commrestrictions_active/displayValueProcess.js</displayValueProcess>
<valueProcess>%aditoprj%/entity/Organisation_entity/entityfields/commrestrictions_active/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>STANDARD_ADDRESS</name>
......@@ -1652,7 +1652,6 @@
</consumerMapping>
<dbRecordFieldMapping>
<name>COMMRESTRICTIONS_ACTIVE.value</name>
<expression>%aditoprj%/entity/Organisation_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STANDARD_ADDRESS.value</name>
......
import("system.vars");
import("system.translate");
import("system.result");
if (vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim())
{ // bug in SqlMaskingUtils.concat. -> use " " as seperator and replace " " by ", "
result.string(translate.text("No advertising by") + " " + ((vars.get("$field.COMMRESTRICTIONS_ACTIVE")).trim()).replace("/ +/g", ", "));
}
import("Contact_lib");
import("system.neon");
import("system.result");
import("system.vars");
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
{
result.string(ContactUtils.getCommunicationRejectionSummary(vars.get("$field.CONTACTID")));
}
import("Contact_lib");
import("system.result");
result.string(ContactUtils.getActiveCommRestrictionsSubselect());
\ No newline at end of file
......@@ -939,8 +939,7 @@
<name>COMMRESTRICTIONS_ACTIVE</name>
<title>Commrestrictions</title>
<color>$priority-high-color</color>
<groupable v="true" />
<displayValueProcess>%aditoprj%/entity/Person_entity/entityfields/commrestrictions_active/displayValueProcess.js</displayValueProcess>
<valueProcess>%aditoprj%/entity/Person_entity/entityfields/commrestrictions_active/valueProcess.js</valueProcess>
</entityField>
<entityField>
<name>STANDARD_ZIP</name>
......@@ -1618,7 +1617,6 @@
</consumerMapping>
<dbRecordFieldMapping>
<name>COMMRESTRICTIONS_ACTIVE.value</name>
<expression>%aditoprj%/entity/Person_entity/recordcontainers/db/recordfieldmappings/commrestrictions_active.value/expression.js</expression>
</dbRecordFieldMapping>
<dbRecordFieldMapping>
<name>STANDARD_ADDRESS.value</name>
......@@ -1693,6 +1691,9 @@
<isFilterable v="true" />
<filtertype>EXTENDED</filtertype>
</consumerMapping>
<consumerMapping>
<name>ContactCommunicationSettings</name>
</consumerMapping>
</recordFieldMappings>
<linkInformation>
<linkInformation>
......
import("system.vars");
import("system.translate");
import("system.result");
if (vars.get("$field.COMMRESTRICTIONS_ACTIVE").trim())
{ // bug in SqlMaskingUtils.concat. -> use " " as seperator and replace " " by ", "
result.string(translate.text("No advertising by") + " " + ((vars.get("$field.COMMRESTRICTIONS_ACTIVE")).trim()).replace(/ +/g, ", "));
}
import("Contact_lib");
import("system.neon");
import("system.result");
import("system.vars");
if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_DATASET)
{
result.string(ContactUtils.getCommunicationRejectionSummary(vars.get("$field.CONTACTID")));
}
import("Contact_lib");
import("system.result");
result.string(ContactUtils.getActiveCommRestrictionsSubselect());
\ No newline at end of file
......@@ -54,6 +54,10 @@
<key>The max participants count can not be equal or less then 0</key>
<value>Die maximale Teilnehmerzahl muss größer 0 sein!</value>
</entry>
<entry>
<key>No advertising</key>
<value>Keine Werbung</value>
</entry>
<entry>
<key>Value is too small, the minimum is %0</key>
<value>Wert ist zu klein, das Minimum ist %0</value>
......
......@@ -603,37 +603,41 @@ ContactUtils.hasCommRestriction = function(pContactId, pMedium, pStartDate)
}
/**
* returns a sql subselect which concatenates all commrestriction displayvalues (translated).
* The select needs the CONTACT.CONTACTID column.
* Generates a summary of communication settings with status 'rejected'.
*
* @return {String} the resulting subselect
* @param {String} pContactId contactId of the contact for the communication settings
* @return {String} description of all rejected communication channels
*/
ContactUtils.getActiveCommRestrictionsSubselect = function()
ContactUtils.getCommunicationRejectionSummary = function (pContactId)
{
var mediumList = KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.communicationMediumCampaign(), "COMMUNICATIONSETTINGS.MEDIUM");
var mask = new SqlMaskingUtils()
var orgContactSubselect = newSelect("orgContact.CONTACTID")
.from("CONTACT anyContact")
.join("CONTACT orgContact", newWhere("anyContact.ORGANISATION_ID = orgContact.ORGANISATION_ID")
.and("orgContact.PERSON_ID IS NULL"))
.where("anyContact.CONTACTID = CONTACT.CONTACTID")
var mediumTitleSql = KeywordUtils.getResolvedTitleSqlPart($KeywordRegistry.communicationMediumCampaign(), "COMMUNICATIONSETTINGS.MEDIUM");
var communicationRejections = newSelect(["CHANNEL_TYPE", "MEDIUM", mediumTitleSql])
.from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID", pContactId)
.and("COMMUNICATIONSETTINGS.CHANNEL_TYPE", $KeywordRegistry.communicationChannelType$profiling(), SqlBuilder.NOT_EQUAL())
.and("COMMUNICATIONSETTINGS.STATUS", $KeywordRegistry.communicationSettingStatus$rejected())
.orderBy(mediumTitleSql)
.table();
var group = mask.getGroupConcat("DISTINCT "+mediumList, "', '");
var subselect = "''";
if(group)
if (communicationRejections.length > 0)
{
var res = newSelect(group).from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID = CONTACT.CONTACTID")
.and("COMMUNICATIONSETTINGS.STATUS", $KeywordRegistry.communicationSettingStatus$rejected())
var subres = newSelect(group).from("COMMUNICATIONSETTINGS")
.where("COMMUNICATIONSETTINGS.CONTACT_ID in ( "+orgContactSubselect.toString()+")")
.and("COMMUNICATIONSETTINGS.STATUS", $KeywordRegistry.communicationSettingStatus$rejected())
subselect = mask.concatWithSeparator(["("+res.toString()+")", "("+subres.toString()+")"], ", ", false);
var mediumTitles = [];
var hasGlobalRejection = communicationRejections.some(function ([channelType, medium, mediumTitle])
{
if (channelType == $KeywordRegistry.communicationChannelType$address())
{
mediumTitle = KeywordUtils.getViewValue($KeywordRegistry.communicationMediumCampaign(), $KeywordRegistry.communicationMediumCampaign$letter());
}
mediumTitles.push(mediumTitle);
return channelType == $KeywordRegistry.communicationChannelType$global();
});
if (hasGlobalRejection)
{
return translate.text("No advertising");
}
return translate.text("No advertising by") + " " + mediumTitles.join(", ")
}
return subselect;
return "";
}
/**
......
......@@ -637,22 +637,24 @@ Observation.actionState = function (pSelectedUIDs, pIsCancelAction)
* If filter or entity are not set, they are set to an empty filter and the current entity.
*
* @param {String} [pEntity]
* @param {Object} [pFilter]
* @param {Object} [pFilterObj]
* @return {Object} Object in Format: {"filter": {"type":"group","operator":"AND","childs":[...]}, "entity": "Entity_entity"}
*/
Observation.getEntityFilter = function (pEntity, pFilter)
Observation.getEntityFilter = function (pEntity, pFilterObj)
{
if (!pEntity)
pEntity = ContextUtils.getEntity(ContextUtils.getCurrentContextId());
if (!pFilter)
pFilter = {
if (!pFilterObj)
{
pFilterObj = {
"type":"group",
"operator":"AND",
"childs":[]
}
};
}
return JSON.stringify({
"filter":pFilter,
"filter":pFilterObj,
"entity":pEntity
});
}
......
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