← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 10492: Add person attribute with type as YES-ONLY

 

------------------------------------------------------------
revno: 10492
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2013-04-08 11:21:21 +0700
message:
  Add person attribute with type as YES-ONLY 
modified:
  dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java
  dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.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/patient/PatientAttribute.java'
--- dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2013-03-08 09:15:27 +0000
+++ dhis-2/dhis-api/src/main/java/org/hisp/dhis/patient/PatientAttribute.java	2013-04-08 04:21:21 +0000
@@ -52,10 +52,12 @@
 
     public static final String TYPE_BOOL = "bool";
 
+    public static final String TYPE_TRUE_ONLY = "trueOnly";
+
     public static final String TYPE_COMBO = "combo";
 
     private String description;
-
+    
     private String valueType;
 
     private boolean mandatory;

=== modified file 'dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java'
--- dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-03-07 05:15:13 +0000
+++ dhis-2/dhis-services/dhis-service-patient/src/main/java/org/hisp/dhis/patient/DefaultPatientRegistrationFormService.java	2013-04-08 04:21:21 +0000
@@ -246,7 +246,6 @@
                 }
                 else
                 {
-
                     // Get value
                     String value = "";
                     if ( patient != null )
@@ -304,7 +303,15 @@
         }
         inputHtml += "}}\" ";
 
-        if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
+        if ( attribute.getValueType().equals( PatientAttribute.TYPE_TRUE_ONLY ) )
+        {
+            inputHtml += " type='checkbox' value='true' ";
+            if ( value.equals( "true" ) )
+            {
+                inputHtml += " checked ";
+            }
+        }
+        else if ( attribute.getValueType().equals( PatientAttribute.TYPE_BOOL ) )
         {
             inputHtml = inputHtml.replaceFirst( "input", "select" ) + ">";
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java	2013-02-01 08:40:49 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/dataentryform/SavePatientRegistrationFormAction.java	2013-04-08 04:21:21 +0000
@@ -105,6 +105,13 @@
         this.programId = programId;
     }
 
+    private String message;
+
+    public String getMessage()
+    {
+        return message;
+    }
+
     // -------------------------------------------------------------------------
     // Action implementation
     // -------------------------------------------------------------------------
@@ -143,6 +150,10 @@
             dataEntryFormService.updateDataEntryForm( dataEntryForm );
         }
 
+        Integer dataEntryFormId = dataEntryFormService.getDataEntryFormByName( name ).getId();
+
+        message = dataEntryFormId + "";
+        
         return SUCCESS;
     }
 

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2013-03-08 13:56:13 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/addPatientAttributeForm.vm	2013-04-08 04:21:21 +0000
@@ -44,6 +44,7 @@
                 <option value="number" selected="selected">$i18n.getString( "number" )</option>
                 <option value="string">$i18n.getString( "text" )</option>
                 <option value="bool">$i18n.getString( "yes_no" )</option>
+				<option value="trueOnly">$i18n.getString( "yes_only" )</option>
                 <option value="date">$i18n.getString( "date" )</option>
                 <option value="combo">$i18n.getString( "attribute_combo_type" )</option>
             </select>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2013-03-08 14:07:03 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/patientAttribute.js	2013-04-08 04:21:21 +0000
@@ -12,12 +12,26 @@
 			setInnerHTML( 'mandatoryField', mandatory );
 			var inherit = ( json.patientAttribute.inherit == 'true') ? i18n_yes : i18n_no;
 			setInnerHTML( 'inheritField', inherit );
-			setInnerHTML( 'valueTypeField', json.patientAttribute.valueType );    
+			
+			var valueType = json.patientAttribute.valueType;
+			var typeMap = patientAttributeTypeMap();
+			setInnerHTML( 'valueTypeField', typeMap[valueType] );    
 			
 			showDetails();
 	});
 }
 
