=== 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 2013-03-17 14:36:26 +0000 +++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm 2013-06-24 07:16:54 +0000 @@ -368,3 +368,91 @@ #end #end + +################################################################################################## +## Data Entry Macros +################################################################################################## + +#* + @param $categoryComboId + @param $dataElements Data Elements to be rendered in your section + @param $args.title Include if you want a title rendered in your section +*# +#macro( renderSection $categoryComboId $dataElements $args ) + +#if( $!args.title ) + + + +#end + + + +
+

$encoder.htmlEncode( $args.title )

+
+
+ + #set( $colCount = $numberOfTotalColumns.get( $categoryComboId ) ) + #set( $categories = $orderedCategories.get( $categoryComboId ) ) + #set( $optionsMap = $orderedOptionsMap.get( $categoryComboId ) ) + #set( $colRepeat = $catColRepeat.get( $categoryComboId ) ) + #set( $hasFilterInSection = false ) + + #foreach( $category in $categories ) + #set( $categoryOptions = $optionsMap.get( $category.id ) ) + #set( $colCount = $colCount / $categoryOptions.size() ) + + + #set( $cols = $colRepeat.get( $category.id ) ) + #foreach( $col in $cols ) + #foreach( $categoryOption in $categoryOptions ) + + #end + #end + + #end + + #set( $count = 0 ) + #set( $mark = 0 ) + #set( $optionCombos = $orderedCategoryOptionCombos.get( $categoryComboId ) ) + #foreach( $optionCombo in $optionCombos ) + #end + #foreach( $dataElement in $dataElements ) + #if( $mark == 1 ) + #set( $mark = 0 ) + #else + #set( $mark = 1 ) + #end + #set( $count = $count + 1 ) + + + #foreach( $optionCombo in $optionCombos ) + #set( $dataEntryId = "${dataElement.uid}-${optionCombo.uid}-val" ) + #set( $commentId = "${dataElement.uid}-${optionCombo.uid}-comment" ) + #set( $greyedField = false ) + #set( $greyedField = $greyedFields.get( "${dataElement.uid}:${optionCombo.uid}" ) ) + #if( $dataElement.type == "bool" ) + + #elseif( $dataElement.type == "trueOnly" ) + + #else + #if( $dataElement.optionSet ) + + #else + + #end + #end + + #set( $tabIndex = $tabIndex + 1 ) + #end + + #end +
#if( $hasFilterInSection == false )#set( $hasFilterInSection = true )#end#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.displayName )}#end
${encoder.htmlEncode( $dataElement.getFormNameFallback() )}
+
+
+#end === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2013-06-24 05:33:13 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java 2013-06-24 07:16:54 +0000 @@ -29,7 +29,13 @@ import com.opensymphony.xwork2.Action; import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator; -import org.hisp.dhis.dataelement.*; +import org.hisp.dhis.dataelement.DataElement; +import org.hisp.dhis.dataelement.DataElementCategory; +import org.hisp.dhis.dataelement.DataElementCategoryCombo; +import org.hisp.dhis.dataelement.DataElementCategoryOption; +import org.hisp.dhis.dataelement.DataElementCategoryOptionCombo; +import org.hisp.dhis.dataelement.DataElementOperand; +import org.hisp.dhis.dataelement.DataElementService; import org.hisp.dhis.dataentryform.DataEntryForm; import org.hisp.dhis.dataentryform.DataEntryFormService; import org.hisp.dhis.dataset.DataSet; @@ -40,7 +46,12 @@ import org.hisp.dhis.organisationunit.OrganisationUnit; import org.hisp.dhis.organisationunit.OrganisationUnitService; -import java.util.*; +import java.util.ArrayList; +import java.util.Collection; +import java.util.Collections; +import java.util.HashMap; +import java.util.List; +import java.util.Map; /** * @author Torgeir Lorange Ostby @@ -299,8 +310,8 @@ // --------------------------------------------------------------------- // For multi-org unit we only support custom forms // --------------------------------------------------------------------- - - if ( multiOrganisationUnit != null && multiOrganisationUnit != 0 ) + + if ( multiOrganisationUnit != null && multiOrganisationUnit != 0 ) { OrganisationUnit organisationUnit = organisationUnitService.getOrganisationUnit( multiOrganisationUnit ); List organisationUnitChildren = new ArrayList(); @@ -323,7 +334,7 @@ organisationUnits.addAll( organisationUnitChildren ); getSectionForm( dataElements, dataSet ); - + displayMode = DataSet.TYPE_SECTION_MULTIORG; } if ( displayMode.equals( DataSet.TYPE_SECTION ) ) @@ -381,7 +392,7 @@ Collections.sort( dataElementsNotInForm, IdentifiableObjectNameComparator.INSTANCE ); } - List des = new ArrayList(); + List des; for ( DataElementCategoryCombo categoryCombo : orderedCategoryCombos ) { === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2013-06-24 05:33:13 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm 2013-06-24 07:16:54 +0000 @@ -1,67 +1,8 @@ + #set( $tabIndex = 1 ) #set( $hasAccess = $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) #foreach( $categoryCombo in $orderedCategoryCombos ) - - #set( $colCount = $numberOfTotalColumns.get( $categoryCombo.id ) ) - #set( $categories = $orderedCategories.get( $categoryCombo.id ) ) - #set( $optionsMap = $orderedOptionsMap.get( $categoryCombo.id ) ) - #set( $colRepeat = $catColRepeat.get( $categoryCombo.id ) ) - - #foreach( $category in $categories ) - #set( $categoryOptions = $optionsMap.get( $category.id ) ) - #set( $colCount = $colCount / $categoryOptions.size() ) - - - #set( $cols = $colRepeat.get( $category.id ) ) - #foreach( $col in $cols ) - #foreach( $categoryOption in $categoryOptions ) - - #end - #end - - #end - - #set( $count = 0 ) - #set( $dataElements = $orderedDataElements.get( $categoryCombo ) ) - #set( $optionCombos = $orderedCategoryOptionCombos.get( $categoryCombo.id ) ) - #set( $mark = 0 ) - #foreach( $optionCombo in $optionCombos ) - #end - #foreach( $dataElement in $dataElements ) - #if( $mark == 1 ) - #set( $mark = 0 ) - #else - #set( $mark = 1 ) - #end - #set( $count = $count + 1 ) - - - #foreach( $optionCombo in $optionCombos ) - #set( $dataEntryId = "${dataElement.uid}-${optionCombo.uid}-val" ) - #set( $commentId = "${dataElement.uid}-${optionCombo.uid}-comment" ) - #if( $dataElement.type == "bool" ) - - #elseif( $dataElement.type == 'trueOnly' ) - - #else - #if( $dataElement.optionSet ) - - #else - - #end - #end - - #set( $tabIndex = $tabIndex + 1 ) - #end - - #end -
#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.displayName )}#end
${encoder.htmlEncode( $dataElement.getFormNameFallback() )} -
-
-
+ #set( $dataElements = $orderedDataElements.get( $categoryCombo ) ) + #renderSection( $categoryCombo.id $dataElements ) #end === modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm' --- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2013-06-24 06:01:18 +0000 +++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm 2013-06-24 07:16:54 +0000 @@ -1,90 +1,8 @@ + #set( $tabIndex = 1 ) #set( $hasAccess = $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) ) #foreach( $section in $sections ) #set( $categoryComboId = $sectionCombos.get( $section.id ) ) - #set( $title = $section.displayName ) - - #renderSection($categoryComboId, {"title": $title }) -#end - -#macro( renderSection $categoryComboId $args ) -#if( $!args.title ) - - - - -#else -
-

