mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
DocLibrary TreeView added.
alfresco_template.ftl optionally loads debug YUI scripts (default to true for now) git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9236 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,8 @@
|
|||||||
|
<webscript>
|
||||||
|
<shortname>treenode</shortname>
|
||||||
|
<description>Document List Component - treenode data webscript</description>
|
||||||
|
<url>/slingshot/doclib/treenode?nodeRef={nodeRef?}&path={path?}</url>
|
||||||
|
<format default="json"></format>
|
||||||
|
<authentication>user</authentication>
|
||||||
|
<transaction>required</transaction>
|
||||||
|
</webscript>
|
@@ -0,0 +1 @@
|
|||||||
|
<#include "treenode.get.json.ftl">
|
@@ -0,0 +1,65 @@
|
|||||||
|
/**
|
||||||
|
* Document List Component: treenode
|
||||||
|
*
|
||||||
|
* Inputs:
|
||||||
|
* mandatory: nodeRef = parent space nodeRef
|
||||||
|
* OR: path = parent space relative path from companyhome
|
||||||
|
*
|
||||||
|
* Outputs:
|
||||||
|
* treenode - object containing list of child folder nodes for a TreeView widget
|
||||||
|
*/
|
||||||
|
model.treenode = getTreenode(args["nodeRef"], args["path"]);
|
||||||
|
|
||||||
|
/* Create collection of folders in the given space */
|
||||||
|
function getTreenode(nodeRef, path)
|
||||||
|
{
|
||||||
|
var items = new Array();
|
||||||
|
|
||||||
|
/* nodeRef input */
|
||||||
|
var parentSpace = null;
|
||||||
|
if ((nodeRef !== null) && (nodeRef != ""))
|
||||||
|
{
|
||||||
|
parentSpace = search.findNode(nodeRef);
|
||||||
|
}
|
||||||
|
else if ((path !== null) && path != "")
|
||||||
|
{
|
||||||
|
parentSpace = companyhome.childByNamePath(path);
|
||||||
|
}
|
||||||
|
if (parentSpace === null)
|
||||||
|
{
|
||||||
|
// return jsonError("Parent space nodeRef not supplied");
|
||||||
|
parentSpace = companyhome;
|
||||||
|
}
|
||||||
|
|
||||||
|
for each(item in parentSpace.children)
|
||||||
|
{
|
||||||
|
if (item.isContainer)
|
||||||
|
{
|
||||||
|
items.push(item);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
items.sort(sortByName);
|
||||||
|
|
||||||
|
return ({
|
||||||
|
"items": items
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/* Format and return error object */
|
||||||
|
function jsonError(errorString)
|
||||||
|
{
|
||||||
|
var obj =
|
||||||
|
{
|
||||||
|
"error": errorString
|
||||||
|
};
|
||||||
|
|
||||||
|
return obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Sort the results by case-insensitive name */
|
||||||
|
function sortByName(a, b)
|
||||||
|
{
|
||||||
|
return (b.name.toLowerCase() > a.name.toLowerCase() ? -1 : 1);
|
||||||
|
}
|
@@ -0,0 +1,25 @@
|
|||||||
|
{
|
||||||
|
"treenode":
|
||||||
|
{
|
||||||
|
<#if treenode.error?exists>
|
||||||
|
"error": "${treenodes.error}"
|
||||||
|
<#else>
|
||||||
|
"items":
|
||||||
|
[
|
||||||
|
<#list treenode.items as t>
|
||||||
|
<#assign hasChildren = false>
|
||||||
|
<#list t.children as c>
|
||||||
|
<#if c.isContainer><#assign hasChildren = true><#break></#if>
|
||||||
|
</#list>
|
||||||
|
{
|
||||||
|
"nodeRef": "${t.nodeRef}",
|
||||||
|
"name": "${t.name}",
|
||||||
|
"description": "${t.properties.description!""}",
|
||||||
|
"hasChildren": ${hasChildren?string}
|
||||||
|
}
|
||||||
|
<#if t_has_next>,</#if>
|
||||||
|
</#list>
|
||||||
|
]
|
||||||
|
</#if>
|
||||||
|
}
|
||||||
|
}
|
Reference in New Issue
Block a user