← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11256: removed need for defaultForm.vm

 

------------------------------------------------------------
revno: 11256
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-06-25 16:01:34 +0700
message:
  removed need for defaultForm.vm
removed:
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm
  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/webapp/dhis-web-dataentry/sectionForm.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	2013-06-24 07:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/macros.vm	2013-06-25 09:01:34 +0000
@@ -368,91 +368,3 @@
     #end
 </div>
 #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 )
-<table class="formSection" style="margin-bottom: 20px;">
-#if( $!args.title )
-<tr>
-  <td>
-    <div class="cent"><h3>$encoder.htmlEncode( $args.title )</h3></div>
-  </td>
-</tr>
-#end
-<tr>
-  <td>
-    <div>
-    <table cellspacing="0">
-    #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() )
-    <tr colspan="$colCount">
-    <td>#if( $hasFilterInSection == false )<input type="text" class="sectionFilter" placeholder="$encoder.jsEscape( $i18n.getString( "filter_in_section" ) , "'")" onkeyup="filterInSection($(this));">#set( $hasFilterInSection = true )#end</td>
-    #set( $cols = $colRepeat.get( $category.id ) )
-    #foreach( $col in $cols )
-    #foreach( $categoryOption in $categoryOptions )
-    <th colspan="$colCount"><span align="center">#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.displayName )}#end</span></th>
-    #end
-    #end
-    </tr>
-    #end
-
-    #set( $count = 0 )
-    #set( $mark = 0 )
-    #set( $optionCombos = $orderedCategoryOptionCombos.get( $categoryComboId )  )
-    #foreach( $optionCombo in $optionCombos )<span id="${optionCombo.uid}-optioncombo" class="hidden">${encoder.htmlEncode( $optionCombo.displayName )}</span>
-    #end
-    #foreach( $dataElement in $dataElements )
-    #if( $mark == 1 )
-    #set( $mark = 0 )
-    #else
-    #set( $mark = 1 )
-    #end
-    #set( $count = $count + 1 )
-    <tr>
-    <td id="${dataElement.uid}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end><span id="${dataElement.uid}-dataelement">${encoder.htmlEncode( $dataElement.getFormNameFallback() )}</span></td>
-    #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" )
-    <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
-      <option value="">[$i18n.getString( "no_value" )]</option>
-      <option value="true">$i18n.getString( "yes" )</option>
-      <option value="false">$i18n.getString( "no" )</option>
-    </select><img name="commentlink" id="${commentId}"></td>
-    #elseif( $dataElement.type == "trueOnly" )
-        <td><input name="entrytrueonly" id="${dataEntryId}" type="checkbox" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
-    #else
-        #if( $dataElement.optionSet )
-          <td><input name="entryoptionset" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
-        #else
-          <td><input name="entryfield" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
-        #end
-    #end
-    </td>
-    #set( $tabIndex = $tabIndex + 1 )
-    #end
-    </tr>
-    #end
-	</table>
-    </div>
-    </td>
-  </tr>
-</table>
-#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 07:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/java/org/hisp/dhis/de/action/LoadFormAction.java	2013-06-25 09:01:34 +0000
@@ -28,6 +28,7 @@
  */
 
 import com.opensymphony.xwork2.Action;
+import org.hisp.dhis.common.CodeGenerator;
 import org.hisp.dhis.common.comparator.IdentifiableObjectNameComparator;
 import org.hisp.dhis.dataelement.DataElement;
 import org.hisp.dhis.dataelement.DataElementCategory;
@@ -307,6 +308,30 @@
 
         String displayMode = dataSet.getDataSetType();
 
+        if ( displayMode.equals( DataSet.TYPE_DEFAULT ) )
+        {
+            DataSet newDataSet = new DataSet();
+            newDataSet.mergeWith( dataSet );
+            dataSet = newDataSet;
+
+            for ( int i = 0; i < orderedCategoryCombos.size(); i++ )
+            {
+                Section section = new Section();
+                section.setId( i );
+                section.setSortOrder( i );
+
+                // generate a random uid so that equals work
+                section.setUid( CodeGenerator.generateCode() );
+
+                section.setDataSet( dataSet );
+                dataSet.getSections().add( section );
+
+                section.getDataElements().addAll( orderedDataElements.get( orderedCategoryCombos.get( i ) ) );
+            }
+
+            displayMode = DataSet.TYPE_SECTION;
+        }
+
         // ---------------------------------------------------------------------
         // For multi-org unit we only support custom forms
         // ---------------------------------------------------------------------
