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()) if (logger.isLoggingEnabled())
logger.log("docsummary query = " + query); 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()) if (logger.isLoggingEnabled())
logger.log("number of results = " + docs.length); logger.log("number of results = " + docs.length);

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@@ -1,7 +1,10 @@
<webscript> <webscript>
<shortname>doclist</shortname> <shortname>doclist</shortname>
<description>Document List Component - doclist data webscript</description> <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> <format default="json"></format>
<authentication>user</authentication> <authentication>user</authentication>
<transaction>required</transaction> <transaction>required</transaction>

View File

@@ -1,80 +1,46 @@
<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/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 * 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 */ /* 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 items = new Array();
var assets;
/* siteId input */ // Use helper function to get the arguments
var siteNode = siteService.getSite(siteId); var parsedArgs = getParsedArgs();
if (siteNode === null) if (parsedArgs === null)
{ {
status.setCode(status.STATUS_BAD_REQUEST, "Site not found: '" + siteId + "'");
return; return;
} }
var containerNode = siteNode.getContainer("documentLibrary"); // Try to find a filter query based on the passed-in arguments
if (containerNode === null) var filterQuery = getFilterQuery(filter, parsedArgs);
if (filterQuery === null)
{ {
status.setCode(status.STATUS_BAD_REQUEST, "Document Library container not found in: " + siteId + ". (No write permission?)"); // Default to all children of parentNode
return; assets = parsedArgs.parentNode.children;
}
/* path input */
if ((path !== null) && (path != ""))
{
pathNode = containerNode.childByNamePath(path);
} }
else else
{ {
pathNode = containerNode; // Run the query returned from the filter
path = ""; assets = search.luceneSearch(filterQuery);
}
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? // Documents and/or folders?
var showDocs = true;
var showFolders = true;
var type = url.templateArgs.type;
if ((type !== null) && (type != "")) if ((type !== null) && (type != ""))
{ {
showDocs = (type == "documents"); showDocs = ((type == "all") || (type == "documents"));
showFolders = (type == "folders"); showFolders = ((type == "all") || (type == "folders"));
} }
// Locked/working copy status defines action set // Locked/working copy status defines action set
@@ -115,7 +81,6 @@ function getDoclist(siteId, path, type, filter)
items.push( items.push(
{ {
asset: asset, asset: asset,
parent: path,
status: itemStatus, status: itemStatus,
owner: itemOwner, owner: itemOwner,
actionSet: actionSet actionSet: actionSet
@@ -131,12 +96,6 @@ function getDoclist(siteId, path, type, filter)
"items": items "items": items
}); });
} }
catch(e)
{
status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, e.toString());
return;
}
}
function sortByType(a, b) function sortByType(a, b)

View File

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

View File

@@ -27,25 +27,25 @@ function getFilterQuery(filter, obj)
date.setDate(date.getDate() - dayCount); date.setDate(date.getDate() - dayCount);
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth() + 1) + "\\-" + date.getDate(); 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 += "+@cm\\:" + dateField + ":[" + fromQuery + "T00\\:00\\:00 TO " + toQuery + "T23\\:59\\:59] ";
filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\""; filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
break; break;
case "editingMe": case "editingMe":
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" "; filterQuery = "+PATH:\"" + obj.rootNode.qnamePath + "//*\" ";
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" "; filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
filterQuery += "+@cm\\:workingCopyOwner:" + person.properties.userName; filterQuery += "+@cm\\:workingCopyOwner:" + person.properties.userName;
break; break;
case "editingOthers": case "editingOthers":
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" "; filterQuery = "+PATH:\"" + obj.rootNode.qnamePath + "//*\" ";
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" "; filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
filterQuery += "-@cm\\:workingCopyOwner:" + person.properties.userName; filterQuery += "-@cm\\:workingCopyOwner:" + person.properties.userName;
break; break;
default: default:
filterQuery = "+PATH:\"" + obj.pathNode.qnamePath + "/*\" "; filterQuery = "+PATH:\"" + obj.parentNode.qnamePath + "/*\" ";
filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\""; filterQuery += "-ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\"";
break; 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> <webscript>
<shortname>treenode</shortname> <shortname>treenode</shortname>
<description>Document List Component - treenode data webscript</description> <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> <format default="json"></format>
<authentication>user</authentication> <authentication>user</authentication>
<transaction>required</transaction> <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 * 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 */ /* Create collection of folders in the given space */
function getTreenode(siteId, path) function getTreenode(siteId, path)
@@ -17,37 +12,15 @@ function getTreenode(siteId, path)
{ {
var items = new Array(); var items = new Array();
/* siteId input */ // Use helper function to get the arguments
var site = siteService.getSite(siteId); var parsedArgs = getParsedArgs();
if (site === null) if (parsedArgs === null)
{ {
status.setCode(status.STATUS_BAD_REQUEST, "Site not found: '" + siteId + "'");
return; return;
} }
var parentNode = site.getContainer("documentLibrary"); // Look for folders in the parentNode
if (parentNode === null) for each(item in parsedArgs.parentNode.children)
{
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)
{ {
if (item.isContainer) if (item.isContainer)
{ {
@@ -57,7 +30,8 @@ function getTreenode(siteId, path)
items.sort(sortByName); items.sort(sortByName);
return ({ return (
{
"items": items "items": items
}); });
} }