From ae8522df09c8807bf5c803ef61c989a6961dcb32 Mon Sep 17 00:00:00 2001 From: Mike Hatfield Date: Fri, 25 Apr 2008 08:25:12 +0000 Subject: [PATCH] New template format and Freemarker macros. Improved YUILoader wrapper. Placeholder doclist using YUI DataTable for testing. git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@8883 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261 --- .../documentlibrary/doclist.get.desc.xml | 4 +-- .../slingshot/documentlibrary/doclist.get.js | 36 ++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml index a1e6f45e2a..8e5520e096 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.desc.xml @@ -1,7 +1,7 @@ doclist Document List Component - doclist data webscript - /slingshot/doclib/doclist?nodeRef={nodeRef} - user + /slingshot/doclib/doclist?nodeRef={nodeRef?}&path={path?} + guest required \ No newline at end of file diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js index 996e6a7a0f..09d8283040 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js @@ -7,10 +7,10 @@ * Outputs: * doclist - object containing list of child folders and documents in the parent space */ -model.doclist = getDoclist(args["nodeRef"]); +model.doclist = getDoclist(args["nodeRef"], args["path"], args["type"]); /* Create collection of documents and folders in the given space */ -function getDoclist(nodeRef) +function getDoclist(nodeRef, path, type) { var items = new Array(); @@ -20,16 +20,35 @@ function getDoclist(nodeRef) { parentSpace = search.findNode(nodeRef); } + else if ((path != null) && path != "") + { + parentSpace = companyhome.childByNamePath(path); + } if (parentSpace == null) { - return jsonError("Parent space nodeRef not supplied"); + // return jsonError("Parent space nodeRef not supplied"); + parentSpace = companyhome; + } + + var showDocs = true, + showFolders = true; + + if ((type != null) && (type != "")) + { + showDocs = (type == "documents"); + showFolders = (type == "folders"); } for each(item in parentSpace.children) { - items.push(item); + if ((item.isContainer && showFolders) || (!item.isContainer && showDocs)) + { + items.push(item); + } } + items.sort(sortByType); + return ({ "items": items }); @@ -45,4 +64,13 @@ function jsonError(errorString) }; return obj; +} + +function sortByType(a, b) +{ + if (a.isContainer == b.isContainer) + { + return (b.name.toLowerCase() > a.name.toLowerCase() ? -1 : 1); + } + return (a.isContainer ? -1 : 1); } \ No newline at end of file