From b9ba11d3b1cdfe6442bb9489f60d338a978aa428 Mon Sep 17 00:00:00 2001 From: Sebastian Listl <s.listl@adito.de> Date: Mon, 9 Nov 2020 16:05:54 +0100 Subject: [PATCH] #1062892 CampaignParticipant filter --- .../AnyContact_entity/AnyContact_entity.aod | 43 ++++++----- .../CampaignParticipant_entity.aod | 75 +++++++++++-------- .../advertisingban_icon/colorProcess.js | 15 +--- .../displayValueProcess.js | 11 +-- .../children/campaignid_param/valueProcess.js | 7 +- .../hasadvertisingban/dropDownProcess.js | 7 ++ .../advertisingban_icon.value/expression.js | 11 --- .../anycontacts/filterConditionProcess.js | 10 +++ .../hasadvertisingban.value/expression.js | 11 +++ .../expression.js | 0 .../expression.js | 0 process/Contact_lib/process.js | 20 +++++ 12 files changed, 129 insertions(+), 81 deletions(-) create mode 100644 entity/CampaignParticipant_entity/entityfields/hasadvertisingban/dropDownProcess.js delete mode 100644 entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js create mode 100644 entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/anycontacts/filterConditionProcess.js create mode 100644 entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/hasadvertisingban.value/expression.js rename entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/{standard_email_communication.displayvalue => standard_email_communication.value}/expression.js (100%) rename entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/{standard_phone_communication.displayvalue => standard_phone_communication.value}/expression.js (100%) diff --git a/entity/AnyContact_entity/AnyContact_entity.aod b/entity/AnyContact_entity/AnyContact_entity.aod index 0d0c5d1d96..3b3b3c3e98 100644 --- a/entity/AnyContact_entity/AnyContact_entity.aod +++ b/entity/AnyContact_entity/AnyContact_entity.aod @@ -3,6 +3,7 @@ <name>AnyContact_entity</name> <majorModelMode>DISTRIBUTED</majorModelMode> <documentation>%aditoprj%/entity/AnyContact_entity/documentation.adoc</documentation> + <title>Contact</title> <contentTitleProcess>%aditoprj%/entity/AnyContact_entity/contentTitleProcess.js</contentTitleProcess> <initFilterProcess>%aditoprj%/entity/AnyContact_entity/initFilterProcess.js</initFilterProcess> <imageProcess>%aditoprj%/entity/AnyContact_entity/imageProcess.js</imageProcess> @@ -29,12 +30,6 @@ <fieldName>AnyContacts</fieldName> <isConsumer v="false" /> </entityDependency> - <entityDependency> - <name>336fdc6b-05f8-40bc-89ba-d4ab98bd6948</name> - <entityName>CampaignParticipant_entity</entityName> - <fieldName>AnyContacts</fieldName> - <isConsumer v="false" /> - </entityDependency> <entityDependency> <name>b2895709-2ebf-46ec-a46d-6b2e9a4575a3</name> <entityName>BulkMailRecipient_entity</entityName> @@ -77,11 +72,23 @@ <fieldName>Contacts</fieldName> <isConsumer v="false" /> </entityDependency> + <entityDependency> + <name>ea7c855e-dccd-4c05-9efb-a1303f37dab8</name> + <entityName>CampaignParticipant_entity</entityName> + <fieldName>AnyContacts</fieldName> + <isConsumer v="false" /> + </entityDependency> </dependencies> </entityProvider> <entityProvider> <name>ContactsByIds</name> <documentation>%aditoprj%/entity/AnyContact_entity/entityfields/contactsbyids/documentation.adoc</documentation> + <children> + <entityParameter> + <name>ContactId_param</name> + <expose v="false" /> + </entityParameter> + </children> <dependencies> <entityDependency> <name>0206f7a8-fd58-47e8-8b7a-5ff4531e56fb</name> @@ -90,12 +97,6 @@ <isConsumer v="false" /> </entityDependency> </dependencies> - <children> - <entityParameter> - <name>ContactId_param</name> - <expose v="false" /> - </entityParameter> - </children> </entityProvider> <entityParameter> <name>ContactIds_param</name> @@ -108,6 +109,7 @@ </entityField> <entityField> <name>LANGUAGE</name> + <title>Language</title> </entityField> <entityField> <name>ORGANISATION_ID</name> @@ -157,9 +159,11 @@ See ContactUtils.getRelationTypeByPersOrg for possible values</description> </entityField> <entityField> <name>PERSON_TITLE</name> + <title>Title</title> </entityField> <entityField> <name>PERSON_SALUTATION</name> + <title>Salutation</title> </entityField> <entityField> <name>PERSON_FULL_NAME</name> @@ -173,6 +177,13 @@ See ContactUtils.getRelationTypeByPersOrg for possible values</description> <entityProvider> <name>OnlySameCompany</name> <documentation>%aditoprj%/entity/AnyContact_entity/entityfields/onlysamecompany/documentation.adoc</documentation> + <children> + <entityParameter> + <name>ContactId_param</name> + <expose v="true" /> + <mandatory v="true" /> + </entityParameter> + </children> <dependencies> <entityDependency> <name>28b19d6b-237c-4268-b6c6-323df408c94a</name> @@ -181,13 +192,6 @@ See ContactUtils.getRelationTypeByPersOrg for possible values</description> <isConsumer v="false" /> </entityDependency> </dependencies> - <children> - <entityParameter> - <name>ContactId_param</name> - <expose v="true" /> - <mandatory v="true" /> - </entityParameter> - </children> </entityProvider> <entityParameter> <name>WithPrivatePersons_param</name> @@ -248,6 +252,7 @@ See ContactUtils.getRelationTypeByPersOrg for possible values</description> <dbRecordFieldMapping> <name>LANGUAGE.value</name> <recordfield>CONTACT.ISOLANGUAGE</recordfield> + <isFilterable v="true" /> </dbRecordFieldMapping> <dbRecordFieldMapping> <name>ORGANISATION_ID.value</name> diff --git a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod index 4d3b86ba02..42f0af8d63 100644 --- a/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod +++ b/entity/CampaignParticipant_entity/CampaignParticipant_entity.aod @@ -21,20 +21,6 @@ <targetContextField>CONTACTCONTEXT</targetContextField> <targetIdField>CONTACT_ID</targetIdField> <documentation>%aditoprj%/entity/CampaignParticipant_entity/entityfields/campaignparticipantsprovider/documentation.adoc</documentation> - <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> @@ -49,6 +35,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> @@ -145,11 +145,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> @@ -157,6 +152,11 @@ <expose v="true" /> </entityParameter> </children> + <dependency> + <name>dependency</name> + <entityName>CampaignStep_entity</entityName> + <fieldName>CampaignSteps</fieldName> + </dependency> </entityConsumer> <entityField> <name>CONTACTCONTEXT</name> @@ -212,17 +212,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> @@ -238,6 +238,12 @@ <name>#PROVIDER_AGGREGATES</name> <useAggregates v="true" /> </entityProvider> + <entityField> + <name>HASADVERTISINGBAN</name> + <title>Advertising ban</title> + <contentType>BOOLEAN</contentType> + <dropDownProcess>%aditoprj%/entity/CampaignParticipant_entity/entityfields/hasadvertisingban/dropDownProcess.js</dropDownProcess> + </entityField> </entityFields> <recordContainers> <dbRecordContainer> @@ -267,6 +273,7 @@ <dbRecordFieldMapping> <name>CAMPAIGNSTEP_ID.value</name> <recordfield>CAMPAIGNPARTICIPANT.CAMPAIGNSTEP_ID</recordfield> + <isFilterable v="true" /> </dbRecordFieldMapping> <dbRecordFieldMapping> <name>CONTACT_ID.value</name> @@ -293,16 +300,24 @@ <recordfield>CAMPAIGNPARTICIPANT.CAMPAIGNPARTICIPANTID</recordfield> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>STANDARD_PHONE_COMMUNICATION.displayValue</name> - <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.displayvalue/expression.js</expression> + <name>STANDARD_EMAIL_COMMUNICATION.value</name> + <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.value/expression.js</expression> + <isFilterable v="true" /> </dbRecordFieldMapping> <dbRecordFieldMapping> - <name>STANDARD_EMAIL_COMMUNICATION.displayValue</name> - <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.displayvalue/expression.js</expression> + <name>STANDARD_PHONE_COMMUNICATION.value</name> + <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.value/expression.js</expression> </dbRecordFieldMapping> + <consumerMapping> + <name>AnyContacts</name> + <filterConditionProcess>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/anycontacts/filterConditionProcess.js</filterConditionProcess> + <isFilterable v="true" /> + <filtertype>BASIC</filtertype> + </consumerMapping> <dbRecordFieldMapping> - <name>ADVERTISINGBAN_ICON.value</name> - <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js</expression> + <name>HASADVERTISINGBAN.value</name> + <expression>%aditoprj%/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/hasadvertisingban.value/expression.js</expression> + <isFilterable v="true" /> </dbRecordFieldMapping> </recordFieldMappings> </dbRecordContainer> diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js index 1bcf3daac5..f322e15de7 100644 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/colorProcess.js @@ -1,16 +1,7 @@ +import("Util_lib"); import("system.result"); -import("Sql_lib"); -import("system.db"); import("system.vars"); import("system.neon"); -import("Campaign_lib"); -if(vars.get("$field.ADVERTISINGBAN_ICON") > 0) -{ - result.string(neon.PRIORITY_MEDIUM_COLOR); -} -else -{ - result.string(neon.PRIORITY_LOW_COLOR); -} - +var hasAdvertisingBan = Utils.toBoolean(vars.get("$field.HASADVERTISINGBAN")); +result.string(hasAdvertisingBan ? neon.PRIORITY_MEDIUM_COLOR : neon.PRIORITY_LOW_COLOR); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js index 837878d3b7..7ff3faa94c 100644 --- a/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/advertisingban_icon/displayValueProcess.js @@ -1,12 +1,7 @@ +import("Util_lib"); import("system.result"); import("system.vars"); // Now show warning always, if any commrestriction exists. No matter which medium the current step has. -if (vars.get("$field.ADVERTISINGBAN_ICON") == 0) -{ - result.string("VAADIN:CHECK"); -} -else -{ - result.string("VAADIN:WARNING"); -} \ No newline at end of file +var hasAdvertisingBan = Utils.toBoolean(vars.get("$field.HASADVERTISINGBAN")); +result.string(hasAdvertisingBan ? "VAADIN:WARNING" : "VAADIN:CHECK"); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/campaignsteps/children/campaignid_param/valueProcess.js b/entity/CampaignParticipant_entity/entityfields/campaignsteps/children/campaignid_param/valueProcess.js index 90d07eb4d8..a22fac8bd5 100644 --- a/entity/CampaignParticipant_entity/entityfields/campaignsteps/children/campaignid_param/valueProcess.js +++ b/entity/CampaignParticipant_entity/entityfields/campaignsteps/children/campaignid_param/valueProcess.js @@ -1,3 +1,8 @@ import("system.vars"); import("system.result"); -result.string(vars.get("$field.CAMPAIGN_ID")); \ No newline at end of file +import("system.neon"); + +if (vars.get("$sys.viewmode") == neon.FRAME_VIEWMODE_TABLE) + result.string(vars.get("$param.CampaignId_param")); +else + result.string(vars.get("$field.CAMPAIGN_ID")); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/entityfields/hasadvertisingban/dropDownProcess.js b/entity/CampaignParticipant_entity/entityfields/hasadvertisingban/dropDownProcess.js new file mode 100644 index 0000000000..3373b8a886 --- /dev/null +++ b/entity/CampaignParticipant_entity/entityfields/hasadvertisingban/dropDownProcess.js @@ -0,0 +1,7 @@ +import("system.translate"); +import("system.result"); + +result.object([ + ["1", translate.text("Yes")], + ["0", translate.text("No")] +]); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js deleted file mode 100644 index 27052d9123..0000000000 --- a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/advertisingban_icon.value/expression.js +++ /dev/null @@ -1,11 +0,0 @@ -import("system.vars"); -import("Contact_lib"); -import("Sql_lib"); -import("system.result"); - -// Now show warning always, if any commrestriction exists. No matter which medium the current step has. -result.string("(" + newSelect("count(*)") - .from("CONTACT") - .where("CONTACT.CONTACTID = CAMPAIGNPARTICIPANT.CONTACT_ID") - .and(newWhere(ContactUtils.getCommRestrictionCondition(undefined, false, vars.get("$sys.date")))) // TODO: the newWhere can be removed when getCommRestrictionCondition returns a sqlBuilder instead of a SqlCondition - .toString() + ")"); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/anycontacts/filterConditionProcess.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/anycontacts/filterConditionProcess.js new file mode 100644 index 0000000000..c37a5f4a9b --- /dev/null +++ b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/anycontacts/filterConditionProcess.js @@ -0,0 +1,10 @@ +import("system.result"); +import("system.vars"); +import("Contact_lib"); +import("Sql_lib"); + +var condition = newWhere(null, ContactUtils.getFullContactSqlBuilder("CONTACTID") + .where("CONTACTID = CAMPAIGNPARTICIPANT.CONTACT_ID") + .and(vars.get("$local.condition")), SqlBuilder.EXISTS()); + +result.string(condition.toString()); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/hasadvertisingban.value/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/hasadvertisingban.value/expression.js new file mode 100644 index 0000000000..b1292f5439 --- /dev/null +++ b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/hasadvertisingban.value/expression.js @@ -0,0 +1,11 @@ +import("system.vars"); +import("Contact_lib"); +import("Sql_lib"); +import("system.result"); + +var commRestrictionContactSubSql = newSelect("CONTACT.CONTACTID") + .from("CONTACT") + .where("CONTACT.CONTACTID = CAMPAIGNPARTICIPANT.CONTACT_ID") + .and(ContactUtils.getCommRestrictionCondition()); + +result.string(SqlBuilder.caseWhen(null, commRestrictionContactSubSql, SqlBuilder.EXISTS()).thenString("1").elseString("0").toString()); \ No newline at end of file diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.displayvalue/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.value/expression.js similarity index 100% rename from entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.displayvalue/expression.js rename to entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_email_communication.value/expression.js diff --git a/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.displayvalue/expression.js b/entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.value/expression.js similarity index 100% rename from entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.displayvalue/expression.js rename to entity/CampaignParticipant_entity/recordcontainers/participantsdbrecordcontainer/recordfieldmappings/standard_phone_communication.value/expression.js diff --git a/process/Contact_lib/process.js b/process/Contact_lib/process.js index 4d53dde63a..05d3069f86 100644 --- a/process/Contact_lib/process.js +++ b/process/Contact_lib/process.js @@ -434,6 +434,26 @@ ContactUtils.getFullContactString = function() + " left join ADDRESS on ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID"; } +/** + * Returns a SqlBuilder for selecting a contact with organisation, person and address. + * + * @param {String|Array|SqlBuilder} [pSelectFields] The select-part to set for the query, if it is omitted, no select will be set. + * @return {SqlBuilder} + */ +ContactUtils.getFullContactSqlBuilder = function (pSelectFields) +{ + var sql = new SqlBuilder() + .from("CONTACT") + .join("ORGANISATION", "ORGANISATION.ORGANISATIONID = CONTACT.ORGANISATION_ID") + .leftJoin("PERSON", "PERSON.PERSONID = CONTACT.PERSON_ID") + .leftJoin("ADDRESS", "ADDRESS.ADDRESSID = CONTACT.ADDRESS_ID"); + + if (pSelectFields) + sql.select(pSelectFields); + + return sql; +} + /** * get the addressid of the default address * -- GitLab