← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18653: implemented support for optionset in metadata attributes

 

------------------------------------------------------------
revno: 18653
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2015-03-21 10:44:53 +0700
message:
  implemented support for optionset in metadata attributes
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm


--
lp:dhis2
https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk

Your team DHIS 2 developers is subscribed to branch lp:dhis2.
To unsubscribe from this branch go to https://code.launchpad.net/~dhis2-devs-core/dhis2/trunk/+edit-subscription
=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2014-10-06 13:02:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2015-03-21 03:44:53 +0000
@@ -257,6 +257,25 @@
 </tr>
 #end
 
+#macro( trOptionSetInput $args )
+#if( "$!args.name" == "" )
+  #set( $name = $!args.id )
+#else
+  #set( $name = $!args.name )
+#end
+
+<tr>
+	<td style="width: 200px;"><label for="$!args.id">$!args.text #if($args.mandatory)<em title="$i18n.getString( 'required' )" class="required">*</em>#end</label></td>
+	<td>
+		<select id="$!args.id" name="$name">
+		#foreach( $choice in $args.attribute.optionSet.options )
+			<option value="$choice.code" #if( $args.value == $choice.code )selected="selected"#end>$choice.displayName</option>
+		#end
+		</select>
+	</td>
+</tr>
+#end
+
 #macro( tblDynamicAttributesJavascript )
 var attributes = jQuery("form").find(":input[name*='attribute_']");
 var jqJsonAttributeValues= jQuery("#jsonAttributeValues");
@@ -318,6 +337,8 @@
 			#trPositiveIntegerInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
 		#elseif( $attribute.valueType == "negative_integer" )
 			#trNegativeIntegerInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value } )
+		#elseif( $attribute.valueType == "option_set" )
+			#trOptionSetInput( { "text": $text, "id": "attribute_$id", "mandatory": $mandatory, "value": $value, "attribute": $attribute } )
 		#end
 	#end
 </table>