diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml new file mode 100644 index 0000000000..66605eb0b5 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.desc.xml @@ -0,0 +1,8 @@ + + End Workflow Task + Ends a task for an in-flight workflow with the passed-in transition or the default + /api/workflow/task/end/{taskId}/{transitionId} + /api/workflow/task/end/{taskId} + + user + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.js b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.js new file mode 100644 index 0000000000..ccbb4af46e --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.js @@ -0,0 +1,33 @@ +function main() +{ + // Task ID + var taskId = url.templateArgs.taskId; + if ((taskId === undefined) || (taskId.length == 0)) + { + status.setCode(status.STATUS_BAD_REQUEST, "TaskID missing when ending task."); + return; + } + + // Check TaskId is valid + var task = workflow.getTask(taskId); + if (task === null) + { + status.setCode(status.STATUS_BAD_REQUEST, "Invalid TaskID when ending task."); + return; + } + + model.taskId = taskId; + + // Optional Transition ID + var transitionId = url.templateArgs.transitionId; + if ((transitionId === undefined) || (transitionId.length == 0)) + { + transitionId = null; + } + + model.transitionId = transitionId; + + task.endTask(transitionId); +} + +main(); \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.json.ftl new file mode 100644 index 0000000000..72027161e5 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/workflow/end-task.post.json.ftl @@ -0,0 +1,6 @@ +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "id": "${taskId}", + "transition": "${transitionId!"default"}" +} + diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml new file mode 100644 index 0000000000..3b9b7d13de --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.desc.xml @@ -0,0 +1,8 @@ + + my-tasks + My Tasks Dashlet Data Webscript + /slingshot/dashlets/my-tasks?filter={filter?}&date={date?} + + user + required + \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.html.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.html.ftl new file mode 100644 index 0000000000..35860a983c --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.html.ftl @@ -0,0 +1 @@ +<#include "my-tasks.get.json.ftl"> \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.json.ftl b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.json.ftl new file mode 100644 index 0000000000..a1bf0b6586 --- /dev/null +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/dashlets/my-tasks.get.json.ftl @@ -0,0 +1,113 @@ +<#assign workingCopyLabel = " " + message("coci_service.working_copy_label")> +<#assign filter = args["filter"]!"all"> + +<#-- Resolve site, container and path --> +<#macro location doc> + <#assign qnamePaths = doc.qnamePath?split("/")> + <#assign displayPaths = doc.displayPath?split("/") + [""]> + <#if ((qnamePaths?size > 5) && (qnamePaths[2] == "st:sites"))> + "site": "${qnamePaths[3]?substring(3)}", + "container": "${qnamePaths[4]?substring(3)}", + "path": "<#list displayPaths[5..] as path><#if path_has_next>/${path}" + + + +<#-- Render a task --> +<#macro taskDetail task> + { + "id": "${task.id}", + "description": "${task.description!""}", + "dueDate": "<#if task.properties["bpm:dueDate"]?exists>${task.properties["bpm:dueDate"]?date!""}<#else>${future?date}", + "status": "${task.properties["bpm:status"]}", + "priority": "${task.properties["bpm:priority"]}", + "startDate": "${task.startDate?date}", + "type": "${task.type}", + "completeness": "${task.properties["bpm:percentComplete"]}", + "resources": + [ +<#list task.packageResources as resource> + { + "nodeRef": "${resource.nodeRef}", + "fileName": "${resource.name}", + "displayName": "${resource.name?replace(workingCopyLabel, "")}", + "location": + { + <@location resource /> + }, + "icon": "${resource.icon16}" + }<#if resource_has_next>, + + ], + "transitions": + [ +<#list task.transitions as transition> + { + "id": "${transition.id}", + "label": "${transition.label}" + }<#if transition_has_next>, + + ] + } + + +<#-- Filter task list --> +<#assign filteredTasks = []> + +<#list workflow.assignedTasks as task> + <#assign hasDate = task.properties["bpm:dueDate"]?exists> + <#assign dueDate><#if task.properties["bpm:dueDate"]?exists>${task.properties["bpm:dueDate"]?date!""}<#else>${future?date} + <#switch filter> + <#case "all"> + <#assign filteredTasks = filteredTasks + [task]> + <#break> + + <#case "today"> + <#if (dateCompare(date?date, dueDate?date, 0, "==") == 1)> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + <#case "tomorrow"> + <#if (dateCompare(tomorrow?date, dueDate?date, 0, "==") == 1)> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + <#case "this-week"> + <#if ((dateCompare(lastSunday?date, dueDate?date) == 0) && (dateCompare(sunday?date, dueDate?date) == 1))> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + <#case "next-week"> + <#if ((dateCompare(sunday?date, dueDate?date) == 0) && (dateCompare(nextSunday?date, dueDate?date) == 1))> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + <#case "overdue"> + <#if (dateCompare(date?date, dueDate?date) == 1)> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + <#case "no-due-date"> + <#if !hasDate> + <#assign filteredTasks = filteredTasks + [task]> + + <#break> + + + + +<#escape x as jsonUtils.encodeJSONString(x)> +{ + "tasks": + [ +<#list filteredTasks as task> + <@taskDetail task /> + <#if task_has_next>, + + ] +} + \ No newline at end of file