diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js index b310a43b6c..4fa6059543 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/common.lib.js @@ -176,26 +176,31 @@ var Common = qnamePaths = node.qnamePath.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 (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 location = { site: null, siteTitle: null, container: null, - path: "/" + displayPaths.slice(libraryRoot.displayPath.split("/").length + 1, displayPaths.length).join("/"), - file: node.name + path: "/" + displayPaths.slice(libraryRoot.displayPath.split("/").length + 1, displayPaths.length).join("/") }; } 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], siteNode = Common.getSite(siteId), containerId = qnamePaths[4].substr(3); @@ -221,8 +226,7 @@ var Common = site: null, siteTitle: null, container: null, - path: "/" + displayPaths.slice(2, displayPaths.length).join("/"), - file: node.name + path: "/" + displayPaths.slice(2, displayPaths.length).join("/") }; } 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 89607299a4..cf1194a213 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 @@ -84,8 +84,7 @@ function getDoclist() nodes = nodes.slice(startIndex, pagePos * pageSize); // Common or variable parent container? - var parent = null, - defaultLocation = {}; + var parent = null; if (!filterParams.variablePath) { @@ -95,9 +94,6 @@ function getDoclist() node: parsedArgs.pathNode, 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), @@ -122,10 +118,10 @@ function getDoclist() { location = { - site: defaultLocation.site, - siteTitle: defaultLocation.siteTitle, - container: defaultLocation.container, - path: defaultLocation.path, + site: parsedArgs.location.site, + siteTitle: parsedArgs.location.siteTitle, + container: parsedArgs.location.container, + path: parsedArgs.location.path, file: node.name }; } diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js index e43fca57da..2790834d45 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js @@ -168,9 +168,8 @@ var Filters = break; case "node": - parsedArgs.pathNode = parsedArgs.rootNode.parent; filterParams.variablePath = false; - filterParams.query = "+ID:\"" + parsedArgs.rootNode.nodeRef + "\""; + filterParams.query = "+ID:\"" + parsedArgs.nodeRef + "\""; break; case "tag": diff --git a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js index 5ac18daaf4..a59f7f98d9 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js +++ b/config/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/node.get.js @@ -2,4 +2,81 @@ - \ No newline at end of file + +/** + * 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(); \ No newline at end of file