3
Displays a table which lists a set of objects and it's common operations: Filter,
4
add, update, translate, remove and show details. The macro produces code against
5
some specific conventions for the scripts and actions to call. Call it this way:
7
#objectList( [name of object, e.g. DataElement], [list of such objects, e.g. $dataElements] )
9
@param objectName The litteral name of the type of object to display, e.g. DataElement
10
@param objects A Velocity list of the objects to be formatted, typically prepared by an action.
12
#macro( objectList $objectName $objects )
13
<table class="objectListTable">
17
<td class="filter"><label for="filter">$i18n.getString( "filter_by_name" )</label>: <form action="none" onsubmit="filterValues(this.firstChild.firstChild.value);return false"><div><input id="filter" type="text"><input type="submit" value="Filter"></div></form></td>
18
<td style="text-align:right"><input type="button" value="$i18n.getString( "add_new" )" onclick="window.location.href='showAdd${objectName}Form.action'"></td>
21
<th>$i18n.getString( "name" )</th>
22
<th>$i18n.getString( "operations" )</th>
27
#foreach( $object in $objects )
28
<tr #if( $mark ) class="odd" #end>
29
<td>$encoder.htmlEncode( $object.name )</td>
31
<a href="showUpdate${objectName}Form.action?id=${object.id}" title="$i18n.getString( "edit" )"><img src="../images/edit.png" alt="$i18n.getString( "edit" )"></a>
32
<a href="$i18n.getString( "translation_translate" )" title="$i18n.getString( "translation_translate" )" onclick="this.href='javascript:location.href= \'../dhis-web-commons/i18n.action?className=${objectName}&$objectId=${object.id}&returnUrl=\' + location.href'"><img src="../images/i18n.png" alt="$i18n.getString( "translation_translate" )"></a>
33
<a href="javascript:remove${objectName}( $object.id, '$encoder.jsEncode( $object.name )' )" title="$i18n.getString( "remove" )"><img src="../images/delete.png" alt="$i18n.getString( "remove" )"></a>
34
<a href="javascript:show${objectName}Details( $object.id )" title="$i18n.getString( "show_details" )"><img src="../images/information.png" alt="$i18n.getString( "show_details" )"></a>
48
Supportive method for displaying rows with alternating colors in a table.
50
@param mark boolean alternating the color.
52
#macro( alternate $mark )
53
#if ( $mark ) class="listAlternateRow"#else class="listRow"#end
57
Formats a boolean into a readable value
59
@param bool the boolean to format.
61
#macro( formatBool $bool )
63
$i18n.getString( "yes" )
65
$i18n.getString( "no" )
69
#macro( formatAggregationOperator $operator )
70
#if ( $operator == "average" )
71
$i18n.getString( "average" )
72
#elseif ( $operator == "count" )
73
$i18n.getString( "count" )
74
#elseif ( $operator == "sum" )
75
$i18n.getString( "sum" )
77
$i18n.getString( "unknown" )
81
#macro( formatType $type )
82
#if ( $type == "string" )
83
$i18n.getString( "text" )
84
#elseif ( $type == "bool" )
85
$i18n.getString( "yes_no" )
86
#elseif ( $type == "int" )
87
$i18n.getString( "number" )
89
$i18n.getString( "unknown" )