mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
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:
@@ -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,26 +26,27 @@ 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?
|
||||
var showDocs = true;
|
||||
var showFolders = true;
|
||||
@@ -55,6 +56,27 @@ function getDocList(filter)
|
||||
showDocs = ((type == "all") || (type == "documents"));
|
||||
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,74 +88,74 @@ function getDocList(filter)
|
||||
createdBy = null;
|
||||
modifiedBy = null;
|
||||
|
||||
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
|
||||
if (asset.isLocked)
|
||||
{
|
||||
if (asset.isLocked)
|
||||
{
|
||||
itemStatus.push("locked");
|
||||
itemOwner = people.getPerson(asset.properties["cm:lockOwner"]);
|
||||
}
|
||||
if (asset.hasAspect("cm:workingcopy"))
|
||||
{
|
||||
itemStatus.push("workingCopy");
|
||||
itemOwner = people.getPerson(asset.properties["cm:workingCopyOwner"]);
|
||||
}
|
||||
// Is this user the item owner?
|
||||
if (itemOwner && (itemOwner.properties.userName == person.properties.userName))
|
||||
{
|
||||
itemStatus.push("lockedBySelf");
|
||||
}
|
||||
|
||||
// Make sure we have a thumbnail
|
||||
if (haveThumbnails)
|
||||
{
|
||||
thumbnail = asset.getThumbnail(THUMBNAIL_NAME);
|
||||
if (thumbnail === null)
|
||||
{
|
||||
// No thumbnail, so queue creation
|
||||
asset.createThumbnail(THUMBNAIL_NAME, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Get users
|
||||
createdBy = people.getPerson(asset.properties["cm:creator"]);
|
||||
modifiedBy = people.getPerson(asset.properties["cm:modifier"]);
|
||||
|
||||
// Get relevant actions set
|
||||
actionSet = getActionSet(asset,
|
||||
{
|
||||
itemStatus: itemStatus,
|
||||
itemOwner: itemOwner
|
||||
});
|
||||
|
||||
items.push(
|
||||
{
|
||||
asset: asset,
|
||||
status: itemStatus,
|
||||
owner: itemOwner,
|
||||
createdBy: createdBy,
|
||||
modifiedBy: modifiedBy,
|
||||
actionSet: actionSet,
|
||||
tags: asset.tags
|
||||
});
|
||||
itemStatus.push("locked");
|
||||
itemOwner = people.getPerson(asset.properties["cm:lockOwner"]);
|
||||
}
|
||||
if (asset.hasAspect("cm:workingcopy"))
|
||||
{
|
||||
itemStatus.push("workingCopy");
|
||||
itemOwner = people.getPerson(asset.properties["cm:workingCopyOwner"]);
|
||||
}
|
||||
// Is this user the item owner?
|
||||
if (itemOwner && (itemOwner.properties.userName == person.properties.userName))
|
||||
{
|
||||
itemStatus.push("lockedBySelf");
|
||||
}
|
||||
|
||||
// Make sure we have a thumbnail
|
||||
if (haveThumbnails)
|
||||
{
|
||||
thumbnail = asset.getThumbnail(THUMBNAIL_NAME);
|
||||
if (thumbnail === null)
|
||||
{
|
||||
// No thumbnail, so queue creation
|
||||
asset.createThumbnail(THUMBNAIL_NAME, true);
|
||||
}
|
||||
}
|
||||
|
||||
// Get users
|
||||
createdBy = people.getPerson(asset.properties["cm:creator"]);
|
||||
modifiedBy = people.getPerson(asset.properties["cm:modifier"]);
|
||||
|
||||
// Get relevant actions set
|
||||
actionSet = getActionSet(asset,
|
||||
{
|
||||
itemStatus: itemStatus,
|
||||
itemOwner: itemOwner
|
||||
});
|
||||
|
||||
items.push(
|
||||
{
|
||||
asset: asset,
|
||||
status: itemStatus,
|
||||
owner: itemOwner,
|
||||
createdBy: createdBy,
|
||||
modifiedBy: modifiedBy,
|
||||
actionSet: actionSet,
|
||||
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);
|
||||
}
|
@@ -1,61 +1,59 @@
|
||||
<#assign workingCopyLabel = " " + message("coci_service.working_copy_label")>
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"doclist":
|
||||
{
|
||||
"totalItems": ${doclist.items?size?string},
|
||||
"items":
|
||||
[
|
||||
<#list doclist.items as item>
|
||||
<#assign d = item.asset>
|
||||
<#assign version = "1.0">
|
||||
<#if d.hasAspect("cm:versionable")><#assign version = d.versionHistory?sort_by("versionLabel")?reverse[0].versionLabel></#if>
|
||||
<#if item.owner?exists>
|
||||
<#assign lockedBy = (item.owner.properties.firstName + " " + item.owner.properties.lastName)?trim>
|
||||
<#assign lockedByUser = item.owner.properties.userName>
|
||||
<#else>
|
||||
<#assign lockedBy="" lockedByUser="">
|
||||
</#if>
|
||||
<#if item.createdBy?exists>
|
||||
<#assign createdBy = (item.createdBy.properties.firstName + " " + item.createdBy.properties.lastName)?trim>
|
||||
<#assign createdByUser = item.createdBy.properties.userName>
|
||||
<#else>
|
||||
<#assign createdBy="" createdByUser="">
|
||||
</#if>
|
||||
<#if item.modifiedBy?exists>
|
||||
<#assign modifiedBy = (item.modifiedBy.properties.firstName + " " + item.modifiedBy.properties.lastName)?trim>
|
||||
<#assign modifiedByUser = item.modifiedBy.properties.userName>
|
||||
<#else>
|
||||
<#assign modifiedBy="" modifiedByUser="">
|
||||
</#if>
|
||||
<#assign tags><#list item.tags as tag>"${tag}"<#if tag_has_next>,</#if></#list></#assign>
|
||||
{
|
||||
"index": ${item_index},
|
||||
"nodeRef": "${d.nodeRef}",
|
||||
"type": "<#if d.isContainer>folder<#else>document</#if>",
|
||||
"mimetype": "${d.mimetype!""}",
|
||||
"icon32": "${d.icon32}",
|
||||
"fileName": "${d.name}",
|
||||
"displayName": "${d.name?replace(workingCopyLabel, "")}",
|
||||
"status": "<#list item.status as s>${s}<#if s_has_next>,</#if></#list>",
|
||||
"lockedBy": "${lockedBy}",
|
||||
"lockedByUser": "${lockedByUser}",
|
||||
"title": "${(d.properties.title!"")}",
|
||||
"description": "${(d.properties.description!"")}",
|
||||
"createdOn": "${d.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||
"createdBy": "${createdBy}",
|
||||
"createdByUser": "${createdByUser}",
|
||||
"modifiedOn": "${d.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||
"modifiedBy": "${modifiedBy}",
|
||||
"modifiedByUser": "${modifiedByUser}",
|
||||
"size": "${d.size}",
|
||||
"version": "${version}",
|
||||
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}",
|
||||
"actionSet": "${item.actionSet}",
|
||||
"tags": <#noescape>[${tags}]</#noescape>
|
||||
}<#if item_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
"totalRecords": ${doclist.paging.totalRecords?c},
|
||||
"startIndex": ${doclist.paging.startIndex?c},
|
||||
"items":
|
||||
[
|
||||
<#list doclist.items as item>
|
||||
<#assign d = item.asset>
|
||||
<#assign version = "1.0">
|
||||
<#if d.hasAspect("cm:versionable")><#assign version = d.versionHistory?sort_by("versionLabel")?reverse[0].versionLabel></#if>
|
||||
<#if item.owner?exists>
|
||||
<#assign lockedBy = (item.owner.properties.firstName + " " + item.owner.properties.lastName)?trim>
|
||||
<#assign lockedByUser = item.owner.properties.userName>
|
||||
<#else>
|
||||
<#assign lockedBy="" lockedByUser="">
|
||||
</#if>
|
||||
<#if item.createdBy?exists>
|
||||
<#assign createdBy = (item.createdBy.properties.firstName + " " + item.createdBy.properties.lastName)?trim>
|
||||
<#assign createdByUser = item.createdBy.properties.userName>
|
||||
<#else>
|
||||
<#assign createdBy="" createdByUser="">
|
||||
</#if>
|
||||
<#if item.modifiedBy?exists>
|
||||
<#assign modifiedBy = (item.modifiedBy.properties.firstName + " " + item.modifiedBy.properties.lastName)?trim>
|
||||
<#assign modifiedByUser = item.modifiedBy.properties.userName>
|
||||
<#else>
|
||||
<#assign modifiedBy="" modifiedByUser="">
|
||||
</#if>
|
||||
<#assign tags><#list item.tags as tag>"${tag}"<#if tag_has_next>,</#if></#list></#assign>
|
||||
{
|
||||
"index": ${item_index},
|
||||
"nodeRef": "${d.nodeRef}",
|
||||
"type": "<#if d.isContainer>folder<#else>document</#if>",
|
||||
"mimetype": "${d.mimetype!""}",
|
||||
"icon32": "${d.icon32}",
|
||||
"fileName": "${d.name}",
|
||||
"displayName": "${d.name?replace(workingCopyLabel, "")}",
|
||||
"status": "<#list item.status as s>${s}<#if s_has_next>,</#if></#list>",
|
||||
"lockedBy": "${lockedBy}",
|
||||
"lockedByUser": "${lockedByUser}",
|
||||
"title": "${(d.properties.title!"")}",
|
||||
"description": "${(d.properties.description!"")}",
|
||||
"createdOn": "${d.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||
"createdBy": "${createdBy}",
|
||||
"createdByUser": "${createdByUser}",
|
||||
"modifiedOn": "${d.properties.modified?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||
"modifiedBy": "${modifiedBy}",
|
||||
"modifiedByUser": "${modifiedByUser}",
|
||||
"size": "${d.size}",
|
||||
"version": "${version}",
|
||||
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}",
|
||||
"actionSet": "${item.actionSet}",
|
||||
"tags": <#noescape>[${tags}]</#noescape>
|
||||
}<#if item_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
</#escape>
|
||||
|
@@ -1,23 +1,20 @@
|
||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||
{
|
||||
"treenode":
|
||||
{
|
||||
"totalItems": ${treenode.items?size},
|
||||
"items":
|
||||
[
|
||||
"totalResults": ${treenode.items?size?c},
|
||||
"items":
|
||||
[
|
||||
<#list treenode.items as t>
|
||||
<#assign hasChildren = false>
|
||||
<#list t.children as c>
|
||||
<#if c.isContainer><#assign hasChildren = true><#break></#if>
|
||||
</#list>
|
||||
{
|
||||
"nodeRef": "${t.nodeRef}",
|
||||
"name": "${t.name}",
|
||||
"description": "${(t.properties.description!"{}")}",
|
||||
"hasChildren": ${hasChildren?string}
|
||||
}<#if t_has_next>,</#if>
|
||||
{
|
||||
"nodeRef": "${t.nodeRef}",
|
||||
"name": "${t.name}",
|
||||
"description": "${(t.properties.description!"{}")}",
|
||||
"hasChildren": ${hasChildren?string}
|
||||
}<#if t_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
</#escape>
|
||||
|
Reference in New Issue
Block a user