← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13778: Fixed bug - Error when to save person identifier types/attributes displayed in list.

 

------------------------------------------------------------
revno: 13778
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2014-01-19 21:27:32 +0700
message:
  Fixed bug - Error when to save person identifier types/attributes displayed in list.
modified:
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeInListNoProgramAction.java
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties
  dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeInListNoProgram.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-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeInListNoProgramAction.java'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeInListNoProgramAction.java	2014-01-09 17:09:05 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/java/org/hisp/dhis/patient/action/patientattribute/SavePatientAttributeInListNoProgramAction.java	2014-01-19 14:27:32 +0000
@@ -85,35 +85,38 @@
 
         int indexIden = 1;
         int indexAttr = 1;
-        for ( String objectId : selectedAttributeIds )
+        if ( selectedAttributeIds != null )
         {
-            // Identifier type
-            String[] id = objectId.split( "_" );
-            if ( id[0].equals( PREFIX_IDENTYFITER_TYPE ) )
-            {
-
-                PatientIdentifierType identifierType = patientIdentifierTypeService.getPatientIdentifierType( Integer
-                    .parseInt( id[1] ) );
-                identifierType.setDisplayInListNoProgram( true );
-                identifierType.setSortOrderInListNoProgram( indexIden );
-                patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
-                indexIden++;
-                patientIdentifierTypes.remove( identifierType );
-            }
-
-            // Attribute
-            else if ( id[0].equals( PREFIX_ATTRIBUTE ) )
-            {
-                PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
-                    .parseInt( id[1] ) );
-                patientAttribute.setDisplayInListNoProgram( true );
-                patientAttribute.setSortOrderInListNoProgram( indexAttr );
-                patientAttributeService.updatePatientAttribute( patientAttribute );
-                indexAttr++;
-                patientAttributes.remove( patientAttribute );
+            for ( String objectId : selectedAttributeIds )
+            {
+                // Identifier type
+                String[] id = objectId.split( "_" );
+                if ( id[0].equals( PREFIX_IDENTYFITER_TYPE ) )
+                {
+
+                    PatientIdentifierType identifierType = patientIdentifierTypeService
+                        .getPatientIdentifierType( Integer.parseInt( id[1] ) );
+                    identifierType.setDisplayInListNoProgram( true );
+                    identifierType.setSortOrderInListNoProgram( indexIden );
+                    patientIdentifierTypeService.updatePatientIdentifierType( identifierType );
+                    indexIden++;
+                    patientIdentifierTypes.remove( identifierType );
+                }
+
+                // Attribute
+                else if ( id[0].equals( PREFIX_ATTRIBUTE ) )
+                {
+                    PatientAttribute patientAttribute = patientAttributeService.getPatientAttribute( Integer
+                        .parseInt( id[1] ) );
+                    patientAttribute.setDisplayInListNoProgram( true );
+                    patientAttribute.setSortOrderInListNoProgram( indexAttr );
+                    patientAttributeService.updatePatientAttribute( patientAttribute );
+                    indexAttr++;
+                    patientAttributes.remove( patientAttribute );
+                }
             }
         }
-
+        
         // Set DisplayInListNoProgram=false for other ID type
         for ( PatientIdentifierType patientIdentifierType : patientIdentifierTypes )
         {

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2014-01-08 17:56:11 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/resources/org/hisp/dhis/patient/i18n_module.properties	2014-01-19 14:27:32 +0000
@@ -495,4 +495,4 @@
 view_template_reminder_message = View template reminder message 
 display_in_list_no_program = Display in list without program
 manage_attributes_with_no_program = Manage attributes with no program
-patient_identifer_type_attribute_displayed_in_list = Person identifer type/attributes displayed in list
\ No newline at end of file
+patient_identifer_type_attribute_displayed_in_list = Person identifier types/attributes displayed in list
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeInListNoProgram.vm'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeInListNoProgram.vm	2014-01-08 16:37:33 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-patient/src/main/webapp/dhis-web-maintenance-patient/patientAttributeInListNoProgram.vm	2014-01-19 14:27:32 +0000
@@ -1,3 +1,16 @@
+<script>
+	jQuery(document).ready(	function(){
+		validation( 'savePatientAttributeInListNoProgramForm', function(form){
+			form.submit();
+		}, function(){
+			selectAllById('selectedAttributeIds');
+			if(jQuery("#selectedAttributeIds option").length > 0 ){
+				setFieldValue('hasAttributes', 'true');
+			}
+		});
+	});	
+</script>
+
 <h3>$i18n.getString( "patient_identifer_type_attribute_displayed_in_list" )</h3>
 																			
 <form id="savePatientAttributeInListNoProgramForm" name="savePatientAttributeInListNoProgramForm" action="savePatientAttributeInListNoProgram.action" method="post" action='savePatientAttributeVisitSchedule.action' onsubmit="selectAllById('selectedAttributeIds');">
@@ -11,7 +24,10 @@
 	<tr>
 		<th>$i18n.getString( "availableAttribute" )</th>
 		<th>$i18n.getString( "filter" )</th>
-		<th>$i18n.getString( "selectedAttribute" )</th>
+		<th>
+			$i18n.getString( "selectedAttribute" )
+			<input type='hidden' id='hasAttributes' name='hasAttributes' class="{validate:{required:true}}">
+		</th>
 	</tr>
 	
 	<tr>