DocLib webscript and UI support for accessing Document Library container

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@18969 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2010-03-03 09:05:11 +00:00
parent df31a68c30
commit a324368a30
4 changed files with 98 additions and 22 deletions

View File

@@ -176,26 +176,31 @@ var Common =
qnamePaths = node.qnamePath.split("/"), qnamePaths = node.qnamePath.split("/"),
displayPaths = node.displayPath.split("/"); displayPaths = node.displayPath.split("/");
if (node.isContainer)
{
// We want the path to include the parent folder name
displayPaths = displayPaths.concat([node.name]);
}
if (libraryRoot) if (libraryRoot)
{ {
if (node.isContainer && String(node.nodeRef) != String(libraryRoot.nodeRef))
{
// We want the path to include the parent folder name
displayPaths = displayPaths.concat([node.name]);
}
// Generate the path from the supplied library root // Generate the path from the supplied library root
location = location =
{ {
site: null, site: null,
siteTitle: null, siteTitle: null,
container: null, container: null,
path: "/" + displayPaths.slice(libraryRoot.displayPath.split("/").length + 1, displayPaths.length).join("/"), path: "/" + displayPaths.slice(libraryRoot.displayPath.split("/").length + 1, displayPaths.length).join("/")
file: node.name
}; };
} }
else if ((qnamePaths.length > 4) && (qnamePaths[2] == TYPE_SITES)) else if ((qnamePaths.length > 4) && (qnamePaths[2] == TYPE_SITES))
{ {
if (node.isContainer)
{
// We want the path to include the parent folder name
displayPaths = displayPaths.concat([node.name]);
}
var siteId = displayPaths[3], var siteId = displayPaths[3],
siteNode = Common.getSite(siteId), siteNode = Common.getSite(siteId),
containerId = qnamePaths[4].substr(3); containerId = qnamePaths[4].substr(3);
@@ -221,8 +226,7 @@ var Common =
site: null, site: null,
siteTitle: null, siteTitle: null,
container: null, container: null,
path: "/" + displayPaths.slice(2, displayPaths.length).join("/"), path: "/" + displayPaths.slice(2, displayPaths.length).join("/")
file: node.name
}; };
} }

View File

@@ -84,8 +84,7 @@ function getDoclist()
nodes = nodes.slice(startIndex, pagePos * pageSize); nodes = nodes.slice(startIndex, pagePos * pageSize);
// Common or variable parent container? // Common or variable parent container?
var parent = null, var parent = null;
defaultLocation = {};
if (!filterParams.variablePath) if (!filterParams.variablePath)
{ {
@@ -95,9 +94,6 @@ function getDoclist()
node: parsedArgs.pathNode, node: parsedArgs.pathNode,
userAccess: Evaluator.run(parsedArgs.pathNode).actionPermissions userAccess: Evaluator.run(parsedArgs.pathNode).actionPermissions
}; };
// Store a default location to save repeated calculations
defaultLocation = Common.getLocation(parsedArgs.pathNode, parsedArgs.libraryRoot);
} }
var isThumbnailNameRegistered = thumbnailService.isThumbnailNameRegistered(THUMBNAIL_NAME), var isThumbnailNameRegistered = thumbnailService.isThumbnailNameRegistered(THUMBNAIL_NAME),
@@ -122,10 +118,10 @@ function getDoclist()
{ {
location = location =
{ {
site: defaultLocation.site, site: parsedArgs.location.site,
siteTitle: defaultLocation.siteTitle, siteTitle: parsedArgs.location.siteTitle,
container: defaultLocation.container, container: parsedArgs.location.container,
path: defaultLocation.path, path: parsedArgs.location.path,
file: node.name file: node.name
}; };
} }

View File

@@ -168,9 +168,8 @@ var Filters =
break; break;
case "node": case "node":
parsedArgs.pathNode = parsedArgs.rootNode.parent;
filterParams.variablePath = false; filterParams.variablePath = false;
filterParams.query = "+ID:\"" + parsedArgs.rootNode.nodeRef + "\""; filterParams.query = "+ID:\"" + parsedArgs.nodeRef + "\"";
break; break;
case "tag": case "tag":

View File

@@ -2,4 +2,81 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js"> <import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js">
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js"> <import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js">
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js"> <import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js">
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/doclist.get.js">
/**
* Main entry point: Return single document or folder given it's nodeRef
*
* @method getDoclist
*/
function getDoclist()
{
// Use helper function to get the arguments
var parsedArgs = ParseArgs.getParsedArgs();
if (parsedArgs === null)
{
return;
}
var filter = args.filter,
items = [];
var favourites = Common.getFavourites(),
node = parsedArgs.rootNode,
parent =
{
node: node.parent,
userAccess: Evaluator.run(node.parent).actionPermissions
};
var isThumbnailNameRegistered = thumbnailService.isThumbnailNameRegistered(THUMBNAIL_NAME),
thumbnail = null,
item = Evaluator.run(node);
item.isFavourite = (favourites[node.nodeRef] === true);
item.location =
{
site: parsedArgs.location.site,
siteTitle: parsedArgs.location.siteTitle,
container: parsedArgs.location.container,
path: parsedArgs.location.path,
file: node.name
};
// Special case for container and libraryRoot nodes
if ((parsedArgs.location.containerNode && String(parsedArgs.location.containerNode.nodeRef) == String(node.nodeRef)) ||
(String(parsedArgs.libraryRoot.nodeRef) == String(node.nodeRef)))
{
item.location.file = "";
}
else if (node.isContainer)
{
// Strip off the extra path that will have been added by default
var paths = item.location.path.split("/");
item.location.path = "/" + paths.slice(1, paths.length - 1).join("/");
}
// Is our thumbnail type registered?
if (isThumbnailNameRegistered)
{
// Make sure we have a thumbnail.
thumbnail = node.getThumbnail(THUMBNAIL_NAME);
if (thumbnail === null)
{
// No thumbnail, so queue creation
node.createThumbnail(THUMBNAIL_NAME, true);
}
}
return (
{
parent: parent,
onlineEditing: utils.moduleInstalled("org.alfresco.module.vti"),
items: [item]
});
}
/**
* Document List Component: doclist
*/
model.doclist = getDoclist();