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) function getDocList(filter)
{ {
var items = new Array(); var items = new Array();
var assets; var assets = new Array()
// Is our thumbnail tpe registered? // Is our thumbnail tpe registered?
var haveThumbnails = thumbnailService.isThumbnailNameRegistered(THUMBNAIL_NAME); 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 // Try to find a filter query based on the passed-in arguments
var allAssets;
var filterQuery = getFilterQuery(filter, parsedArgs); var filterQuery = getFilterQuery(filter, parsedArgs);
if (filterQuery === null) if (filterQuery === null)
{ {
// Default to all children of parentNode // Default to all children of parentNode
assets = parsedArgs.parentNode.children; allAssets = parsedArgs.parentNode.children;
} }
else if (filterQuery == "node") else if (filterQuery == "node")
{ {
assets = [parsedArgs.rootNode]; allAssets = [parsedArgs.rootNode];
} }
else if (filterQuery == "tag") else if (filterQuery == "tag")
{ {
assets = parsedArgs.rootNode.childrenByTags(args["filterData"]); allAssets = parsedArgs.rootNode.childrenByTags(args["filterData"]);
} }
else else
{ {
// Run the query returned from the filter // Run the query returned from the filter
assets = search.luceneSearch(filterQuery); allAssets = search.luceneSearch(filterQuery);
} }
// Documents and/or folders? // Documents and/or folders?
@@ -56,6 +57,27 @@ function getDocList(filter)
showFolders = ((type == "all") || (type == "folders")); 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 // Locked/working copy status defines action set
var itemStatus, itemOwner, actionSet, thumbnail, createdBy, modifiedBy; var itemStatus, itemOwner, actionSet, thumbnail, createdBy, modifiedBy;
@@ -66,8 +88,6 @@ function getDocList(filter)
createdBy = null; createdBy = null;
modifiedBy = null; modifiedBy = null;
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
{
if (asset.isLocked) if (asset.isLocked)
{ {
itemStatus.push("locked"); itemStatus.push("locked");
@@ -117,23 +137,25 @@ function getDocList(filter)
tags: asset.tags tags: asset.tags
}); });
} }
}
items.sort(sortByType);
return ( return (
{ {
"luceneQuery": filterQuery, luceneQuery: filterQuery,
"items": items paging:
{
startIndex: startIndex,
totalRecords: totalRecords
},
items: items
}); });
} }
function sortByType(a, b) 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")> <#assign workingCopyLabel = " " + message("coci_service.working_copy_label")>
<#escape x as jsonUtils.encodeJSONString(x)> <#escape x as jsonUtils.encodeJSONString(x)>
{ {
"doclist": "totalRecords": ${doclist.paging.totalRecords?c},
{ "startIndex": ${doclist.paging.startIndex?c},
"totalItems": ${doclist.items?size?string},
"items": "items":
[ [
<#list doclist.items as item> <#list doclist.items as item>
@@ -56,6 +55,5 @@
}<#if item_has_next>,</#if> }<#if item_has_next>,</#if>
</#list> </#list>
] ]
}
} }
</#escape> </#escape>

View File

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