DocumentLibrary working again with moved Sites home. "Create folder" using simple dialog framework. Doclist and tree webscript support for nodeRefs. Base.css tweaks to font-size, yui-skin-sam names restored. Toolbar swaps visible elements based on active display filter.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9814 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2008-07-11 13:21:21 +00:00
parent 1cae290559
commit 02aeeb60e0
15 changed files with 207 additions and 204 deletions

View File

@@ -43,7 +43,7 @@ function getDocs(siteId, filter)
if (logger.isLoggingEnabled())
logger.log("docsummary query = " + query);
var docs = search.luceneSearch("workspace://SiteStore", query, "cm:modified", false);
var docs = search.luceneSearch(query, "cm:modified", false);
if (logger.isLoggingEnabled())
logger.log("number of results = " + docs.length);

View File

@@ -20,7 +20,7 @@ function main()
{
// Params object contains commonly-used arguments
var params;
if (url.templateArgs.storetype != undefined)
if (url.templateArgs.store_type != undefined)
{
params = getNodeRefInputParams();
}
@@ -89,37 +89,37 @@ function getSiteInputParams()
try
{
// First try to get the parameters from the URI
var siteId = url.templateArgs.siteid;
var containerId = url.templateArgs.containerId;
var filePath = url.templateArgs.filepath;
var siteId = url.templateArgs.site;
var containerId = url.templateArgs.container;
var filePath = url.templateArgs.path;
// Was a JSON parameter list supplied?
// TODO: Also handle multiple files
if (typeof json == "object")
{
if (!json.isNull("siteid"))
if (!json.isNull("site"))
{
siteId = json.get("siteid");
siteId = json.get("site");
}
if (!json.isNull("containerId"))
if (!json.isNull("container"))
{
containerId = json.get("containerId");
containerId = json.get("container");
}
if (!json.isNull("filepath"))
if (!json.isNull("path"))
{
filePath = json.get("filepath");
filePath = json.get("path");
}
}
if ((siteId === null) || (siteId.length === 0))
{
return "'siteId' parameter is missing.";
return "'site' parameter is missing.";
}
// containerId
if ((containerId === null) || (containerId.length === 0))
{
return "'containerId' parameter is missing.";
return "'container' parameter is missing.";
}
// filePath might be null for the root folder
@@ -175,21 +175,21 @@ function getNodeRefInputParams()
try
{
// First try to get the parameters from the URI
var storeType = url.templateArgs.storetype;
var storeId = url.templateArgs.storeid;
var storeType = url.templateArgs.store_type;
var storeId = url.templateArgs.store_id;
var id = url.templateArgs.id;
// Was a JSON parameter list supplied?
// TODO: Also handle multiple files
if (typeof json == "object")
{
if (!json.isNull("storetype"))
if (!json.isNull("store_type"))
{
storeType = json.get("storetype");
storeType = json.get("store_type");
}
if (!json.isNull("storeid"))
if (!json.isNull("store_id"))
{
storeId = json.get("storeid");
storeId = json.get("store_id");
}
if (!json.isNull("id"))
{

View File

@@ -1,8 +1,8 @@
<webscript>
<shortname>cancel-checkout</shortname>
<description>Document List Action - Cancel check-out for file</description>
<url>/slingshot/doclib/action/cancel-checkout/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/cancel-checkout/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/cancel-checkout/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/cancel-checkout/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,8 +1,8 @@
<webscript>
<shortname>checkin</shortname>
<description>Document List Action - Check-in file</description>
<url>/slingshot/doclib/action/checkin/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/checkin/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/checkin/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/checkin/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,8 +1,8 @@
<webscript>
<shortname>checkout</shortname>
<description>Document List Action - Check-out file</description>
<url>/slingshot/doclib/action/checkout/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/checkout/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/checkout/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/checkout/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -45,6 +45,7 @@ function runAction(p_params)
{
id: resultId,
nodeRef: resultNodeRef,
downloadUrl: "api/node/content/" + resultNodeRef.replace(":/", "") + "/" + workingCopy.name + "?a=true",
action: "checkoutAsset",
success: true
}];

View File

@@ -1,10 +1,10 @@
<webscript>
<shortname>file</shortname>
<description>Document List Action - Delete file</description>
<url>/slingshot/doclib/action/file/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/folder/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/file/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/folder/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/file/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/folder/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/file/node/{store_type}/{store_id}/{id}</url>
<url>/slingshot/doclib/action/folder/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,9 +1,9 @@
<webscript>
<shortname>folder</shortname>
<description>Document List Action - Create folder</description>
<url>/slingshot/doclib/action/folder/site/{siteid}/{containerId}</url>
<url>/slingshot/doclib/action/folder/site/{siteid}/{containerId}/{filepath}</url>
<url>/slingshot/doclib/action/folder/node/{storetype}/{storeid}/{id}</url>
<url>/slingshot/doclib/action/folder/site/{site}/{container}</url>
<url>/slingshot/doclib/action/folder/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/action/folder/node/{store_type}/{store_id}/{id}</url>
<format default="json">argument</format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,7 +1,10 @@
<webscript>
<shortname>doclist</shortname>
<description>Document List Component - doclist data webscript</description>
<url>/slingshot/doclib/doclist?site={site}&amp;path={path?}&amp;type={type?}</url>
<url>/slingshot/doclib/doclist/{type}/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/doclist/{type}/site/{site}/{container}</url>
<url>/slingshot/doclib/doclist/{type}/node/{store_type}/{store_id}/{id}/{path}</url>
<url>/slingshot/doclib/doclist/{type}/node/{store_type}/{store_id}/{id}</url>
<format default="json"></format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,141 +1,100 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/filters.lib.js">
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/action-sets.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">
/**
* Document List Component: doclist
*
* Inputs:
* mandatory: site = the site containing the document library
* optional: path = folder relative to root store
*
* Outputs:
* doclist - object containing list of child folders and documents
*/
model.doclist = getDoclist(args["site"], args["path"], args["type"], args["filter"]);
model.doclist = getDoclist(args["filter"]);
/* Create collection of documents and folders in the given space */
function getDoclist(siteId, path, type, filter)
function getDoclist(filter)
{
try
var items = new Array();
var assets;
// Use helper function to get the arguments
var parsedArgs = getParsedArgs();
if (parsedArgs === null)
{
var items = new Array();
/* siteId input */
var siteNode = siteService.getSite(siteId);
if (siteNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Site not found: '" + siteId + "'");
return;
}
var containerNode = siteNode.getContainer("documentLibrary");
if (containerNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Document Library container not found in: " + siteId + ". (No write permission?)");
return;
}
/* path input */
if ((path !== null) && (path != ""))
{
pathNode = containerNode.childByNamePath(path);
}
else
{
pathNode = containerNode;
path = "";
}
if (pathNode === null)
{
pathNode = containerNode;
}
var showDocs = true;
var showFolders = true;
// Default to all children of pathNode
var assets = pathNode.children;
// Try to find a filter query based on the passed-in arguments
var filterParams =
{
siteNode: siteNode,
containerNode: containerNode,
pathNode: pathNode
}
var filterQuery = getFilterQuery(filter, filterParams);
if (filterQuery != null)
{
assets = search.luceneSearch("workspace://SiteStore", filterQuery);
}
// Documents and/or folders?
if ((type !== null) && (type != ""))
{
showDocs = (type == "documents");
showFolders = (type == "folders");
}
// Locked/working copy status defines action set
var itemStatus;
var itemOwner;
var actionSet;
for each(asset in assets)
{
itemStatus = [];
itemOwner = "";
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
{
if (asset.isLocked)
{
itemStatus.push("locked");
itemOwner = asset.properties["cm:lockOwner"];
}
if (asset.hasAspect("cm:workingcopy"))
{
itemStatus.push("workingCopy");
itemOwner = asset.properties["cm:workingCopyOwner"];
}
// Is this user the item owner?
if (itemOwner == person.properties.userName)
{
itemStatus.push("lockedBySelf");
}
// Get relevant actions set
actionSet = getActionSet(asset,
{
itemStatus: itemStatus,
itemOwner: itemOwner
});
items.push(
{
asset: asset,
parent: path,
status: itemStatus,
owner: itemOwner,
actionSet: actionSet
});
}
}
items.sort(sortByType);
return (
{
"luceneQuery": filterQuery,
"items": items
});
}
catch(e)
{
status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, e.toString());
return;
}
// Try to find a filter query based on the passed-in arguments
var filterQuery = getFilterQuery(filter, parsedArgs);
if (filterQuery === null)
{
// Default to all children of parentNode
assets = parsedArgs.parentNode.children;
}
else
{
// Run the query returned from the filter
assets = search.luceneSearch(filterQuery);
}
// Documents and/or folders?
var showDocs = true;
var showFolders = true;
var type = url.templateArgs.type;
if ((type !== null) && (type != ""))
{
showDocs = ((type == "all") || (type == "documents"));
showFolders = ((type == "all") || (type == "folders"));
}
// Locked/working copy status defines action set
var itemStatus;
var itemOwner;
var actionSet;
for each(asset in assets)
{
itemStatus = [];
itemOwner = "";
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
{
if (asset.isLocked)
{
itemStatus.push("locked");
itemOwner = asset.properties["cm:lockOwner"];
}
if (asset.hasAspect("cm:workingcopy"))
{
itemStatus.push("workingCopy");
itemOwner = asset.properties["cm:workingCopyOwner"];
}
// Is this user the item owner?
if (itemOwner == person.properties.userName)
{
itemStatus.push("lockedBySelf");
}
// Get relevant actions set
actionSet = getActionSet(asset,
{
itemStatus: itemStatus,
itemOwner: itemOwner
});
items.push(
{
asset: asset,
status: itemStatus,
owner: itemOwner,
actionSet: actionSet
});
}
}
items.sort(sortByType);
return (
{
"luceneQuery": filterQuery,
"items": items
});
}

View File

@@ -1,3 +1,4 @@
<#assign workingCopyLabel = " " + message("coci_service.working_copy_label")>
{
"doclist":
{
@@ -14,9 +15,8 @@
"type": "<#if d.isContainer>folder<#else>document</#if>",
"mimetype": "${d.mimetype!""}",
"icon32": "${d.icon32}",
"displayName": "${d.name?replace(" (Working Copy)", "")?html}",
"actualName": "${d.name?html}",
"parent": "${item.parent}",
"fileName": "${d.name?html}",
"displayName": "${d.name?replace(workingCopyLabel, "")?html}",
"status": "<#list item.status as s>${s}<#if s_has_next>,</#if></#list>",
"lockedBy": "${item.owner}",
"title": "${(d.properties.title!"")?html}",

View File

@@ -27,25 +27,25 @@ function getFilterQuery(filter, obj)
date.setDate(date.getDate() - dayCount);
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth() + 1) + "\\-" + date.getDate();
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" ";
filterQuery = "+PATH:\"" + obj.rootNode.qnamePath + "//*\" ";
filterQuery += "+@cm\\:" + dateField + ":[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59] ";
filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
break;
case "editingMe":
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" ";
filterQuery = "+PATH:\"" + obj.rootNode.qnamePath + "//*\" ";
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
filterQuery += "+@cm\\:workingCopyOwner:" + person.properties.userName;
break;
case "editingOthers":
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" ";
filterQuery = "+PATH:\"" + obj.rootNode.qnamePath + "//*\" ";
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
filterQuery += "-@cm\\:workingCopyOwner:" + person.properties.userName;
break;
default:
filterQuery = "+PATH:\"" + obj.pathNode.qnamePath + "/*\" ";
filterQuery = "+PATH:\"" + obj.parentNode.qnamePath + "/*\" ";
filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
break;
}

View File

@@ -0,0 +1,63 @@
function getParsedArgs()
{
var rootNode = null;
var parentNode = null;
if (url.templateArgs.store_type != undefined)
{
// nodeRef input
var storeType = url.templateArgs.store_type;
var storeId = url.templateArgs.store_id;
var id = url.templateArgs.id;
var nodeRef = storeType + "://" + storeId + "/" + id;
rootNode = search.findNode(nodeRef);
if (rootNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Not a valid nodeRef: '" + nodeRef + "'");
return;
}
}
else
{
// site, component container, path input
var site = url.templateArgs.site;
var container = url.templateArgs.container;
var siteNode = siteService.getSite(site);
if (siteNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Site not found: '" + site + "'");
return;
}
rootNode = siteNode.getContainer(container);
if (rootNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Document Library container '" + container + "' not found in '" + site + "'. (No permission?)");
return;
}
}
// path input
var path = url.templateArgs.path;
if ((path !== null) && (path != ""))
{
parentNode = rootNode.childByNamePath(path);
}
else
{
parentNode = rootNode;
path = "";
}
if (parentNode === null)
{
parentNode = rootNode;
}
return (
{
rootNode: rootNode,
parentNode: parentNode,
path: path
});
}

View File

@@ -1,7 +1,10 @@
<webscript>
<shortname>treenode</shortname>
<description>Document List Component - treenode data webscript</description>
<url>/slingshot/doclib/treenode?site={site}&amp;path={path?}</url>
<url>/slingshot/doclib/treenode/site/{site}/{container}/{path}</url>
<url>/slingshot/doclib/treenode/site/{site}/{container}</url>
<url>/slingshot/doclib/treenode/node/{store_type}/{store_id}/{id}/{path}</url>
<url>/slingshot/doclib/treenode/node/{store_type}/{store_id}/{id}</url>
<format default="json"></format>
<authentication>user</authentication>
<transaction>required</transaction>

View File

@@ -1,14 +1,9 @@
<import resource="classpath:/alfresco/templates/webscripts/org/alfresco/slingshot/documentlibrary/parse-args.lib.js">
/**
* Document List Component: treenode
*
* Inputs:
* mandatory: site = the site containing the document library
* optional: path = folder relative to root store
*
* Outputs:
* treenode - object containing list of child folder nodes for a TreeView widget
*/
model.treenode = getTreenode(args["site"], args["path"]);
model.treenode = getTreenode();
/* Create collection of folders in the given space */
function getTreenode(siteId, path)
@@ -17,37 +12,15 @@ function getTreenode(siteId, path)
{
var items = new Array();
/* siteId input */
var site = siteService.getSite(siteId);
if (site === null)
// Use helper function to get the arguments
var parsedArgs = getParsedArgs();
if (parsedArgs === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Site not found: '" + siteId + "'");
return;
}
var parentNode = site.getContainer("documentLibrary");
if (parentNode === null)
{
status.setCode(status.STATUS_BAD_REQUEST, "Document Library container not found in: " + siteId + ". (No write permission?)");
return;
}
/* path input */
if ((path !== null) && (path != ""))
{
parentSpace = parentNode.childByNamePath(path);
}
else
{
parentSpace = parentNode;
}
if (parentSpace === null)
{
parentSpace = parentNode;
}
for each(item in parentSpace.children)
// Look for folders in the parentNode
for each(item in parsedArgs.parentNode.children)
{
if (item.isContainer)
{
@@ -57,7 +30,8 @@ function getTreenode(siteId, path)
items.sort(sortByName);
return ({
return (
{
"items": items
});
}