diff --git a/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js b/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js index 115f011a725aee198b4c0acfac12c866fa7ab387..d3c9e9c8c0b15494196924e33d73ef9024208f46 100644 --- a/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js +++ b/entity/WorkflowDefinition_entity/recordcontainers/jdito/contentProcess.js @@ -60,14 +60,10 @@ result.object((function () ]; }); - var possibleKeysMap = null; + var possibleKeys = null; if (context) { - possibleKeysMap = {}; - WorkflowUtils.getPossibleWorkflowDefinitions(context).forEach(function (key) - { - this[key] = true; - }, possibleKeysMap); + possibleKeys = new Set(WorkflowUtils.getPossibleWorkflowDefinitions(context)); } var filterFn; @@ -77,7 +73,7 @@ result.object((function () { filterFn = function (currDef) { - return newestVersions[currDef[4]] == currDef[5] && (possibleKeysMap ? possibleKeysMap[currDef[4]] : true); + return newestVersions[currDef[4]] == currDef[5] && (!possibleKeys || possibleKeys.has(currDef[4])); }; } else diff --git a/process/CreateNotification_workflowService/process.js b/process/CreateNotification_workflowService/process.js index 52b6f6fa9fe3f5929f17014aad2663d2e355bfb4..65d5e32a4167747c7b2730d1cbabf41985603f99 100644 --- a/process/CreateNotification_workflowService/process.js +++ b/process/CreateNotification_workflowService/process.js @@ -1,39 +1,54 @@ +import("system.translate"); +import("Employee_lib"); import("KeywordRegistry_basic"); import("system.text"); import("system.vars"); import("system.notification"); var variables = JSON.parse(vars.get("$local.value")); +var caption = variables.notificationCaption || ""; +var description = variables.notificationDescription || ""; +var userIds; +try +{ + userIds = JSON.parse(variables.notificationUser); +} +catch (e) // Throw an exeption when the variable can't parse to an JSON-Object. +{ + userIds = [variables.notificationUser || variables.USER_ID]; +} +if (!variables.skipTranslation && userIds.length === 1) +{ + var userLocale = EmployeeUtils.getUserLocale(userIds[0]); + caption = translate.text(caption, userLocale); + description = translate.text(description, userLocale); +} var config = notification.createConfig() .notificationType(variables.notificationType || "WorkflowNotification") - .caption(variables.notificationCaption || "") - .description(variables.notificationDescription || ""); + .caption(caption) + .description(description) + .addUsersWithIds(userIds); -try { - config.addUsersWithIds(JSON.parse(variables.notificationUser)); -} catch (e) { // Throw an exeption when the variable can't parse to an JSON-Object. - config.addUsersWithIds([variables.notificationUser || variables.USER_ID]) -} var prio; -switch (variables.notificationPriority){ - case $KeywordRegistry.notificationPriority$none: - prio = notification.PRIO_NONE +switch (variables.notificationPriority) +{ + case $KeywordRegistry.notificationPriority$none(): + prio = notification.PRIO_NONE; break; case $KeywordRegistry.notificationPriority$low(): - prio = notification.PRIO_LOW + prio = notification.PRIO_LOW; break; case $KeywordRegistry.notificationPriority$hight(): - prio = notification.PRIO_HIGH + prio = notification.PRIO_HIGH; break; case $KeywordRegistry.notificationPriority$max(): - prio = notification.PRIO_MAX + prio = notification.PRIO_MAX; break; case $KeywordRegistry.notificationPriority$normal(): default: - prio = notification.PRIO_NORMAL - break; + prio = notification.PRIO_NORMAL; } config.forcedPriority(prio); diff --git a/process/CreateNotification_workflowService/serviceTaskParameterProcess.js b/process/CreateNotification_workflowService/serviceTaskParameterProcess.js index fa7063a63b76a5780e371f4bc45d0e892554e1b4..3c5840a32f8ea86f9e6784d370994fac324b4cc9 100644 --- a/process/CreateNotification_workflowService/serviceTaskParameterProcess.js +++ b/process/CreateNotification_workflowService/serviceTaskParameterProcess.js @@ -21,5 +21,6 @@ users = users.map(function (user) result.object([ new WorkflowServiceTaskParameter("notificationCaption", "Caption", WorkflowServiceTaskParameter.STRING()), new WorkflowServiceTaskParameter("notificationDescription", "Description", WorkflowServiceTaskParameter.STRING()), - new WorkflowServiceTaskParameter("notificationUser", "User", WorkflowServiceTaskParameter.ENUM(), users) + new WorkflowServiceTaskParameter("notificationUser", "User", WorkflowServiceTaskParameter.ENUM(), users), + new WorkflowServiceTaskParameter("skipTranslation", "Skip translation", WorkflowServiceTaskParameter.BOOLEAN()) ]); \ No newline at end of file diff --git a/process/Employee_lib/process.js b/process/Employee_lib/process.js index 68230ad249a5bd84c97ca921f588f7ac8da512cd..5bd0f62bc07337d6529c0b4788b62a0a6f09964d 100644 --- a/process/Employee_lib/process.js +++ b/process/Employee_lib/process.js @@ -177,6 +177,18 @@ EmployeeUtils.getUsersDepartment = function(pContactId, pDepartmentAsDisplayable return department; } +/** + * Gets the locale of the specified user. This is the locale from the users last log in. + * + * @param {String} pUserId user id + * @return {String} locale of the user, can be null if the user doesn't exist or has never logged in before + */ +EmployeeUtils.getUserLocale = function (pUserId) +{ + var user = tools.getUserByAttribute(tools.NAME, pUserId, tools.PROFILE_DEFAULT); + return user && user[tools.PARAMS][tools.LOCALE] || null; +} + /** * Provides functions for employeesrole *