← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19650: tracker-capture: apply the new webmessage reponse for registration, enrollment and event creation

 

------------------------------------------------------------
revno: 19650
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-07-14 21:05:51 +0200
message:
  tracker-capture: apply the new webmessage reponse for registration, enrollment and event creation
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js


--
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-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-07-13 07:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-07-14 19:05:51 +0000
@@ -1119,19 +1119,19 @@
         newEvent.status = newEvent.eventDate ? 'ACTIVE' : 'SCHEDULE';
 
         newEvents.events.push(newEvent);
-        DHIS2EventFactory.create(newEvents).then(function (data) {
-            if (data.importSummaries[0].status === 'ERROR') {
+        DHIS2EventFactory.create(newEvents).then(function (response) {
+            if (response.response && response.response.importSummaries[0].status === 'SUCCESS') {
+                newEvent.event = response.response.importSummaries[0].reference;
+                $modalInstance.close(newEvent);
+            }
+            else {                
                 var dialogOptions = {
                     headerText: 'event_creation_error',
-                    bodyText: data.importSummaries[0].description
+                    bodyText: response.message
                 };
 
                 DialogService.showDialog({}, dialogOptions);
             }
-            else {
-                newEvent.event = data.importSummaries[0].reference;
-                $modalInstance.close(newEvent);
-            }
         });
 
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html	2015-03-19 10:18:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event.html	2015-07-14 19:05:51 +0000
@@ -26,6 +26,8 @@
                            placeholder="{{dhis2CalendarFormat.keyDateFormat}}" 
                            ng-rquired="false" 
                            d2-date
+                           max-date="0"
+                           min-date=""
                            ng-model="dhis2Event.eventDate">
                     <span ng-if="eventDateInvalid" class="error">{{'required'| translate}}</span>
                 </div>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-07-13 07:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/registration/registration-controller.js	2015-07-14 19:05:51 +0000
@@ -143,10 +143,9 @@
         }
         
         RegistrationService.registerOrUpdate($scope.tei, $scope.optionSets, $scope.attributesById).then(function(registrationResponse){
-            
-            if(registrationResponse.response && registrationResponse.response.reference && registrationResponse.response.status === 'SUCCESS'){
-                
-                $scope.tei.trackedEntityInstance = registrationResponse.response.reference;
+            var reg = registrationResponse.response && registrationResponse.response.importSummaries && registrationResponse.response.importSummaries[0] ? registrationResponse.response.importSummaries[0] : {};
+            if(reg.reference && reg.status === 'SUCCESS'){                
+                $scope.tei.trackedEntityInstance = reg.reference;
                 
                 if( $scope.registrationMode === 'PROFILE' ){                    
                     reloadProfileWidget();
@@ -163,9 +162,9 @@
                         enrollment.dateOfIncident = $scope.selectedEnrollment.dateOfIncident === '' ? $scope.selectedEnrollment.dateOfEnrollment : $scope.selectedEnrollment.dateOfIncident;
 
                         EnrollmentService.enroll(enrollment).then(function(enrollmentResponse){
-                            var r = enrollmentResponse.response && enrollmentResponse.response.importSummaries && enrollmentResponse.response.importSummaries[0] ? enrollmentResponse.response.importSummaries[0] : {};
-                            if(r.reference && r.status === 'SUCCESS'){                                
-                                enrollment.enrollment = r.reference;
+                            var en = enrollmentResponse.response && enrollmentResponse.response.importSummaries && enrollmentResponse.response.importSummaries[0] ? enrollmentResponse.response.importSummaries[0] : {};
+                            if(en.reference && en.status === 'SUCCESS'){                                
+                                enrollment.enrollment = en.reference;
                                 $scope.selectedEnrollment = enrollment;                                                                
                                 var dhis2Events = EventUtils.autoGenerateEvents($scope.tei.trackedEntityInstance, $scope.selectedProgram, $scope.selectedOrgUnit, enrollment);
                                 if(dhis2Events.events.length > 0){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2015-06-25 15:23:48 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/relationship/relationship-controller.js	2015-07-14 19:05:51 +0000
@@ -104,10 +104,10 @@
             if( index !== -1 ){
                 $scope.selectedTei.relationships.splice(index,1);
                 TEIService.update($scope.selectedTei, $scope.optionSets, $scope.attributesById).then(function(response){
-                    if(response.status !== 'SUCCESS'){//update has failed
+                    if(response.response && response.response.status !== 'SUCCESS'){//update has failed
                         var dialogOptions = {
                                 headerText: 'update_error',
-                                bodyText: response.description
+                                bodyText: response.message
                             };
                         DialogService.showDialog({}, dialogOptions);
                         return;
@@ -518,10 +518,10 @@
             tei.relationships.push(relationship);
             
             TEIService.update(tei, $scope.optionSets, $scope.attributesById).then(function(response){
-                if(response.status !== 'SUCCESS'){//update has failed
+                if(response.response && response.response.status !== 'SUCCESS'){//update has failed
                     var dialogOptions = {
                             headerText: 'relationship_error',
-                            bodyText: response.description
+                            bodyText: response.message
                         };
                     DialogService.showDialog({}, dialogOptions);
                     return;
@@ -632,12 +632,10 @@
         $scope.tei = {trackedEntity: selectedTrackedEntity, orgUnit: $scope.selectedOrgUnit.id, attributes: registrationAttributes };   
         var teiId = '';
 
-        TEIService.register($scope.tei, $scope.optionSets, $scope.attributesById).then(function(tei){
-            
-            if(tei.status === 'SUCCESS'){
-                
-                teiId = tei.reference;
-                
+        TEIService.register($scope.tei, $scope.optionSets, $scope.attributesById).then(function(registrationResponse){            
+            var reg = registrationResponse.response && registrationResponse.response.importSummaries && registrationResponse.response.importSummaries[0] ? registrationResponse.response.importSummaries[0] : {};
+            if(reg.reference && reg.status === 'SUCCESS'){                
+                teiId = reg.reference;                
                 //registration is successful and check for enrollment
                 if($scope.selectedProgramForRelative){    
                     //enroll TEI
@@ -647,12 +645,13 @@
                                 dateOfEnrollment: DateUtils.formatFromUserToApi($scope.enrollment.enrollmentDate),
                                 dateOfIncident: $scope.enrollment.incidentDate === '' ? DateUtils.formatFromUserToApi($scope.enrollment.enrollmentDate) : DateUtils.formatFromUserToApi($scope.enrollment.incidentDate)
                             };
-                    EnrollmentService.enroll(enrollment).then(function(data){
-                        if(data.status !== 'SUCCESS'){
+                    EnrollmentService.enroll(enrollment).then(function(enrollmentResponse){
+                        var en = enrollmentResponse.response && enrollmentResponse.response.importSummaries && enrollmentResponse.response.importSummaries[0] ? enrollmentResponse.response.importSummaries[0] : {};
+                        if(en.reference && en.status === 'SUCCESS'){
                             //enrollment has failed
                             var dialogOptions = {
                                     headerText: 'enrollment_error',
-                                    bodyText: data.description
+                                    bodyText: enrollmentResponse.message
                                 };
                             DialogService.showDialog({}, dialogOptions);
                             return;
@@ -664,7 +663,7 @@
                 //registration has failed
                 var dialogOptions = {
                         headerText: 'registration_error',
-                        bodyText: tei.description
+                        bodyText: registrationResponse.message
                     };
                 DialogService.showDialog({}, dialogOptions);
                 return;