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

Marketing workflow enhancements

parent eb03b33f
No related branches found
No related tags found
No related merge requests found
......@@ -3,4 +3,5 @@
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<include relativeToChangelogFile="true" file="insert_commMediumTitleKeywordAttribute.xml"/>
<include relativeToChangelogFile="true" file="Knowledgemanagement/changelog_knowledgeManagement.xml"/>
<include relativeToChangelogFile="true" file="insert_employeeCountAttribute.xml"/>
</databaseChangeLog>
<?xml version="1.1" encoding="UTF-8" standalone="no"?>
<databaseChangeLog xmlns="http://www.liquibase.org/xml/ns/dbchangelog"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.6.xsd">
<changeSet author="s.listl" id="59d2d137-086a-4c07-869a-72a2b24952d4">
<insert tableName="AB_ATTRIBUTE">
<column name="AB_ATTRIBUTEID" value="dd024883-c49e-4d09-85c8-829cf9c9c5e9"/>
<column name="ATTRIBUTE_PARENT_ID" value="e32cd923-3774-41c1-95d5-57b79e52e568"/>
<column name="ATTRIBUTE_ACTIVE" valueNumeric="1"/>
<column name="ATTRIBUTE_NAME" value="Employee count"/>
<column name="ATTRIBUTE_TYPE" value="NUMBER"/>
<column name="SORTING" valueNumeric="7"/>
</insert>
<insert tableName="AB_ATTRIBUTEUSAGE">
<column name="AB_ATTRIBUTEUSAGEID" value="8de717a1-9d64-44c9-b692-b350b0857d59"/>
<column name="AB_ATTRIBUTE_ID" value="dd024883-c49e-4d09-85c8-829cf9c9c5e9"/>
<column name="OBJECT_TYPE" value="Organisation"/>
<column name="MAX_COUNT" valueNumeric="1"/>
</insert>
</changeSet>
</databaseChangeLog>
\ No newline at end of file
import("Sql_lib");
import("Util_lib");
import("system.vars");
import("system.result");
......@@ -7,11 +8,36 @@ var context = vars.get("$param.ObjectType_param");
var targets = Utils.parseJSON(vars.get("$param.ObjectIds_param"));
var filter = Utils.parseJSON(vars.get("$param.ObjectFilter_param"));
targets = FilterViewActionUtils.getUidsBySelectionOrFilter(context, targets, filter).map(function (targetId)
var personContactIds = [];
targets = FilterViewActionUtils.getUidsBySelectionOrFilter(context, targets, filter).map(function (target)
{
if (Utils.isString(targetId))
return [targetId, context]; //todo: context dynamic (eg for participants)
return targetId;
if (Utils.isString(target))
target = [target, context];
if (target[1] == "Person")
personContactIds.push(target[0]);
return target;
});
if (personContactIds.length !== 0)
{
var orgContactIds = newSelect(["anyContact.CONTACTID", "orgContact.CONTACTID"])
.from("CONTACT", "orgContact")
.join("CONTACT", "anyContact.ORGANISATION_ID = orgContact.ORGANISATION_ID and orgContact.PERSON_ID is null", "anyContact")
.where(["CONTACT", "CONTACTID", "anyContact"], personContactIds, SqlBuilder.IN())
.table();
var contactIdMap = new Map(orgContactIds);
targets.forEach(function ([targetId, targetContext, variables], i, allTargets)
{
if (contactIdMap.has(targetId))
{
if (!variables)
variables = {};
variables.attributeRowId = contactIdMap.get(targetId);
variables.attributeContext = "Organisation";
allTargets[i][2] = variables;
}
});
}
result.string(JSON.stringify(targets));
\ No newline at end of file
......@@ -17,10 +17,9 @@ if (!Utils.isNullOrEmpty(startFormResult))
targets.forEach(function ([targetId, targetContext, processVariables])
{
/* Caution: If 'variables' is used, then 'processVariables' is only a reference to 'variables'.
Currently that's fine, but keep it in mind when you change this code. */
if (!processVariables)
processVariables = variables;
processVariables = {};
Object.assign(processVariables, variables);
processVariables[WorkflowVariables.TARGET_ID()] = targetId;
processVariables[WorkflowVariables.TARGET_CONTEXT()] = targetContext || context;
......
......@@ -10,8 +10,5 @@
<name>a6965156-ab52-4520-a3be-1351eacd863d</name>
<view>KnowledgeNewsFeed_view</view>
</neonViewReference>
<neonViewReference>
<name>e4604c82-a42f-47c6-a1d1-0f1d1727ee38</name>
</neonViewReference>
</references>
</neonContext>
......@@ -327,6 +327,7 @@ KnowledgeManagementTagsController.getInstance = function(pId, pModel)
*
* @param {String} pIdValue, id of the new AttributeRelation typically read from $local.idvalue
* @param {Array} pRowData, data of the new tag, typically read from $local.rowdata
* @param {Boolean} pFromUpdate
*
* @return {this}
*/
......@@ -489,6 +490,7 @@ KnowledgeManagementTagsController.prototype.clearTags = function()
* @param {String} pIdValue typically the $local.idvalue of the onInsert process, it is being used, if for some reason the entered tag is already existing.
* then a new AttributeRelation is created instead of the tag.
* @param {[][]} pData typically the $local.rowdata of the onInsert or onUpdate process
* @param {Boolean} pFromUpdate
*
* @return {String|null} returns the id of the new tag attribute or null, if it couldn't be created
*/
......
......@@ -24,4 +24,5 @@ if (variables.attributeValueVariable)
variables.attributeValue = attributeValue;
}
new AttributeRelationQuery(variables.targetId, attributeId, variables.targetContext).insertAttribute(variables.attributeValue);
\ No newline at end of file
new AttributeRelationQuery(variables.attributeRowId || variables.targetId, attributeId, variables.attributeContext || variables.targetContext)
.insertAttribute(variables.attributeValue);
\ No newline at end of file
......@@ -17,12 +17,13 @@ var currentValues = JSON.parse(vars.get("$local.value"));
var allAttributes = newSelect("AB_ATTRIBUTEID, ATTRIBUTE_PARENT_ID, ATTRIBUTE_NAME, ATTRIBUTE_TYPE, ATTRIBUTE_ACTIVE")
.from("AB_ATTRIBUTE")
.where("AB_ATTRIBUTE.ATTRIBUTE_TYPE", AttributeTypes.OBJECTSELECTION(), SqlBuilder.NOT_EQUAL()) //these can't work yet
.orderBy(["ATTRIBUTE_PARENT_ID", "SORTING", "ATTRIBUTE_NAME"])
.table();
var attributeNameMap = {};
var attributeNameMap = new Map();
var attributes = [];
allAttributes.forEach(function ([attributeId, parentId, attributeName, attributeType, isActive])
{
attributeNameMap[attributeId] = [translate.text(attributeName), parentId];
attributeNameMap.set(attributeId, [translate.text(attributeName), parentId]);
if (isActive == "1" && attributeType != AttributeTypes.GROUP() && attributeType != AttributeTypes.COMBOVALUE())
attributes.push(attributeId);
});
......@@ -32,9 +33,9 @@ attributes = attributes.map(function (attributeId)
var fullName = "";
//the loop will stop if an id comes up twice, because otherwise that could cause an infinite loop if the data is faulty
var alreadyEncountered = new Set();
while (parentId && attributeNameMap[parentId] && !alreadyEncountered.has(parentId))
while (parentId && attributeNameMap.has(parentId) && !alreadyEncountered.has(parentId))
{
var [currentName, currentParent] = attributeNameMap[parentId];
var [currentName, currentParent] = attributeNameMap.get(parentId);
if (!fullName)
fullName = currentName;
else
......
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