Skip to content
Snippets Groups Projects
Commit 6eae1710 authored by S.Listl's avatar S.Listl
Browse files

Workflow serviceTask parameters

parent b5c8a8a9
No related branches found
No related tags found
No related merge requests found
import("KeywordData_lib");
import("system.translate");
import("KeywordRegistry_basic");
import("Keyword_lib");
import("system.tools");
import("system.logging");
import("Attribute_lib");
......@@ -61,13 +65,41 @@ function restget (pRequest)
});
}
function _getUsers (pUseContactId)
{
var users = tools.getUsersByAttribute(tools.ISACTIVE, ["true"], tools.PROFILE_FULL);
return users.map(function (user)
{
return {
id : pUseContactId ? user[tools.PARAMS][tools.CONTACTID] : user[tools.NAME],
name : (user[tools.PARAMS][tools.FIRSTNAME] + " " + user[tools.PARAMS][tools.LASTNAME]).trim()
};
}).sort(function (a, b)
{
if (a.name > b.name)
return 1;
else if (a.name < b.name)
return -1;
return 0;
});
}
function _getKeywords (pContainer)
{
return _mapToItemArray(KeywordData.getSimpleData(pContainer));
}
//every workflowService has an own function, because:
// - it will only be executed if the workflowSevice is selected
// - it creates an own scope for variables declared with var
var parameterConfiguration = {
CreateActivity_workflowService : function (pCurrentValues)
{
return [
new Parameter("activityResponsible", "Responsible", Types.STRING),
new Parameter("activityDirection", "Direction", Types.STRING),
new Parameter("activityCategory", "Category", Types.STRING),
new Parameter("activityResponsible", "Responsible", Types.ENUM, _getUsers(true)),
new Parameter("activityDirection", "Direction", Types.ENUM, _getKeywords($KeywordRegistry.activityDirection())),
new Parameter("activityCategory", "Category", Types.ENUM, _getKeywords($KeywordRegistry.activityCategory())),
new Parameter("activityEntryDate", "Entry date", Types.DATE),
new Parameter("activityContent", "Content", Types.STRING),
new Parameter("activityTitle", "Title", Types.STRING)
......@@ -78,7 +110,7 @@ function restget (pRequest)
return [
new Parameter("notificationCaption", "Caption", Types.STRING),
new Parameter("notificationDescription", "Description", Types.STRING),
new Parameter("notificationUser", "User", Types.STRING)
new Parameter("notificationUser", "User", Types.ENUM, _getUsers())
];
},
SendEmail_workflowService : function (pCurrentValues)
......@@ -98,9 +130,69 @@ function restget (pRequest)
// {
// return {id : attribute["#UID"], name : attribute["#CONTENTTITLE"]};
// });
return [
new Parameter("attributeId", "Attribute", Types.ENUM)
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
.table();
var attributeNameMap = {};
var attributes = [];
allAttributes.forEach(function ([attributeId, parentId, attributeName, attributeType, isActive])
{
attributeNameMap[attributeId] = [translate.text(attributeName), parentId];
if (isActive == "1" && attributeType != $AttributeTypes.GROUP && attributeType != $AttributeTypes.COMBOVALUE)
attributes.push(attributeId);
});
attributes = attributes.map(function (attributeId)
{
var parentId = 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 = {};
while (parentId && attributeNameMap[parentId] && !alreadyEncountered[parentId])
{
var [currentName, currentParent] = attributeNameMap[parentId];
if (!fullName)
fullName = currentName;
else
fullName = currentName + " / " + fullName;
alreadyEncountered[parentId] = true;
parentId = currentParent;
}
return {id : attributeId, name : fullName};
});
var parameters = [
new Parameter("attributeId", "Attribute", Types.ENUM, attributes, true)
];
if (currentValues.attributeId && currentValues.attributeId.value)
{
var selectedAttributeId = currentValues.attributeId.value;
var attributeType = AttributeUtil.getAttributeType(selectedAttributeId);
var listValues = AttributeUtil.getPossibleListValues(selectedAttributeId, attributeType);
var enumValues, paramType;
if (listValues != null)
{
enumValues = _mapToItemArray(listValues);
paramType = Types.ENUM;
}
else
{
paramType = ({
"TEXT" : Types.STRING,
"LONG_TEXT" : Types.STRING,
"NUMBER" : Types.NUMBER,
"DATE" : Types.DATE
})[AttributeTypeUtil.getContentType(attributeType)];
}
if (paramType)
parameters.push(new Parameter("attributeValue", "Value", paramType, enumValues));
}
return parameters;
},
UpdateOffer_workflowService : function (pCurrentValues)
{
......
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