Skip to content

Commit 393b064

Browse files
MNT-24776 adding if-else conditionals to avoid null values
(cherry picked from commit be02be5)
1 parent f741f2c commit 393b064

File tree

1 file changed

+91
-82
lines changed
  • remote-api/src/main/resources/alfresco/templates/webscripts/org/alfresco/repository/forms

1 file changed

+91
-82
lines changed
Lines changed: 91 additions & 82 deletions
Original file line numberDiff line numberDiff line change
@@ -1,83 +1,92 @@
1-
<#macro renderParent node indent=" ">
2-
<#escape x as jsonUtils.encodeJSONString(x)>
3-
${indent}"parent":
4-
${indent}{
5-
<#if (node != rootNode) && node.parent??>
6-
<@renderParent node.parent indent+" " />
7-
</#if>
8-
${indent}"type": "${node.typeShort}",
9-
${indent}"isContainer": ${node.isContainer?string},
10-
${indent}"name": "${node.properties.name!""}",
11-
${indent}"title": "${node.properties.title!""}",
12-
${indent}"description": "${node.properties.description!""}",
13-
<#if node.properties.modified??>${indent}"modified": "${xmldate(node.properties.modified)}",</#if>
14-
<#if node.properties.modifier??>${indent}"modifier": "${node.properties.modifier}",</#if>
15-
${indent}"displayPath": "${node.displayPath!""}",
16-
${indent}"qnamePath": "${node.qnamePath!""}",
17-
<#if node.aspects??>
18-
${indent}"aspects":
19-
${indent}[
20-
<#list node.aspects as aspect>
21-
"${shortQName(aspect)}"
22-
<#if aspect_has_next>,</#if>
23-
</#list>
24-
25-
${indent}],
26-
</#if>
27-
${indent}"nodeRef": "${node.nodeRef}"
28-
${indent}},
29-
</#escape>
30-
</#macro>
31-
32-
<#macro pickerResultsJSON results>
33-
<#escape x as jsonUtils.encodeJSONString(x)>
34-
{
35-
"data":
36-
{
37-
<#if parent??>
38-
<@renderParent parent />
39-
</#if>
40-
"items":
41-
[
42-
<#list results as row>
43-
{
44-
"type": "${row.item.typeShort}",
45-
"parentType": "${row.item.parentTypeShort!""}",
46-
"isContainer": ${row.item.isContainer?string},
47-
<#if row.container??>"container": "${row.container!""}",</#if>
48-
"name": "${row.item.properties.name!""}",
49-
<#if row.item.aspects??>
50-
"aspects": [
51-
<#list row.item.aspects as aspect>
52-
"${shortQName(aspect)}"
53-
<#if aspect_has_next>,</#if>
54-
</#list>
55-
],
56-
</#if>
57-
"title":<#if row.item.properties["lnk:title"]??>"${row.item.properties["lnk:title"]}",
58-
<#elseif row.item.properties["ia:whatEvent"]??>"${row.item.properties["ia:whatEvent"]}",
59-
<#else>"${row.item.properties.title!""}",</#if>
60-
"description": "${row.item.properties.description!""}",
61-
<#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
62-
<#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
63-
<#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
64-
<#if row.item.properties["ia:fromDate"]??>"fromDate": "${xmldate(row.item.properties["ia:fromDate"])}",</#if>
65-
"displayPath": "${row.item.displayPath!""}",
66-
"qnamePath": "${row.item.qnamePath!""}",
67-
<#if row.item.typeShort != "cm:person" && row.item.typeShort != "cm:authorityContainer">
68-
"userAccess":
69-
{
70-
"create": ${row.item.hasPermission("CreateChildren")?string},
71-
"edit": ${row.item.hasPermission("Write")?string},
72-
"delete": ${row.item.hasPermission("Delete")?string}
73-
},
74-
</#if>
75-
"nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
76-
"selectable" : ${row.selectable?string}</#if>
77-
}<#if row_has_next>,</#if>
78-
</#list>
79-
]
80-
}
81-
}
82-
</#escape>
1+
<#macro renderParent node indent=" ">
2+
<#escape x as jsonUtils.encodeJSONString(x)>
3+
${indent}"parent":
4+
${indent}{
5+
<#if (node != rootNode) && node.parent??>
6+
<@renderParent node.parent indent+" " />
7+
</#if>
8+
${indent}"type": "${node.typeShort}",
9+
${indent}"isContainer": ${node.isContainer?string},
10+
${indent}"name": "${node.properties.name!""}",
11+
${indent}"title": "${node.properties.title!""}",
12+
${indent}"description": "${node.properties.description!""}",
13+
<#if node.properties.modified??>${indent}"modified": "${xmldate(node.properties.modified)}",</#if>
14+
<#if node.properties.modifier??>${indent}"modifier": "${node.properties.modifier}",</#if>
15+
${indent}"displayPath": "${node.displayPath!""}",
16+
${indent}"qnamePath": "${node.qnamePath!""}",
17+
<#if node.aspects??>
18+
${indent}"aspects":
19+
${indent}[
20+
<#list node.aspects as aspect>
21+
"${shortQName(aspect)}"
22+
<#if aspect_has_next>,</#if>
23+
</#list>
24+
25+
${indent}],
26+
</#if>
27+
${indent}"nodeRef": "${node.nodeRef}"
28+
${indent}},
29+
</#escape>
30+
</#macro>
31+
32+
<#macro pickerResultsJSON results>
33+
<#escape x as jsonUtils.encodeJSONString(x)>
34+
{
35+
"data":
36+
{
37+
<#if parent??>
38+
<@renderParent parent />
39+
</#if>
40+
"items":
41+
[
42+
<#list results as row>
43+
{
44+
"type": "${row.item.typeShort}",
45+
"parentType": "${row.item.parentTypeShort!""}",
46+
"isContainer": ${row.item.isContainer?string},
47+
<#if row.container??>"container": "${row.container!""}",</#if>
48+
<#if row.item.properties?? && row.item.properties.name??>
49+
"name": "${row.item.properties.name!""}",
50+
<#else>
51+
"name": "${(row.item.name)!row.item?string!""}",
52+
</#if>
53+
<#if row.item.aspects??>
54+
"aspects": [
55+
<#list row.item.aspects as aspect>
56+
"${shortQName(aspect)}"
57+
<#if aspect_has_next>,</#if>
58+
</#list>
59+
],
60+
</#if>
61+
<#if row.item.properties??>
62+
"title":<#if row.item.properties["lnk:title"]??>"${row.item.properties["lnk:title"]}",
63+
<#elseif row.item.properties["ia:whatEvent"]??>"${row.item.properties["ia:whatEvent"]}",
64+
<#else>"${row.item.properties.title!""}",</#if>
65+
"description": "${row.item.properties.description!""}",
66+
<#else>
67+
"title": "${(row.item.name)!row.item?string!""}",
68+
"description": "",
69+
</#if>
70+
<#if row.item.properties.modified??>"modified": "${xmldate(row.item.properties.modified)}",</#if>
71+
<#if row.item.properties.modifier??>"modifier": "${row.item.properties.modifier}",</#if>
72+
<#if row.item.siteShortName??>"site": "${row.item.siteShortName}",</#if>
73+
<#if row.item.properties["ia:fromDate"]??>"fromDate": "${xmldate(row.item.properties["ia:fromDate"])}",</#if>
74+
"displayPath": "${row.item.displayPath!""}",
75+
"qnamePath": "${row.item.qnamePath!""}",
76+
<#if row.item.typeShort != "cm:person" && row.item.typeShort != "cm:authorityContainer">
77+
"userAccess":
78+
{
79+
"create": ${row.item.hasPermission("CreateChildren")?string},
80+
"edit": ${row.item.hasPermission("Write")?string},
81+
"delete": ${row.item.hasPermission("Delete")?string}
82+
},
83+
</#if>
84+
"nodeRef": "${row.item.nodeRef}"<#if row.selectable?exists>,
85+
"selectable" : ${row.selectable?string}</#if>
86+
}<#if row_has_next>,</#if>
87+
</#list>
88+
]
89+
}
90+
}
91+
</#escape>
8392
</#macro>

0 commit comments

Comments
 (0)