+function patientAttributeTypeMap()
+{
+	var typeMap = [];
+	typeMap['number'] = i18n_number;
+	typeMap['string'] = i18n_text;
+	typeMap['bool'] = i18n_yes_no;
+	typeMap['trueOnly'] = i18n_yes_only;
+	typeMap['date'] = i18n_date;
+	typeMap['combo'] = i18n_attribute_combo_type;
+	return typeMap;
+}
 // -----------------------------------------------------------------------------
 // Remove Patient Attribute
 // -----------------------------------------------------------------------------

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-04-05 08:47:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/javascript/viewPatientRegistationForm.js	2013-04-08 04:21:21 +0000
@@ -1,3 +1,4 @@
+var isSave;
 
 $( document ).ready( function() 
 {
@@ -203,7 +204,7 @@
 	else{
 		setFieldValue('requiredField','everything_is_ok');
 		setInnerHTML( 'designTextarea' , jQuery("#designTextarea").ckeditorGet().getData() );
-		if(getFieldValue('autoSave')=='true'){
+		if(isSave='true'){
 			autoSavePatientRegistrationForm();
 		}
 		else
@@ -375,6 +376,8 @@
 	},
 	function( json ) 
 	{
+		setFieldValue('dataEntryFormId', json.message);
+		showById('deleteButton');
 		setHeaderDelayMessage( i18n_save_success ); 
 	} );
 }

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm	2013-03-08 09:15:27 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttribute.vm	2013-04-08 04:21:21 +0000
@@ -72,4 +72,6 @@
 	var i18n_processing = '$encoder.jsEscape( $i18n.getString( "processing" ) , "'")';
 	var i18n_done = '$encoder.jsEscape( $i18n.getString( "done" ) , "'")';
 	var i18n_all = '$encoder.jsEscape( $i18n.getString( "all" ) , "'")';
+	var i18n_yes_only = '$encoder.jsEscape( $i18n.getString( "yes_only" ) , "'")';
+	var i18n_attribute_combo_type = '$encoder.jsEscape( $i18n.getString( "attribute_combo_type" ) , "'")';
 </script>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2013-03-08 13:27:22 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/updatePatientAttibuteForm.vm	2013-04-08 04:21:21 +0000
@@ -47,7 +47,8 @@
                 <option value="number" #if( $patientAttribute.valueType == 'number' ) selected="selected" #end>$i18n.getString( "number" )</option>
                 <option value="string" #if( $patientAttribute.valueType == 'string' ) selected="selected" #end>$i18n.getString( "text" )</option>
                 <option value="bool" #if( $patientAttribute.valueType == 'bool' ) selected="selected" #end>$i18n.getString( "yes_no" )</option>
-                <option value="date" #if( $patientAttribute.valueType == 'date' ) selected="selected" #end>$i18n.getString( "date" )</option>
+                <option value="trueOnly" #if( $patientAttribute.valueType == 'trueOnly' ) selected="selected" #end >$i18n.getString( "yes_only" )</option>
+				<option value="date" #if( $patientAttribute.valueType == 'date' ) selected="selected" #end>$i18n.getString( "date" )</option>
                 <option value="combo" #if( $patientAttribute.valueType == 'combo' ) selected="selected" #end>$i18n.getString( "attribute_combo_type" )</option>
             </select>
         </td>

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm	2013-04-05 08:47:47 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/viewPatientRegistationForm.vm	2013-04-08 04:21:21 +0000
@@ -99,16 +99,14 @@
 <table width="100%">	
     <tr>
         <td>
-		    <button type="button" id="saveButton" onclick="validateDataEntryForm();">$i18n.getString( 'save' )</button>
-            <button type="submit" id="saveAndCloseButton"/>$i18n.getString( 'save_and_close' )</button>
+		    <button type="button" id="saveButton" onclick="isSave='true';validateDataEntryForm();">$i18n.getString( 'save' )</button>
+            <button type="submit" id="saveAndCloseButton" onclick="isSave='false';"/>$i18n.getString( 'save_and_close' )</button>
             <button type="button" id="cancelButton" onclick="window.location='patientRegistrationForm.action'">$i18n.getString( 'cancel' )</button>
 			&nbsp;&nbsp;<span style="color:#606060">|</span>&nbsp;
 		    <button type="button" id="propertiesButton" onclick="openPropertiesSelector()"/>$i18n.getString( 'insert_properties' )</button>
 			<button type="button" id="insertImagesButton">$i18n.getString( 'insert_images' )</button>
-			#if($!registrationForm.dataEntryForm)
 			&nbsp;&nbsp;<span style="color:#606060">|</span>&nbsp;
-		    <button type="button" id="deleteButton" onclick="deleteRegistrationForm( $registrationForm.id, '$registrationForm.dataEntryForm.name' )" />$i18n.getString( 'delete' )</button>
-			#end
+		    <button type="button" id="deleteButton" onclick="deleteRegistrationForm( $registrationForm.id, '$registrationForm.dataEntryForm.name' )" #if($!registrationForm.dataEntryForm) style='display:none;' #end />$i18n.getString( 'delete_this_form' )</button>
 			<input type="checkbox" id="autoSave" name="autoSave" value='$!autoSave' #if($autoSave && $autoSave=="true") checked #end onchange="setAutoSaveRegistrationSetting(this.checked)" />$i18n.getString( 'auto_save_patient_registration_forms' )
         </td>		
     </tr>