mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-07-31 17:39:05 +00:00
Remaining DocLib filters. Fix to active filter highlight. New "available actions" logic based on document state.
git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@9599 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
function getActionSet(asset, obj)
|
||||
{
|
||||
var actionSet = "empty";
|
||||
var itemStatus = obj.itemStatus.toString();
|
||||
var isItemOwner = (obj.itemOwner == person.properties.userName);
|
||||
|
||||
// Only 1 action set for folders
|
||||
if (asset.isContainer)
|
||||
{
|
||||
actionSet = "folder";
|
||||
}
|
||||
else if (itemStatus.indexOf("workingCopy") != -1)
|
||||
{
|
||||
actionSet = isItemOwner ? "workingCopyOwner" : "locked";
|
||||
}
|
||||
else if (itemStatus.indexOf("locked") != -1)
|
||||
{
|
||||
actionSet = isItemOwner ? "lockOwner" : "locked";
|
||||
}
|
||||
else
|
||||
{
|
||||
actionSet = "document";
|
||||
}
|
||||
|
||||
return actionSet;
|
||||
}
|
@@ -1,4 +1,5 @@
|
||||
<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">
|
||||
|
||||
/**
|
||||
* Document List Component: doclist
|
||||
@@ -55,7 +56,7 @@ function getDoclist(siteId, path, type, filter)
|
||||
// Default to all children of pathNode
|
||||
var assets = pathNode.children;
|
||||
|
||||
// Try to find a filter query based on the passed-in argument
|
||||
// Try to find a filter query based on the passed-in arguments
|
||||
var filterParams =
|
||||
{
|
||||
siteNode: siteNode,
|
||||
@@ -75,11 +76,53 @@ function getDoclist(siteId, path, type, filter)
|
||||
showFolders = (type == "folders");
|
||||
}
|
||||
|
||||
// Locked/working copy status
|
||||
/*
|
||||
<#if d.isLocked><#assign status = status + ["locked"]><#assign lockedBy = d.properties["cm:lockOwner"]></#if>
|
||||
<#if d.hasAspect("cm:workingcopy")><#assign status = status + ["workingcopy"]><#assign lockedBy = d.properties["cm:workingCopyOwner"]></#if>
|
||||
*/
|
||||
|
||||
var itemStatus;
|
||||
var itemOwner;
|
||||
var actionSet;
|
||||
|
||||
for each(asset in assets)
|
||||
{
|
||||
itemStatus = [];
|
||||
itemOwner = "";
|
||||
|
||||
if ((asset.isContainer && showFolders) || (asset.isDocument && showDocs))
|
||||
{
|
||||
items.push(asset);
|
||||
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
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
@@ -101,9 +144,9 @@ function getDoclist(siteId, path, type, filter)
|
||||
|
||||
function sortByType(a, b)
|
||||
{
|
||||
if (a.isContainer == b.isContainer)
|
||||
if (a.asset.isContainer == b.asset.isContainer)
|
||||
{
|
||||
return (b.name.toLowerCase() > a.name.toLowerCase() ? -1 : 1);
|
||||
return (b.asset.name.toLowerCase() > a.asset.name.toLowerCase() ? -1 : 1);
|
||||
}
|
||||
return (a.isContainer ? -1 : 1);
|
||||
return (a.asset.isContainer ? -1 : 1);
|
||||
}
|
@@ -4,22 +4,19 @@
|
||||
"totalItems": ${doclist.items?size},
|
||||
"items":
|
||||
[
|
||||
<#list doclist.items as d>
|
||||
<#assign status = []>
|
||||
<#assign lockedBy = "">
|
||||
<#list doclist.items as item>
|
||||
<#assign d = item.asset>
|
||||
<#assign version = "1.0">
|
||||
<#if d.isLocked><#assign status = status + ["locked"]><#assign lockedBy = d.properties["cm:lockOwner"]></#if>
|
||||
<#if d.hasAspect("cm:workingcopy")><#assign status = status + ["workingcopy"]></#if>
|
||||
<#if d.hasAspect("cm:versionable")><#assign version = d.versionHistory?sort_by("versionLabel")?reverse[0].versionLabel></#if>
|
||||
{
|
||||
"index": ${d_index},
|
||||
"index": ${item_index},
|
||||
"nodeRef": "${d.nodeRef}",
|
||||
"type": "<#if d.isContainer>folder<#else>document</#if>",
|
||||
"mimetype": "${d.mimetype!""}",
|
||||
"icon32": "${d.icon32}",
|
||||
"name": "${d.name?replace(" (Working Copy)", "")?html}",
|
||||
"status": "<#list status as s>${s}<#if s_has_next>,</#if></#list>",
|
||||
"lockedBy": "${lockedBy}",
|
||||
"status": "<#list item.status as s>${s}<#if s_has_next>,</#if></#list>",
|
||||
"lockedBy": "${item.owner}",
|
||||
"title": "${(d.properties.title!"")?html}",
|
||||
"description": "${(d.properties.description!"")?html}",
|
||||
"createdOn": "${d.properties.created?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||
@@ -28,8 +25,9 @@
|
||||
"modifiedBy": "${d.properties.modifier}",
|
||||
"size": "${d.size}",
|
||||
"version": "${version}",
|
||||
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}"
|
||||
}<#if d_has_next>,</#if>
|
||||
"contentUrl": "api/node/content/${d.storeType}/${d.storeId}/${d.id}/${d.name?url}",
|
||||
"actionSet": "${item.actionSet}"
|
||||
}<#if item_has_next>,</#if>
|
||||
</#list>
|
||||
]
|
||||
}
|
||||
|
@@ -4,18 +4,44 @@ function getFilterQuery(filter, obj)
|
||||
|
||||
switch (String(filter))
|
||||
{
|
||||
case "TODO: recentlyModified":
|
||||
case "recentlyModified":
|
||||
var usingModified = true;
|
||||
// fall through...
|
||||
case "recentlyAdded":
|
||||
// Which query: created, or modified?
|
||||
var dateField = "modified";
|
||||
if (typeof usingModified === "undefined")
|
||||
{
|
||||
dateField = "created";
|
||||
}
|
||||
|
||||
// Default to 7 days - can be overridden using "days" argument
|
||||
var dayCount = 7;
|
||||
var argDays = args["days"];
|
||||
if ((argDays != null) && !isNaN(argDays))
|
||||
{
|
||||
dayCount = argDays;
|
||||
}
|
||||
var date = new Date();
|
||||
var toQuery = date.getFullYear() + "\\-" + (date.getMonth() + 1) + "\\-" + date.getDate();
|
||||
date.setDate(date.getDate() - dayCount);
|
||||
var fromQuery = date.getFullYear() + "\\-" + (date.getMonth() + 1) + "\\-" + date.getDate();
|
||||
|
||||
filterQuery = "+PATH:\"" + obj.containerNode.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 "TODO: recentlyAdded":
|
||||
break;
|
||||
|
||||
case "editingMe":
|
||||
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" ";
|
||||
filterQuery += " +@cm\\:workingCopyOwner:" + person.properties.userName;
|
||||
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
|
||||
filterQuery += "+@cm\\:workingCopyOwner:" + person.properties.userName;
|
||||
break;
|
||||
|
||||
case "TODO: editingOthers":
|
||||
case "editingOthers":
|
||||
filterQuery = "+PATH:\"" + obj.containerNode.qnamePath + "//*\" ";
|
||||
filterQuery += "+ASPECT:\"{http://www.alfresco.org/model/content/1.0}workingcopy\" ";
|
||||
filterQuery += "-@cm\\:workingCopyOwner:" + person.properties.userName;
|
||||
break;
|
||||
|
||||
default:
|
||||
|
Reference in New Issue
Block a user