← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4545: Data entry minor fix, category option combo name not displayed in history for custom forms

 

------------------------------------------------------------
revno: 4545
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-08 16:17:11 +0200
message:
  Data entry minor fix, category option combo name not displayed in history for custom forms
modified:
  dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm
  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/javascript/form.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm
  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-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java'
--- dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-08-27 11:14:30 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-09-08 14:17:11 +0000
@@ -302,6 +302,8 @@
                 }
 
                 inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
+                inputHtml += "<span id=\"" + dataElement.getId() + "-dataelement\" style=\"display:none\">" + dataElement.getName() + "</span>";
+                inputHtml += "<span id=\"" + categoryOptionCombo.getId() + "-optioncombo\" style=\"display:none\">" + categoryOptionCombo.getName() + "</span>";
                 
                 inputMatcher.appendReplacement( sb, inputHtml );
             }

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm	2011-09-04 21:07:05 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/cacheManifest.vm	2011-09-08 14:17:11 +0000
@@ -1,5 +1,5 @@
 CACHE MANIFEST
-# 2.4-SNAPSHOT Version 22
+# 2.4-SNAPSHOT Version 23
 NETWORK:
 *
 CACHE:

=== 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	2011-09-04 21:07:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/defaultForm.vm	2011-09-08 14:17:11 +0000
@@ -36,7 +36,7 @@
   #end
   #set( $count = $count + 1 )
   <tr>
-  <td id="${dataElement.id}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end>${encoder.htmlEncode( $dataElement.name )}</td>
+  <td id="${dataElement.id}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end><span id="${dataElement.id}-dataelement">${encoder.htmlEncode( $dataElement.name )}</span></td>
   #foreach( $optionCombo in $optionCombos )
   #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )	    
   <td>

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-08-30 21:19:19 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2011-09-08 14:17:11 +0000
@@ -387,7 +387,7 @@
 {
 	if ( dataElements[dataElementId] != null )
 	{
-		return dataElements[dataElementId].type;
+		return dataElements[dataElementId];
 	}
 	
 	log( 'Data element not present in data set, falling back to default type: ' + dataElementId );	
@@ -396,12 +396,27 @@
 
 function getDataElementName( dataElementId )
 {
-	if ( dataElements[dataElementId] != null )
-	{
-		return dataElements[dataElementId].name;
-	}
-	
-	log( 'Data element present in data set, falling back to default name: ' + dataElementId );
+	var span = $( '#' + dataElementId + '-dataelement' );
+	
+	if ( span != null )
+	{
+		return span.text();
+	}
+	
+	log( 'Data element not present in form, falling back to default name: ' + dataElementId );
+	return DEFAULT_NAME;	
+}
+
+function getOptionComboName( optionComboId )
+{
+	var span = $( '#' + optionComboId + '-optioncombo' );
+	
+	if ( span != null )
+	{
+		return span.text();
+	}
+	
+	log( 'Category option combo not present in form, falling back to default name: ' + optionComboId );
 	return DEFAULT_NAME;	
 }
 
@@ -723,7 +738,7 @@
     var optionComboId = id.split( '-' )[1];
 
     var dataElementName = getDataElementName( dataElementId );
-    var optionComboName = $( '#' + optionComboId + '-optioncombo' ).text();
+    var optionComboName = getOptionComboName( optionComboId );
 
     $( '#currentDataElement' ).html( dataElementName + ' ' + optionComboName );
 
@@ -935,7 +950,7 @@
     var periodId = $( '#selectedPeriodId' ).val();
 
     var dataElementName = getDataElementName( dataElementId );
-    var optionComboName = $( '#' + optionComboId + '-optioncombo' ).html();
+    var optionComboName = getOptionComboName( optionComboId );
     var operandName = dataElementName + ' ' + optionComboName;
 
     $( '#historyDiv' ).load( 'viewHistory.action', {

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2011-08-27 11:43:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm	2011-09-08 14:17:11 +0000
@@ -9,8 +9,8 @@
 "dataElements": {
 #set( $size = $dataElements.size() )
 #foreach( $dataElement in $dataElements )
-"${dataElement.id}":{"name":"$encoder.jsonEncode( ${dataElement.name} )","type":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )" 
-}#if( $velocityCount < $size ),#end
+"${dataElement.id}":"$encoder.jsonEncode( ${dataElement.getDetailedNumberType()} )" 
+#if( $velocityCount < $size ),#end
 #end },
 
 "indicatorFormulas": {

=== 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	2011-09-04 21:07:05 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/sectionForm.vm	2011-09-08 14:17:11 +0000
@@ -53,7 +53,7 @@
     #end
     #set( $count = $count + 1 )
     <tr>
-    <td id="${dataElement.id}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end>${encoder.htmlEncode( $dataElement.name )}</td>
+    <td id="${dataElement.id}-cell" #if( $mark == 1 )class="alt"#else class="reg"#end><span id="${dataElement.id}-dataelement">${encoder.htmlEncode( $dataElement.name )}</span></td>
     #foreach( $optionCombo in $optionCombos )
     #set( $dataEntryId = "${dataElement.id}-${optionCombo.id}-val" )
     #set( $greyedField = false )