mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
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:
@@ -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>
|
@@ -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();
|
@@ -0,0 +1,6 @@
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"id": "${taskId}",
|
||||
"transition": "${transitionId!"default"}"
|
||||
}
|
||||
</#escape>
|
@@ -0,0 +1,8 @@
|
||||
<webscript>
|
||||
<shortname>my-tasks</shortname>
|
||||
<description>My Tasks Dashlet Data Webscript</description>
|
||||
<url>/slingshot/dashlets/my-tasks?filter={filter?}&date={date?}</url>
|
||||
<format default="json"></format>
|
||||
<authentication>user</authentication>
|
||||
<transaction>required</transaction>
|
||||
</webscript>
|
@@ -0,0 +1 @@
|
||||
<#include "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>/</#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>
|
Reference in New Issue
Block a user