@@ -337,6 +362,7 @@
 
             displayMode = DataSet.TYPE_SECTION_MULTIORG;
         }
+
         if ( displayMode.equals( DataSet.TYPE_SECTION ) )
         {
             getSectionForm( dataElements, dataSet );

=== removed 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 07:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	1970-01-01 00:00:00 +0000
@@ -1,8 +0,0 @@
-
-#set( $tabIndex = 1 )
-#set( $hasAccess = $auth.hasAccess( "dhis-web-dataentry", "saveValue" ) )
-
-#foreach( $categoryCombo in $orderedCategoryCombos )
-    #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 07:16:54 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2013-06-25 09:01:34 +0000
@@ -4,5 +4,89 @@
 
 #foreach( $section in $sections )
     #set( $categoryComboId = $sectionCombos.get( $section.id ) )
-    #renderSection( $categoryComboId, $section.dataElements, {"title": $section.displayName } )
+    #renderSection( $categoryComboId, $section.dataElements, $section.displayName )
+#end
+
+#*
+    @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 $title )
+<table class="formSection" style="margin-bottom: 20px;">
+#if( $!title )
+<tr>
+  <td>
+    <div class="cent"><h3>$encoder.htmlEncode( $title )</h3></div>
+  </td>
+</tr>
+#end
+<tr>
+  <td>
+    <div>
+    <table cellspacing="0">
+    #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() )
+    <tr colspan="$colCount">
+    <td>#if( $hasFilterInSection == false )<input type="text" class="sectionFilter" placeholder="$encoder.jsEscape( $i18n.getString( "filter_in_section" ) , "'")" onkeyup="filterInSection($(this));">#set( $hasFilterInSection = true )#end</td>
+    #set( $cols = $colRepeat.get( $category.id ) )
+    #foreach( $col in $cols )
+    #foreach( $categoryOption in $categoryOptions )
+    <th colspan="$colCount"><span align="center">#if( $categoryOption.isDefault() )${i18n.getString( "value" )}#else ${encoder.htmlEncode( $categoryOption.displayName )}#end</span></th>
+    #end
+    #end
+    </tr>
+    #end
+
+    #set( $count = 0 )
+    #set( $mark = 0 )
+    #set( $optionCombos = $orderedCategoryOptionCombos.get( $categoryComboId )  )
+    #foreach( $optionCombo in $optionCombos )<span id="${optionCombo.uid}-optioncombo" class="hidden">${encoder.htmlEncode( $optionCombo.displayName )}</span>
+    #end
+    #foreach( $dataElement in $dataElements )
+    #if( $mark == 1 )
+    #set( $mark = 0 )
+    #else
+    #set( $mark = 1 )
+    #end
+    #set( $count = $count + 1 )
+    <tr>
+    <td id="${dataElement.uid}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end><span id="${dataElement.uid}-dataelement">${encoder.htmlEncode( $dataElement.getFormNameFallback() )}</span></td>
+    #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" )
+    <td><select name="entryselect" id="$dataEntryId" tabindex="$tabIndex"#if( $greyedField || !$hasAccess ) disabled="disabled"#end>
+      <option value="">[$i18n.getString( "no_value" )]</option>
+      <option value="true">$i18n.getString( "yes" )</option>
+      <option value="false">$i18n.getString( "no" )</option>
+    </select><img name="commentlink" id="${commentId}"></td>
+    #elseif( $dataElement.type == "trueOnly" )
+        <td><input name="entrytrueonly" id="${dataEntryId}" type="checkbox" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+    #else
+        #if( $dataElement.optionSet )
+          <td><input name="entryoptionset" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+        #else
+          <td><input name="entryfield" id="${dataEntryId}" type="text" tabindex="${tabIndex}"#if( $greyedField || !$hasAccess ) disabled="disabled"#end></td>
+        #end
+    #end
+    </td>
+    #set( $tabIndex = $tabIndex + 1 )
+    #end
+    </tr>
+    #end
+	</table>
+    </div>
+    </td>
+  </tr>
+</table>
 #end