$encoder.htmlEncode( $args.title )

-
-#end - - - -
-
- - #set( $colCount = $numberOfTotalColumns.get( $categoryComboId ) ) - #set( $categories = $orderedCategories.get( $categoryComboId ) ) - #set( $optionsMap = $orderedOptionsMap.get( $categoryComboId ) ) - #set( $colRepeat = $catColRepeat.get( $categoryComboId ) ) - #set( $hasFilterInSection = false ) - - #foreach( $category in $categories ) - #set( $categoryOptions = $optionsMap.get( $category.id ) ) - #set( $colCount = $colCount / $categoryOptions.size() ) - - - #set( $cols = $colRepeat.get( $category.id ) ) - #foreach( $col in $cols ) - #foreach( $categoryOption in $categoryOptions ) - - #end - #end - - #end - - #set( $count = 0 ) - #set( $mark = 0 ) - #set( $optionCombos = $orderedCategoryOptionCombos.get( $categoryComboId ) ) - #foreach( $optionCombo in $optionCombos ) - #end - #foreach( $dataElement in $section.dataElements ) - #if( $mark == 1 ) - #set( $mark = 0 ) - #else - #set( $mark = 1 ) - #end - #set( $count = $count + 1 ) - - - #foreach( $optionCombo in $optionCombos ) - #set( $dataEntryId = "${dataElement.uid}-${optionCombo.uid}-val" ) - #set( $commentId = "${dataElement.uid}-${optionCombo.uid}-comment" ) - #set( $greyedField = false ) - #set( $greyedField = $greyedFields.get( "${dataElement.uid}:${optionCombo.uid}" ) ) - #if( $dataElement.type == "bool" ) - - #elseif( $dataElement.type == "trueOnly" ) - - #else - #if( $dataElement.optionSet ) - - #else - - #end - #end - - #set( $tabIndex = $tabIndex + 1 ) - #end - - #end -
#if( $hasFilterInSection == false )#set( $hasFilterInSection = true )#end#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.displayName )}#end
${encoder.htmlEncode( $dataElement.getFormNameFallback() )}
-
-
+ #renderSection( $categoryComboId, $section.dataElements, {"title": $section.displayName } ) #end