Document Library support for pagination - currently off by default (in component instance definition). Reworked More Actions pop-up to avoid MSIE script error on deferred events. YUI History Manager allowed to initialise correctly. OpenOffice mimetypes added to allowed swf preview pop-up.

git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@10249 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
Mike Hatfield
2008-08-05 12:13:39 +00:00
parent 720b70035f
commit fd3f660ee6
3 changed files with 148 additions and 131 deletions

View File

@@ -13,7 +13,7 @@ model.doclist = getDocList(args["filter"]);
function getDocList(filter)
{
var items = new Array();
var assets;
var assets = new Array()
// Is our thumbnail tpe registered?
var haveThumbnails = thumbnailService.isThumbnailNameRegistered(THUMBNAIL_NAME);
@@ -26,24 +26,25 @@ function getDocList(filter)
}
// Try to find a filter query based on the passed-in arguments
var allAssets;
var filterQuery = getFilterQuery(filter, parsedArgs);
if (filterQuery === null)
{
// Default to all children of parentNode
assets = parsedArgs.parentNode.children;
allAssets = parsedArgs.parentNode.children;
}
else if (filterQuery == "node")
{
assets = [parsedArgs.rootNode];
allAssets = [parsedArgs.rootNode];
}
else if (filterQuery == "tag")
{
assets = parsedArgs.rootNode.childrenByTags(args["filterData"]);
allAssets = parsedArgs.rootNode.childrenByTags(args["filterData"]);
}
else
{
// Run the query returned from the filter
assets = search.luceneSearch(filterQuery);
allAssets = search.luceneSearch(filterQuery);
}
// Documents and/or folders?
@@ -56,6 +57,27 @@ function getDocList(filter)
showFolders = ((type == "all") || (type == "folders"));
}
// Only interesting in folders and/or documents depending on passed-in type
for each(asset in allAssets)
{
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
{
assets.push(asset);
}
}
// Make a note of totalRecords before trimming the assets array
var totalRecords = assets.length;
// Sort the list before trimming to page chunks
assets.sort(sortByType);
// Pagination
var pageSize = args["size"] || assets.length;
var pagePos = args["pos"] || "1";
var startIndex = (pagePos - 1) * pageSize;
assets = assets.slice(startIndex, pagePos * pageSize);
// Locked/working copy status defines action set
var itemStatus, itemOwner, actionSet, thumbnail, createdBy, modifiedBy;
@@ -66,8 +88,6 @@ function getDocList(filter)
createdBy = null;
modifiedBy = null;
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
{
if (asset.isLocked)
{
itemStatus.push("locked");
@@ -117,23 +137,25 @@ function getDocList(filter)
tags: asset.tags
});
}
}
items.sort(sortByType);
return (
{
"luceneQuery": filterQuery,
"items": items
luceneQuery: filterQuery,
paging:
{
startIndex: startIndex,
totalRecords: totalRecords
},
items: items
});
}
function sortByType(a, b)
{
if (a.asset.isContainer == b.asset.isContainer)
if (a.isContainer == b.isContainer)
{
return (b.asset.name.toLowerCase() > a.asset.name.toLowerCase() ? -1 : 1);
return (b.name.toLowerCase() > a.name.toLowerCase() ? -1 : 1);
}
return (a.asset.isContainer ? -1 : 1);
return (a.isContainer ? -1 : 1);
}

View File

@@ -1,9 +1,8 @@
<#assign workingCopyLabel = " " + message("coci_service.working_copy_label")>
<#escape x as jsonUtils.encodeJSONString(x)>
{
"doclist":
{
"totalItems": ${doclist.items?size?string},
"totalRecords": ${doclist.paging.totalRecords?c},
"startIndex": ${doclist.paging.startIndex?c},
"items":
[
<#list doclist.items as item>
@@ -57,5 +56,4 @@
</#list>
]
}
}
</#escape>

View File

@@ -1,8 +1,6 @@
<#escape x as jsonUtils.encodeJSONString(x)>
{
"treenode":
{
"totalItems": ${treenode.items?size},
"totalResults": ${treenode.items?size?c},
"items":
[
<#list treenode.items as t>
@@ -19,5 +17,4 @@
</#list>
]
}
}
</#escape>