← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4546: Added property formName to data element. This is useful when you want to use section/default form...

 

------------------------------------------------------------
revno: 4546
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2011-09-08 17:28:20 +0200
message:
  Added property formName to data element. This is useful when you want to use section/default forms and there is a requirement to replicate paper forms with non-descriptive data element names.
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java
  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/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js
  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/sectionForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.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-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/dataelement/DataElement.java	2011-09-08 15:28:20 +0000
@@ -89,6 +89,8 @@
 
     public static final String AGGREGATION_OPERATOR_COUNT = "count";
 
+    private String formName;
+    
     /**
      * If this DataElement is active or not (enabled or disabled).
      */
@@ -369,11 +371,26 @@
         result.append( "}" );
         return result.toString();
     }
+    
+    public String getFormNameFallback()
+    {
+        return formName != null && !formName.isEmpty() ? formName : name;
+    }
 
     // -------------------------------------------------------------------------
     // Getters and setters
     // -------------------------------------------------------------------------
 
+    public String getFormName()
+    {
+        return formName;
+    }
+
+    public void setFormName( String formName )
+    {
+        this.formName = formName;
+    }
+
     public boolean isActive()
     {
         return active;

=== 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-09-08 14:17:11 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/java/org/hisp/dhis/dataentryform/DefaultDataEntryFormService.java	2011-09-08 15:28:20 +0000
@@ -302,7 +302,7 @@
                 }
 
                 inputHtml = inputHtml.replace( TAG_CLOSE, appendCode );
-                inputHtml += "<span id=\"" + dataElement.getId() + "-dataelement\" style=\"display:none\">" + dataElement.getName() + "</span>";
+                inputHtml += "<span id=\"" + dataElement.getId() + "-dataelement\" style=\"display:none\">" + dataElement.getFormNameFallback() + "</span>";
                 inputHtml += "<span id=\"" + categoryOptionCombo.getId() + "-optioncombo\" style=\"display:none\">" + categoryOptionCombo.getName() + "</span>";
                 
                 inputMatcher.appendReplacement( sb, inputHtml );

=== modified file 'dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml'
--- dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2011-09-06 11:52:18 +0000
+++ dhis-2/dhis-services/dhis-service-core/src/main/resources/org/hisp/dhis/dataelement/hibernate/DataElement.hbm.xml	2011-09-08 15:28:20 +0000
@@ -34,6 +34,8 @@
 
     <property name="description" type="text" />
 
+	<property name="formName" length="230" />
+
     <property name="active" not-null="true" />
 
     <property name="type" column="valuetype" length="16" not-null="true" />

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-08-18 12:04:09 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/validationRules.js	2011-09-08 15:28:20 +0000
@@ -214,6 +214,11 @@
             "alphanumericwithbasicpuncspaces" : true,
             "notOnlyDigits" : true
         },
+        "formName" : {
+            "rangelength" : [ 2, 150 ],
+            "alphanumericwithbasicpuncspaces" : false,
+            "notOnlyDigits" : false
+        },
         "url" : {
             "url" : true,
             "rangelength" : [ 0, 255 ]

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

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2011-05-05 21:15:45 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/AddDataElementAction.java	2011-09-08 15:28:20 +0000
@@ -100,6 +100,13 @@
     {
         this.description = description;
     }
+    
+    private String formName;
+
+    public void setFormName( String formName )
+    {
+        this.formName = formName;
+    }
 
     private String domainType;
 
@@ -196,6 +203,7 @@
         dataElement.setShortName( shortName );
         dataElement.setCode( code );
         dataElement.setDescription( description );
+        dataElement.setFormName( formName );
         dataElement.setActive( true );
         dataElement.setDomainType( domainType );
         dataElement.setType( valueType );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2011-06-29 08:45:16 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/java/org/hisp/dhis/dd/action/dataelement/UpdateDataElementAction.java	2011-09-08 15:28:20 +0000
@@ -118,6 +118,13 @@
         this.description = description;
     }
 
+    private String formName;
+
+    public void setFormName( String formName )
+    {
+        this.formName = formName;
+    }
+
     private Boolean active;
 
     public void setActive( Boolean active )
@@ -205,6 +212,11 @@
         {
             description = null;
         }
+        
+        if ( formName != null && formName.trim().length() == 0 )
+        {
+            formName = null;
+        }
 
         // ---------------------------------------------------------------------
         // Update data element
@@ -220,6 +232,7 @@
         dataElement.setShortName( shortName );
         dataElement.setCode( code );
         dataElement.setDescription( description );
+        dataElement.setFormName( formName );
         dataElement.setActive( active );
         dataElement.setDomainType( domainType );
         dataElement.setType( valueType );

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2011-06-14 16:13:36 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/resources/org/hisp/dhis/dd/i18n_module.properties	2011-09-08 15:28:20 +0000
@@ -351,4 +351,5 @@
 negativeNumber									= Negative Integer
 view_1											= View 1
 view_2											= View 2
-store_zero_data_values							= Store Zero Data Value
\ No newline at end of file
+store_zero_data_values							= Store Zero Data Value
+form_name										= Form name
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/addDataElementForm.vm	2011-09-08 15:28:20 +0000
@@ -33,6 +33,10 @@
 		<td><textarea id="description" name="description" style="width:20em; height:8em"></textarea></td>
 	</tr>
 	<tr>
+		<td><label for="formName">$i18n.getString( "form_name" )</label></td>
+		<td><input type="text" id="formName" name="formName" style="width:20em"/></td>
+	</tr>
+	<tr>
 		<td><label for="domainType">$i18n.getString( "domain_type" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select id="domainType" name="domainType" style="min-width:20em">

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm	2011-04-24 15:50:02 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-datadictionary/src/main/webapp/dhis-web-maintenance-datadictionary/updateDataElementForm.vm	2011-09-08 15:28:20 +0000
@@ -42,6 +42,10 @@
 		<td><textarea id="description" name="description" style="width:20em; height:8em">$!encoder.htmlEncode( $dataElement.description )</textarea></td>
 	</tr>
 	<tr>
+		<td><label for="formName">$i18n.getString( "form_name" )</label></td>
+		<td><input type="text" id="formName" name="formName" value="$!encoder.htmlEncode( $dataElement.formName )" style="width:20em"/></td>
+	</tr>
+	<tr>
 		<td><label for="active">$i18n.getString( "active" ) <em title="$i18n.getString( 'required' )" class="required">*</em></label></td>
 		<td>
 			<select id="active" name="active" style="min-width:20em">