dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15479
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5624: (mobile) sort optionCombos in dataEntry
------------------------------------------------------------
revno: 5624
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2011-12-27 13:51:59 +0100
message:
(mobile) sort optionCombos in dataEntry
modified:
dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/FormUtils.java
dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.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-light/src/main/java/org/hisp/dhis/light/dataentry/utils/FormUtils.java'
--- dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/FormUtils.java 2011-12-26 10:07:59 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/java/org/hisp/dhis/light/dataentry/utils/FormUtils.java 2011-12-27 12:51:59 +0000
@@ -27,14 +27,8 @@
package org.hisp.dhis.light.dataentry.utils;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.HashMap;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-
import org.apache.commons.collections.CollectionUtils;
+import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
import org.hisp.dhis.dataanalysis.DataAnalysisService;
import org.hisp.dhis.dataelement.DataElement;
import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo;
@@ -58,6 +52,8 @@
import org.joda.time.format.DateTimeFormatter;
import org.joda.time.format.ISODateTimeFormat;
+import java.util.*;
+
/**
* @author mortenoh
*/
@@ -129,7 +125,7 @@
@SuppressWarnings( "unchecked" )
public Map<String, DeflatedDataValue> getValidationViolations( OrganisationUnit organisationUnit, DataSet dataSet,
- Period period )
+ Period period )
{
Map<String, DeflatedDataValue> validationErrorMap = new HashMap<String, DeflatedDataValue>();
@@ -226,8 +222,7 @@
try
{
Double.parseDouble( value );
- }
- catch ( NumberFormatException e )
+ } catch ( NumberFormatException e )
{
return false;
}
@@ -240,8 +235,7 @@
try
{
Integer.parseInt( value );
- }
- catch ( NumberFormatException e )
+ } catch ( NumberFormatException e )
{
return false;
}
@@ -271,8 +265,7 @@
{
return true;
}
- }
- catch ( NumberFormatException e )
+ } catch ( NumberFormatException e )
{
}
@@ -291,8 +284,7 @@
{
return true;
}
- }
- catch ( NumberFormatException e )
+ } catch ( NumberFormatException e )
{
}
@@ -312,11 +304,18 @@
{
sdf.parseDateTime( value );
return true;
- }
- catch ( IllegalArgumentException e )
+ } catch ( IllegalArgumentException e )
{
}
return false;
}
+
+ public static List<DataElementCategoryOptionCombo> sortedCategoryOptionCombos( Collection<DataElementCategoryOptionCombo> categoryOptionCombos )
+ {
+ List<DataElementCategoryOptionCombo> sortedCategoryOptionCombos = new ArrayList<DataElementCategoryOptionCombo>( categoryOptionCombos );
+ Collections.sort( sortedCategoryOptionCombos, new IdentifiableObjectNameComparator() );
+
+ return sortedCategoryOptionCombos;
+ }
}
=== modified file 'dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm'
--- dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm 2011-12-27 12:16:47 +0000
+++ dhis-2/dhis-web/dhis-web-light/src/main/webapp/dhis-web-light/dataEntrySection.vm 2011-12-27 12:51:59 +0000
@@ -45,9 +45,11 @@
#set( $dataElementName = $dataElement.name )
#end
- #foreach( $optionCombo in $dataElement.categoryCombo.optionCombos )
-
- #if( !$greyedFields.get( "$dataElement.id:$optionCombo.id" ) )
+ #set( $optionCombos = $formUtils.sortedCategoryOptionCombos( $dataElement.categoryCombo.optionCombos ) )
+
+ #foreach( $optionCombo in $optionCombos )
+
+ #if( !$greyedFields.get( "$dataElement.id:$optionCombo.id" ) )
#set( $key = "DE${dataElement.id}OC${optionCombo.id}" )
<label>$encoder.htmlEncode( $dataElementName ) #if( $optionCombo.name!="(default)")$encoder.htmlEncode( $optionCombo.name )#end</label>