diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.json.js b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.json.js index 73b4968bed..951bca843b 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.json.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickeritems.post.json.js @@ -16,7 +16,7 @@ function main() // convert the JSONArray object into a native JavaScript array var jsonItems = json.get("items"), numItems = jsonItems.length(), - item, result, resultObj; + item, result; for (count = 0; count < numItems; count++) { @@ -35,6 +35,10 @@ function main() { result = createGroupResult(result); } + else + { + result = createNodeResult(result); + } results.push( { diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl index aee8e91738..8716bac579 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.ftl @@ -11,8 +11,9 @@ ${indent}"name": "${node.properties.name!""}", ${indent}"title": "${node.properties.title!""}", ${indent}"description": "${node.properties.description!""}", - <#if node.properties.modified??>${indent}"modified": "${node.properties.modified?string("dd MMMM yyyy HH:mm")}", + <#if node.properties.modified??>${indent}"modified": "${xmldate(node.properties.modified)}", <#if node.properties.modifier??>${indent}"modifier": "${node.properties.modifier}", + <#if node.site??>${indent}"site": "${node.site}", ${indent}"displayPath": "${node.displayPath!""}", ${indent}"nodeRef": "${node.nodeRef}" ${indent}}, @@ -37,8 +38,9 @@ "name": "${row.item.properties.name!""}", "title": "${row.item.properties.title!""}", "description": "${row.item.properties.description!""}", - <#if row.item.properties.modified??>"modified": "${row.item.properties.modified?string("dd MMMM yyyy HH:mm")}", + <#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}", <#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}", + <#if row.item.site??>"site": "${row.item.site}", "displayPath": "${row.item.displayPath!""}", "nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>, "selectable" : ${row.selectable?string} diff --git a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js index dd2e19d1ec..1e520963d7 100644 --- a/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js +++ b/config/alfresco/templates/webscripts/org/alfresco/repository/forms/pickerresults.lib.js @@ -1,3 +1,61 @@ +/** + * Creates an Object representing the given node. + * + * Also determines whether the node is located within a site, if it + * is a "site" property is provided where the value is the site short + * name. + * + * @method createNodeResult + * @param node + * @return Object representing the node + */ +function createNodeResult(node) +{ + var nodeObject = + { + typeShort: node.typeShort, + isContainer: node.isContainer, + children: node.children, + properties: {}, + displayPath: node.displayPath, + nodeRef: "" + node.nodeRef, + } + + // add required properties + nodeObject.properties.name = node.properties.name; + nodeObject.properties.title = node.properties.title; + nodeObject.properties.description = node.properties.description; + nodeObject.properties.modified = node.properties.modified; + nodeObject.properties.modifier = node.properties.modifier; + + // determine if the node is in a site and if so, which one + if (node.qnamePath != null) + { + var paths = node.qnamePath.split("/"); + for (var i = 0, ii = paths.length; i < ii; i++) + { + if (paths[i] == "st:sites") + { + // we now know the node is in a site, find + // the next element in the array (if there + // is one) to get the site name + + if ((i+1) < paths.length) + { + var siteName = paths[i+1]; + + // remove the "cm:" prefix and add to result object + nodeObject.site = siteName.substring(3); + } + + break; + } + } + } + + return nodeObject; +} + /** * Creates an Object representing the given person node. *