← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18740: support mandatory for metadata attributes of type optionset

 

------------------------------------------------------------
revno: 18740
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 16:48:48 +0700
message:
  support mandatory for metadata attributes of type optionset
modified:
  dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java
  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-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java'
--- dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java	2015-01-17 07:41:26 +0000
+++ dhis-2/dhis-support/dhis-support-system/src/main/java/org/hisp/dhis/system/util/AttributeUtils.java	2015-03-30 09:48:48 +0000
@@ -32,6 +32,7 @@
 import org.hisp.dhis.attribute.Attribute;
 import org.hisp.dhis.attribute.AttributeService;
 import org.hisp.dhis.attribute.AttributeValue;
+import org.springframework.util.StringUtils;
 
 import java.util.HashMap;
 import java.util.List;
@@ -78,7 +79,7 @@
             {
                 if ( attributeValueItem.getAttribute().getId() == attribute.getId() )
                 {
-                    if ( attributeValue == null || attributeValue.getValue() == null || attributeValue.getValue().length() == 0 )
+                    if ( attributeValue == null || StringUtils.isEmpty( attributeValue.getValue() ) )
                     {
                         attributeService.deleteAttributeValue( attributeValueItem );
                     }

=== 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	2015-03-21 03:44:53 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2015-03-30 09:48:48 +0000
@@ -268,6 +268,9 @@
 	<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">
+    #if( $args.mandatory != true )
+      <option value="">---</option>
+    #end
 		#foreach( $choice in $args.attribute.optionSet.options )
 			<option value="$choice.code" #if( $args.value == $choice.code )selected="selected"#end>$choice.displayName</option>
 		#end