-
Notifications
You must be signed in to change notification settings - Fork 0
/
pageawareness-summary.vm
122 lines (116 loc) · 4.81 KB
/
pageawareness-summary.vm
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
## Copyright 2016 ICE Health Systems
##
## Licensed under the Apache License, Version 2.0 (the "License");
## you may not use this file except in compliance with the License.
## You may obtain a copy of the License at
##
## http://www.apache.org/licenses/LICENSE-2.0
##
## Unless required by applicable law or agreed to in writing, software
## distributed under the License is distributed on an "AS IS" BASIS,
## WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
## See the License for the specific language governing permissions and
## limitations under the License.
##
## Macro title: Page Awareness Summary Macro
## Developed by: Matt MacLean (ICE Health Systems)
## Date created: 26/05/2016
##
## This macro displays lists of users who are acknowledgers, reviewers and/or approvers of the page.
##
## @param UserType:title=User Type|type=enum|enumValues=Acknowledgers,Reviewers,Approvers|desc=Lists the different users aware of this page.|required=true|multiple=false|default=Acknowledgers
##
## Based on the value of the user type parameter, determine which key prefix we will need to use for lookups
#set ( $prefix = "pageAwareness-" )
#set ( $datePrefix = "pageAwarenessDate-" )
#set ( $columnTitle = "Acknowledged" )
#if ( $paramUserType == "Reviewers" )
#set ( $prefix = "pageReview-" )
#set ( $datePrefix = "pageReviewDate-" )
#set ( $columnTitle = "Reviewed" )
#elseif ( $paramUserType == "Approvers" )
#set ( $prefix = "pageApprove-" )
#set ( $datePrefix = "pageApproveDate-" )
#set ( $columnTitle = "Approved" )
#end
## Get the list of properties for this content page
#set ( $contentProperties = $content.getProperties() )
#set ( $contentPropertyList = $contentProperties.asList() )
#set ( $contentId = $content.getContentId().asLong() )
#set ( $contentVersion = "v" + $content.getVersion() )
## Get the user assignments for the page
#set ( $assignedApproversKey = "assignedApprovers-" + $contentId )
#set ( $assignedReviewersKey = "assignedReviewers-" + $contentId )
#set ( $assignedApprovers = $contentProperties.getStringProperty( $assignedApproversKey ).split(",") )
#set ( $assignedReviewers = $contentProperties.getStringProperty( $assignedReviewersKey ).split(",") )
#if ( $paramUserType == "Reviewers" )
#set ( $assignedUsers = $assignedReviewers )
#elseif ( $paramUserType == "Approvers" )
#set ( $assignedUsers = $assignedApprovers )
#end
<table>
<thead>
<tr>
<th>Username</th>
<th>$columnTitle</th>
<th>Date</th>
</tr>
</thead>
<tbody>
#if ( $paramUserType == "Acknowledgers" )
## show all acknowledging users, and what version of the page they last acknowledged
#foreach( $contentProperty in $contentPropertyList )
#if ( $contentProperty.getName().startsWith($prefix) )
#set ( $propName = $contentProperty.getName() )
#set ( $idx = $propName.indexOf("-") + 1 )
#set ( $propNamePart = $propName.substring($idx) )
#set ( $idx = $propNamePart.indexOf("-") + 1 )
#set ( $userName = $propNamePart.substring($idx) )
#set ( $version = $contentProperty.getStringValue() )
#set ( $dateKey = $datePrefix + $contentId + "-" + $userName )
#set ( $dateValue = $contentProperties.getStringProperty($dateKey) )
#if ( !$dateValue )
#set ( $dateValue = "Unknown" )
#end
<tr>
<td>$userName</td>
<td>$version</td>
<td>$dateValue</td>
</tr>
#end
#end
#else
## For the assigned user lists, we always display assigned users, and only assigned users
#foreach( $userName in $assignedUsers )
#if ( $userName != "" )
#set ( $valueForKey = "" )
#set ( $keyName = $prefix + $contentId + "-" + $userName)
#set ( $keyNameDate = $datePrefix + $contentId + "-" + $userName)
#set ( $valueForKey = $contentProperties.getStringProperty($keyName) )
#set ( $displayValue = "Pending" )
#set ( $displayDate = "" )
#set ( $bgColor = "#FFC" )
#if ( $valueForKey && $valueForKey != "" )
#set ( $displayValue = $valueForKey )
#set ( $displayDate = $contentProperties.getStringProperty($keyNameDate) )
#if ( !$displayDate )
#set ( $displayDate = "Unknown" )
#end
#if ( $valueForKey == $contentVersion )
## light green bg
#set ( $bgColor = "#CFC" )
#else
## light red bg
#set ( $bgColor = "#FCC" )
#end
#end
<tr style="background-color: $bgColor;">
<td>$userName</td>
<td>$displayValue</td>
<td>$displayDate</td>
</tr>
#end
#end
#end
</tbody>
</table>