My Tasks dashlet.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10421 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2008-08-19 14:06:53 +00:00
parent 1533fdf240
commit 9a4ce6d812
6 changed files with 169 additions and 0 deletions

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>End Workflow Task</shortname>
<description>Ends a task for an in-flight workflow with the passed-in transition or the default</description>
<url>/api/workflow/task/end/{taskId}/{transitionId}</url>
<url>/api/workflow/task/end/{taskId}</url>
<format default="json"/>
<authentication>user</authentication>
</webscript>

View File

@@ -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();

View File

@@ -0,0 +1,6 @@
<#escape x as jsonUtils.encodeJSONString(x)>
{
"id": "${taskId}",
"transition": "${transitionId!"default"}"
}
</#escape>

View File

@@ -0,0 +1,8 @@
<webscript>
<shortname>my-tasks</shortname>
<description>My Tasks Dashlet Data Webscript</description>
<url>/slingshot/dashlets/my-tasks?filter={filter?}&amp;date={date?}</url>
<format default="json"></format>
<authentication>user</authentication>
<transaction>required</transaction>
</webscript>

View File

@@ -0,0 +1 @@
<#include "my-tasks.get.json.ftl">

View File

@@ -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 &gt; 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>/</#if>${path}</#list>"
</#if>
</#macro>
<#-- 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}</#if>",
"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>,</#if>
</#list>
],
"transitions":
[
<#list task.transitions as transition>
{
"id": "${transition.id}",
"label": "${transition.label}"
}<#if transition_has_next>,</#if>
</#list>
]
}
</#macro>
<#-- 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}</#if></#assign>
<#switch filter>
<#case "all">
<#assign filteredTasks = filteredTasks + [task]>
<#break>
<#case "today">
<#if (dateCompare(date?date, dueDate?date, 0, "==") == 1)>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
<#case "tomorrow">
<#if (dateCompare(tomorrow?date, dueDate?date, 0, "==") == 1)>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
<#case "this-week">
<#if ((dateCompare(lastSunday?date, dueDate?date) == 0) && (dateCompare(sunday?date, dueDate?date) == 1))>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
<#case "next-week">
<#if ((dateCompare(sunday?date, dueDate?date) == 0) && (dateCompare(nextSunday?date, dueDate?date) == 1))>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
<#case "overdue">
<#if (dateCompare(date?date, dueDate?date) == 1)>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
<#case "no-due-date">
<#if !hasDate>
<#assign filteredTasks = filteredTasks + [task]>
</#if>
<#break>
</#switch>
</#list>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"tasks":
[
<#list filteredTasks as task>
<@taskDetail task />
<#if task_has_next>,</#if>
</#list>
]
}
</#escape>