mirror of
https://github.com/Alfresco/alfresco-community-repo.git
synced 2025-08-07 17:49:17 +00:00
Merged DEV/SHARE-LINKS to HEAD
11867: Fix issues raised by Mike's code review 11906: Finish Links Dashlet 12080: Fix bugs raised by 3d code review 12142: Missed Dashlet Code 12405: Final run-through of Links component before merge to HEAD 12406: Further minor edits to Links git-svn-id: https://svn.alfresco.com/repos/alfresco-enterprise/alfresco/HEAD/root@12416 c4b6b30b-aa2e-2d43-bbcb-ca4b014f7261
This commit is contained in:
@@ -1,3 +1,5 @@
|
|||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"message":"deleted"
|
"message":"${message}"
|
||||||
}
|
}
|
||||||
|
</#escape>
|
@@ -38,11 +38,16 @@ function getRequestNodes()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i in items)
|
for (var i in items)
|
||||||
|
{
|
||||||
|
if (i)
|
||||||
{
|
{
|
||||||
var tmpNode = node.childByNamePath(items[i]);
|
var tmpNode = node.childByNamePath(items[i]);
|
||||||
if (tmpNode)
|
if (tmpNode)
|
||||||
|
{
|
||||||
nodes.push(tmpNode);
|
nodes.push(tmpNode);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return nodes;
|
return nodes;
|
||||||
}
|
}
|
||||||
@@ -58,17 +63,20 @@ function deleteLink(linkNode)
|
|||||||
var isDeleted = linkNode.remove();
|
var isDeleted = linkNode.remove();
|
||||||
if (! isDeleted)
|
if (! isDeleted)
|
||||||
{
|
{
|
||||||
status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, "Unable to delete node: " + nodeRef);
|
var mes = "Unable to delete node: " + nodeRef;
|
||||||
|
status.setCode(status.STATUS_INTERNAL_SERVER_ERROR, mes);
|
||||||
|
model.message = mes;
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
//model.message = "Node " + nodeRef + " deleted";
|
model.message = "Node " + nodeRef + " deleted";
|
||||||
|
|
||||||
var siteId = url.templateArgs.site;
|
var siteId = url.templateArgs.site;
|
||||||
var containerId = url.templateArgs.container;
|
var containerId = url.templateArgs.container;
|
||||||
var data = {
|
var data =
|
||||||
title:linkData["title"],
|
{
|
||||||
|
title:linkData.title,
|
||||||
page: "links"
|
page: "links"
|
||||||
}
|
};
|
||||||
|
|
||||||
activities.postActivity("org.alfresco.links.link-deleted", siteId, containerId, jsonUtils.toJSONString(data));
|
activities.postActivity("org.alfresco.links.link-deleted", siteId, containerId, jsonUtils.toJSONString(data));
|
||||||
}
|
}
|
||||||
@@ -83,7 +91,21 @@ function main()
|
|||||||
}
|
}
|
||||||
|
|
||||||
for (var i in nodes)
|
for (var i in nodes)
|
||||||
|
{
|
||||||
|
if (i)
|
||||||
|
{
|
||||||
|
if (!nodes[i].hasPermission("Delete"))
|
||||||
|
{
|
||||||
|
status.code = 403;
|
||||||
|
var mes = "Permission to delete is denied";
|
||||||
|
status.message = mes;
|
||||||
|
model.message = mes;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
deleteLink(nodes[i]);
|
deleteLink(nodes[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -3,29 +3,29 @@
|
|||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
|
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/generic-paged-results.lib.js">
|
||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/links/links.lib.js">
|
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/links/links.lib.js">
|
||||||
|
|
||||||
|
const DEFAULT_NUM_DAYS = 7;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Fetches all links added to the site
|
* Fetches all links added to the site
|
||||||
*/
|
*/
|
||||||
function getLinksList(node,filter,tag,numdays, index, count)
|
function getLinksList(node, filter, tag, numdays, index, count)
|
||||||
{
|
{
|
||||||
//var fromDate = getTodayMinusXDays(numdays);
|
|
||||||
|
|
||||||
// query information
|
// query information
|
||||||
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/linksmodel/1.0}link\"" +
|
var luceneQuery = " +TYPE:\"{http://www.alfresco.org/model/linksmodel/1.0}link\" +PATH:\"" + node.qnamePath + "/*\"";
|
||||||
" +PATH:\"" + node.qnamePath + "/*\"";
|
|
||||||
|
|
||||||
if (filter == "internal")
|
if (filter == "recent")
|
||||||
{
|
{
|
||||||
//luceneQuery += " +@cm\\:internal:\"true\"";
|
var fromDate = getTodayMinusXDays(DEFAULT_NUM_DAYS);
|
||||||
luceneQuery += "+ASPECT:\"{http://www.alfresco.org/model/linksmodel/1.0}internal\" ";
|
var toDate = new Date();
|
||||||
|
|
||||||
|
luceneQuery += getCreationDateRangeQuery(fromDate, toDate);
|
||||||
}
|
}
|
||||||
else if (filter == "www")
|
else if (filter == "user")
|
||||||
{
|
{
|
||||||
luceneQuery += "-ASPECT:\"{http://www.alfresco.org/model/linksmodel/1.0}internal\" ";
|
luceneQuery += " +@cm\\:creator:" + person.properties.userName;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (tag != null)
|
if (tag !== null)
|
||||||
{
|
{
|
||||||
luceneQuery += " +PATH:\"/cm:taggable/cm:" + search.ISO9075Encode(tag) + "/member\" ";
|
luceneQuery += " +PATH:\"/cm:taggable/cm:" + search.ISO9075Encode(tag) + "/member\" ";
|
||||||
}
|
}
|
||||||
@@ -45,19 +45,18 @@ function main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pNumber = parseInt(args.page);
|
var pNumber = parseInt(args.page, 10);
|
||||||
var pSize = parseInt(args.pageSize);
|
var pSize = parseInt(args.pageSize, 10);
|
||||||
var filter = args.filter;
|
var filter = args.filter;
|
||||||
var tag = (args["tag"] != undefined && args["tag"].length > 0) ? args["tag"] : null;
|
var tag = (args.tag != undefined && args.tag.length > 0) ? args.tag : null;
|
||||||
|
|
||||||
if ((pNumber == undefined) || (pSize == undefined))
|
if ((pNumber === undefined) || (pSize === undefined))
|
||||||
{
|
{
|
||||||
model.error = "Parameters missing!";
|
model.error = "Parameters missing!";
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
model.links = node;
|
||||||
model.data = getLinksList(node,filter,tag,7,(pNumber - 1) * pSize,pSize);
|
model.data = getLinksList(node,filter,tag,7,(pNumber - 1) * pSize,pSize);
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
@@ -1,49 +1,58 @@
|
|||||||
<#import "../generic-paged-results.lib.ftl" as gen/>
|
<#import "../generic-paged-results.lib.ftl" as gen>
|
||||||
|
|
||||||
<#macro renderPerson person fieldName>
|
<#macro renderPerson person fieldName>
|
||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
"${fieldName}":
|
||||||
"${fieldName}" : {
|
{
|
||||||
<#if person.assocs["cm:avatar"]??>
|
<#if person.assocs["cm:avatar"]??>
|
||||||
"avatarRef" : "${person.assocs["cm:avatar"][0].nodeRef?string}",
|
"avatarRef": "${person.assocs["cm:avatar"][0].nodeRef?string}",
|
||||||
</#if>
|
</#if>
|
||||||
"username" : "${person.properties["cm:userName"]}",
|
"username": "${person.properties["cm:userName"]}",
|
||||||
"firstName" : "${person.properties["cm:firstName"]}",
|
"firstName": "${person.properties["cm:firstName"]}",
|
||||||
"lastName" : "${person.properties["cm:lastName"]}"
|
"lastName": "${person.properties["cm:lastName"]}"
|
||||||
},
|
},
|
||||||
</#escape>
|
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#--
|
<#--
|
||||||
This template renders a link.
|
This template renders a link.
|
||||||
-->
|
-->
|
||||||
|
|
||||||
<#macro linkJSON item>
|
<#macro linkJSON item>
|
||||||
<#escape x as jsonUtils.encodeJSONString(x)>
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"url" : "${item.url!''}",
|
"url": "${item.url!''}",
|
||||||
"commentsUrl" : "/node/${item.node.nodeRef?replace('://','/')}/comments",
|
"commentsUrl": "/node/${item.node.nodeRef?replace('://','/')}/comments",
|
||||||
"description" : "${item.description!''}",
|
"description": "${item.description!''}",
|
||||||
"nodeRef" : "${item.node.nodeRef}",
|
"nodeRef": "${item.node.nodeRef}",
|
||||||
"name" : "${item.name!''}",
|
"name": "${item.name!''}",
|
||||||
"title" : "${item.title!''}",
|
"title": "${item.title!''}",
|
||||||
"internal" : "${item.internal!'false'}",
|
"internal": ${(item.internal!false)?string},
|
||||||
"isUpdated" : "${item.isUpdated!'false'}",
|
"createdOn": "${item.createdOn?string("MMM dd yyyy HH:mm:ss 'GMT'Z '('zzz')'")}",
|
||||||
<#if item.author??>
|
<#if item.creator??>
|
||||||
<@renderPerson person=item.author fieldName="author" />
|
<@renderPerson person=item.creator fieldName="author" />
|
||||||
<#else>
|
<#else>
|
||||||
"author" : { "username" : "${item.node.properties.creator}" },
|
"author":
|
||||||
</#if>
|
{
|
||||||
"permissions" : {
|
"username": "${item.node.properties.creator}"
|
||||||
"edit" : ${item.node.hasPermission("Write")?string},
|
|
||||||
"delete" : ${item.node.hasPermission("Delete")?string}
|
|
||||||
},
|
},
|
||||||
"tags" : [<#list item.tags as x>"${x}"<#if x_has_next>, </#if></#list>]
|
</#if>
|
||||||
|
"permissions":
|
||||||
|
{
|
||||||
|
"edit": ${item.node.hasPermission("Write")?string},
|
||||||
|
"delete": ${item.node.hasPermission("Delete")?string}
|
||||||
|
},
|
||||||
|
"tags": [<#list item.tags as x>"${x}"<#if x_has_next>, </#if></#list>]
|
||||||
}
|
}
|
||||||
</#escape>
|
</#escape>
|
||||||
</#macro>
|
</#macro>
|
||||||
|
|
||||||
<#macro renderLinkList>
|
<#macro renderLinkList>
|
||||||
{
|
{
|
||||||
|
"metadata":
|
||||||
|
{
|
||||||
|
"linkPermissions":
|
||||||
|
{
|
||||||
|
"create": "${links.hasPermission("CreateChildren")?string}"
|
||||||
|
}
|
||||||
|
},
|
||||||
<@gen.pagedResults data=data ; item>
|
<@gen.pagedResults data=data ; item>
|
||||||
<@linkJSON item=item />
|
<@linkJSON item=item />
|
||||||
</@gen.pagedResults>
|
</@gen.pagedResults>
|
||||||
@@ -52,6 +61,6 @@
|
|||||||
|
|
||||||
<#macro renderLink>
|
<#macro renderLink>
|
||||||
{
|
{
|
||||||
"item" : <@linkJSON item=item />
|
"item": <@linkJSON item=item />
|
||||||
}
|
}
|
||||||
</#macro>
|
</#macro>
|
@@ -2,24 +2,21 @@
|
|||||||
const LINK_INTERNAL_ASPECT = "lnk:internal";
|
const LINK_INTERNAL_ASPECT = "lnk:internal";
|
||||||
const ASPECT_INTERNAL = "lnk:isInternal";
|
const ASPECT_INTERNAL = "lnk:isInternal";
|
||||||
|
|
||||||
|
|
||||||
function getLinksData(node)
|
function getLinksData(node)
|
||||||
{
|
{
|
||||||
var itm = {};
|
var itm = {};
|
||||||
itm.node = node;
|
itm.node = node;
|
||||||
itm.name = node.name||"";
|
itm.name = node.name || "";
|
||||||
itm.title = node.properties["lnk:linkTitle"]||"";
|
itm.title = node.properties["lnk:title"] || "";
|
||||||
itm.description = node.properties["lnk:description"]||"";
|
itm.description = node.properties["lnk:description"] || "";
|
||||||
itm.url = node.properties["lnk:url"]||"";
|
itm.url = node.properties["lnk:url"] || "";
|
||||||
|
itm.createdOn = node.properties.created || "";
|
||||||
|
itm.modifiedOn = node.properties.modified || "";
|
||||||
|
itm.creator = people.getPerson(node.properties["cm:creator"]);
|
||||||
|
|
||||||
// get the tags JSONArray and copy it into a real javascript array object
|
|
||||||
itm.tags = node.tags;
|
itm.tags = node.tags;
|
||||||
itm.internal = (node.hasAspect("lnk:internal")?"true":"false");
|
itm.internal = node.hasAspect("lnk:internal");
|
||||||
|
|
||||||
itm.author = people.getPerson(node.properties["cm:creator"]);
|
|
||||||
// (re-)enable permission
|
|
||||||
node.setInheritsPermissions(true);
|
|
||||||
/*itm.isUpdated = node.properties.isUpdated || "false";*/
|
|
||||||
return itm;
|
return itm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -34,7 +31,7 @@ function getLinkProperties()
|
|||||||
|
|
||||||
if (json.has("title"))
|
if (json.has("title"))
|
||||||
{
|
{
|
||||||
data["lnk:linkTitle"] = json.get("title");
|
data["lnk:title"] = json.get("title");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (json.has("url"))
|
if (json.has("url"))
|
||||||
@@ -52,5 +49,5 @@ function getLinkProperties()
|
|||||||
|
|
||||||
function isLinkInternal()
|
function isLinkInternal()
|
||||||
{
|
{
|
||||||
return (json.has("isinternal")?true:false);
|
return (json.has("internal") ? true : false);
|
||||||
}
|
}
|
||||||
|
@@ -1,3 +1,7 @@
|
|||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"name" : "${item.name}"
|
"message": "${message}"<#if item??>,
|
||||||
|
"name": "${item.name?string}"
|
||||||
|
</#if>
|
||||||
}
|
}
|
||||||
|
</#escape>
|
@@ -2,16 +2,15 @@
|
|||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/nodenameutils.lib.js">
|
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/nodenameutils.lib.js">
|
||||||
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/links/links.lib.js">
|
<import resource="classpath:alfresco/templates/webscripts/org/alfresco/repository/links/links.lib.js">
|
||||||
|
|
||||||
|
|
||||||
function ensureTagScope(node)
|
function ensureTagScope(node)
|
||||||
{
|
{
|
||||||
if (! node.isTagScope)
|
if (!node.isTagScope)
|
||||||
{
|
{
|
||||||
node.isTagScope = true;
|
node.isTagScope = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// also check the parent (the site!)
|
// also check the parent (the site!)
|
||||||
if (! node.parent.isTagScope)
|
if (!node.parent.isTagScope)
|
||||||
{
|
{
|
||||||
node.parent.isTagScope = true;
|
node.parent.isTagScope = true;
|
||||||
}
|
}
|
||||||
@@ -27,7 +26,7 @@ function createLink(linkNode)
|
|||||||
{
|
{
|
||||||
// get the tags JSONArray and copy it into a real javascript array object
|
// get the tags JSONArray and copy it into a real javascript array object
|
||||||
var tmp = json.get("tags");
|
var tmp = json.get("tags");
|
||||||
for (var x=0; x < tmp.length(); x++)
|
for (var x = 0; x < tmp.length(); x++)
|
||||||
{
|
{
|
||||||
tags.push(tmp.get(x));
|
tags.push(tmp.get(x));
|
||||||
}
|
}
|
||||||
@@ -35,10 +34,10 @@ function createLink(linkNode)
|
|||||||
|
|
||||||
// get a unique name
|
// get a unique name
|
||||||
var nodeName = getUniqueChildName(linkNode, "link");
|
var nodeName = getUniqueChildName(linkNode, "link");
|
||||||
|
linkNode = linkNode.createNode(nodeName, "lnk:link",getLinkProperties());
|
||||||
|
|
||||||
var linkNode = linkNode.createNode(nodeName, "lnk:link",getLinkProperties());
|
if (isLinkInternal())
|
||||||
|
{
|
||||||
if (isLinkInternal()) {
|
|
||||||
var pr = [];
|
var pr = [];
|
||||||
pr["lnk:isInternal"] = "true";
|
pr["lnk:isInternal"] = "true";
|
||||||
linkNode.addAspect("lnk:internal", pr);
|
linkNode.addAspect("lnk:internal", pr);
|
||||||
@@ -51,11 +50,14 @@ function createLink(linkNode)
|
|||||||
|
|
||||||
var siteId = url.templateArgs.site;
|
var siteId = url.templateArgs.site;
|
||||||
var containerId = url.templateArgs.container;
|
var containerId = url.templateArgs.container;
|
||||||
var data = {
|
var data =
|
||||||
|
{
|
||||||
title: json.get("title"),
|
title: json.get("title"),
|
||||||
page: json.get("page") + "?container=links&linkId=" + nodeName
|
page: json.get("page") + "?linkId=" + nodeName
|
||||||
}
|
};
|
||||||
|
|
||||||
|
var mes = linkNode.properties["name"];
|
||||||
|
model.message = mes;
|
||||||
activities.postActivity("org.alfresco.links.link-created", siteId, containerId, jsonUtils.toJSONString(data));
|
activities.postActivity("org.alfresco.links.link-created", siteId, containerId, jsonUtils.toJSONString(data));
|
||||||
|
|
||||||
return linkNode;
|
return linkNode;
|
||||||
@@ -70,6 +72,15 @@ function main()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!node.hasPermission("CreateChildren"))
|
||||||
|
{
|
||||||
|
status.code = 403;
|
||||||
|
var mes = "Permission to create is denied";
|
||||||
|
status.message = mes;
|
||||||
|
model.message = mes;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
ensureTagScope(node);
|
ensureTagScope(node);
|
||||||
|
|
||||||
var link = createLink(node);
|
var link = createLink(node);
|
||||||
|
@@ -1,3 +1,5 @@
|
|||||||
|
<#escape x as jsonUtils.encodeJSONString(x)>
|
||||||
{
|
{
|
||||||
"message":"update"
|
"message": "${message}"
|
||||||
}
|
}
|
||||||
|
</#escape>
|
@@ -23,29 +23,33 @@ function updateLink(linkNode)
|
|||||||
var pr = [];
|
var pr = [];
|
||||||
pr["lnk:isInternal"] = "true";
|
pr["lnk:isInternal"] = "true";
|
||||||
linkNode.addAspect("lnk:internal", pr);
|
linkNode.addAspect("lnk:internal", pr);
|
||||||
|
}
|
||||||
} else if (linkNode.hasAspect("lnk:internal") && !isInternal)
|
else if (linkNode.hasAspect("lnk:internal") && !isInternal)
|
||||||
{
|
{
|
||||||
linkNode.removeAspect("lnk:internal");
|
linkNode.removeAspect("lnk:internal");
|
||||||
}
|
}
|
||||||
|
|
||||||
var prs = getLinkProperties();
|
var prs = getLinkProperties();
|
||||||
for (var propName in prs)
|
for (var propName in prs)
|
||||||
|
{
|
||||||
|
if (propName)
|
||||||
{
|
{
|
||||||
linkNode.properties[propName] = prs[propName];
|
linkNode.properties[propName] = prs[propName];
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
linkNode.mimetype = "text/html";
|
linkNode.mimetype = "text/html";
|
||||||
linkNode.content = linkNode.properties["lnk:url"];
|
linkNode.content = linkNode.properties["lnk:url"];
|
||||||
linkNode.tags = tags;
|
linkNode.tags = tags;
|
||||||
linkNode.save();
|
linkNode.save();
|
||||||
|
model.message = "Node " + linkNode.nodeRef + " updated";
|
||||||
var siteId = url.templateArgs.site;
|
var siteId = url.templateArgs.site;
|
||||||
var containerId = url.templateArgs.container;
|
var containerId = url.templateArgs.container;
|
||||||
var data = {
|
var data =
|
||||||
|
{
|
||||||
title: json.get("title"),
|
title: json.get("title"),
|
||||||
page: json.get("page") + "?container=links&linkId=" + linkNode.name
|
page: json.get("page") + "?linkId=" + linkNode.name
|
||||||
}
|
};
|
||||||
|
|
||||||
activities.postActivity("org.alfresco.links.link-updated", siteId, containerId, jsonUtils.toJSONString(data));
|
activities.postActivity("org.alfresco.links.link-updated", siteId, containerId, jsonUtils.toJSONString(data));
|
||||||
|
|
||||||
@@ -56,9 +60,15 @@ function main()
|
|||||||
{
|
{
|
||||||
// get requested node
|
// get requested node
|
||||||
var node = getRequestNode();
|
var node = getRequestNode();
|
||||||
|
if (!node.hasPermission("WriteProperties") || !node.hasPermission("WriteContent"))
|
||||||
var link = updateLink(node);
|
{
|
||||||
|
status.code = 403;
|
||||||
|
var mes = "Permission to update is denied";
|
||||||
|
status.message = mes;
|
||||||
|
model.message = mes;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
updateLink(node);
|
||||||
}
|
}
|
||||||
|
|
||||||
main();
|
main();
|
Reference in New Issue
Block a user