← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16082: Fixed bug - Exception thrown when to save TEI location without selecting any orgunit.

 

------------------------------------------------------------
revno: 16082
committer: Tran Chau <tran.hispvietnam@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-07-11 12:28:48 +0700
message:
  Fixed bug - Exception thrown when to save TEI location without selecting any orgunit.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/RegisterTrackedEntityInstanceLocationAction.java
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties
  dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceLocation.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-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/RegisterTrackedEntityInstanceLocationAction.java'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/RegisterTrackedEntityInstanceLocationAction.java	2014-03-18 08:10:10 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/java/org/hisp/dhis/caseentry/action/trackedentity/RegisterTrackedEntityInstanceLocationAction.java	2014-07-11 05:28:48 +0000
@@ -38,7 +38,8 @@
 /**
  * @author Chau Thu Tran
  * 
- * @version $RegisterTrackedEntityInstanceLocationAction.java Mar 27, 2012 04:52:51 PM$
+ * @version $RegisterTrackedEntityInstanceLocationAction.java Mar 27, 2012
+ *          04:52:51 PM$
  */
 public class RegisterTrackedEntityInstanceLocationAction
     implements Action
@@ -46,7 +47,7 @@
     // -------------------------------------------------------------------------
     // Dependencies
     // -------------------------------------------------------------------------
-    
+
     private SelectionTreeManager selectionTreeManager;
 
     public void setSelectionTreeManager( SelectionTreeManager selectionTreeManager )
@@ -81,13 +82,15 @@
     {
         OrganisationUnit orgunit = selectionTreeManager.getReloadedSelectedOrganisationUnit();
 
-        TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( entityInstanceId );
-
-        entityInstance.setOrganisationUnit( orgunit );
-        
-        entityInstanceService.addTrackedEntityInstance( entityInstance );
-
-        return SUCCESS;
+        if ( orgunit != null )
+        {
+            TrackedEntityInstance entityInstance = entityInstanceService.getTrackedEntityInstance( entityInstanceId );
+            entityInstance.setOrganisationUnit( orgunit );
+            entityInstanceService.updateTrackedEntityInstance( entityInstance );
+            return SUCCESS;
+        }
+
+        return INPUT;
     }
 
 }

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2014-07-09 03:43:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/org/hisp/dhis/caseentry/i18n_module.properties	2014-07-11 05:28:48 +0000
@@ -693,4 +693,5 @@
 filter_by_program = Filter by program
 users = Users
 message_is_sent = Message is sent
-messsage = Message
\ No newline at end of file
+messsage = Message
+please_select_an_orgunit = Please select an organisation unit
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2014-06-24 10:12:20 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/resources/struts.xml	2014-07-11 05:28:48 +0000
@@ -543,6 +543,8 @@
 
 		<action name="registerTrackedEntityInstanceLocation"
 			class="org.hisp.dhis.caseentry.action.trackedentity.RegisterTrackedEntityInstanceLocationAction">
+			<result name="input" type="velocity-json">/dhis-web-commons/ajax/jsonResponseInput.vm
+			</result>
 			<result name="success" type="velocity-json">/dhis-web-commons/ajax/jsonResponseSuccess.vm
 			</result>
 			<param name="requiredAuthorities">F_TRACKED_ENTITY_INSTANCE_CHANGE_LOCATION</param>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2014-07-10 07:17:45 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/activityPlanSelect.vm	2014-07-11 05:28:48 +0000
@@ -107,8 +107,8 @@
 				<td>$i18n.getString('use_data_from_level')</td>
 				<td>
 					<input type="radio" id='ouMode1' name="ouMode" value="SELECTED" checked> $i18n.getString('selected')
-					<input type="radio" id='ouMode2' name="ouMode" value="CHILDREN"> $i18n.getString('children_only')
-					<input type="radio" id='ouMode3' name="ouMode" value="DESCENDANTS"> $i18n.getString('all')
+					<input type="radio" id='ouMode2' name="ouMode" value="DESCENDANTS"> $i18n.getString('children_only')
+					<input type="radio" id='ouMode3' name="ouMode" value="ALL"> $i18n.getString('all')
 				</td>
 			</tr>
 			<tr>

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2014-07-09 03:43:23 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/commons.js	2014-07-11 05:28:48 +0000
@@ -1339,8 +1339,13 @@
 	$.getJSON('registerTrackedEntityInstanceLocation.action', {
 		entityInstanceId : entityInstanceId
 	}, function(json) {
-		showTrackedEntityInstanceDashboardForm(entityInstanceId);
-		showSuccessMessage(i18n_save_success);
+		if(json.response=='input'){
+			setMessage( i18n_please_select_an_orgunit );
+		}
+		else{
+			showTrackedEntityInstanceDashboardForm(entityInstanceId);
+			showSuccessMessage(i18n_save_success);
+		}
 	});
 }
 
@@ -1767,8 +1772,7 @@
 		isValid = false;
 	}
 	if (isValid) {
-		$
-				.ajax({
+		$.ajax({
 					url : 'saveCoordinatesEvent.action',
 					data : {
 						programStageInstanceId : programStageInstanceId,

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceLocation.vm'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceLocation.vm	2014-02-07 20:25:49 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/trackedEntityInstanceLocation.vm	2014-07-11 05:28:48 +0000
@@ -1,6 +1,7 @@
 <script>
 	hideById('mainLinkLbl');
 	jQuery('[name=mainPagelink]').html(i18n_main_form_link);
+	var i18n_please_select_an_orgunit = '$encoder.jsEscape( $i18n.getString( "please_select_an_orgunit" ) , "'" )';
 </script>
 
 <h3>
@@ -27,4 +28,5 @@
 			<td></td>
 		</tr>
 	</table>
+	<span id='message'></span>
 </form>
\ No newline at end of file