← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 19673: event-capture: use the new webmessage api response

 

------------------------------------------------------------
revno: 19673
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2015-07-17 09:28:57 +0200
message:
  event-capture: use the new webmessage api response
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.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-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-07-02 07:19:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-07-17 07:28:57 +0000
@@ -563,10 +563,10 @@
         
         //send the new event to server
         DHIS2EventFactory.create(dhis2Event).then(function(data) {
-            if (data.importSummaries[0].status === 'ERROR') {
+            if (data.response.importSummaries[0].status === 'ERROR') {
                 var dialogOptions = {
                     headerText: 'event_registration_error',
-                    bodyText: data.importSummaries[0].description
+                    bodyText: data.message
                 };
 
                 DialogService.showDialog({}, dialogOptions);
@@ -574,7 +574,7 @@
             else {
                 
                 //add the new event to the grid                
-                newEvent.event = data.importSummaries[0].reference;                
+                newEvent.event = data.response.importSummaries[0].reference;                
                 if( !$scope.dhis2Events ){
                     $scope.dhis2Events = [];                   
                 }

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-07-13 07:37:11 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-07-17 07:28:57 +0000
@@ -350,7 +350,6 @@
                 var p = d.promise();
                 dhis2.ec.store.get('programStages', program.programStages[0].id).done(function(obj) {
                     if(!obj || obj.version !== program.programStages[0].version) {
-                        //promise = promise.then( getProgramStage( program.programStages[0].id ) );
                         promise = promise.then( getD2Object( program.programStages[0].id, 'programStages', '../api/programStages', 'fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,preGenerateUID,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,sortOrder,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,name,type,optionSetValue,numberType,textType,formName,optionSet[id]]]', 'idb' ) );
                     }
 
@@ -377,20 +376,6 @@
     return mainPromise;    
 }
 
-/*function getProgramStage( id )
-{
-    return function() {
-        return $.ajax( {
-            url: '../api/programStages.json?filter=id:eq:' + id +'&fields=id,name,version,description,reportDateDescription,captureCoordinates,dataEntryForm,minDaysFromStart,repeatable,preGenerateUID,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,sortOrder,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,name,type,optionSetValue,numberType,textType,formName,optionSet[id]]]',
-            type: 'GET'
-        }).done( function( response ){            
-            _.each( _.values( response.programStages ), function( programStage ) {                
-                dhis2.ec.store.set( 'programStages', programStage );
-            });
-        });
-    };
-}*/
-
 function getOptionSets( programs )
 {
     if( !programs ){
@@ -417,7 +402,6 @@
                         dhis2.ec.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {
                             if( (!obj || obj.version !== prStDe.dataElement.optionSet.version) && optionSetsInPromise.indexOf(prStDe.dataElement.optionSet.id) === -1) {
                                 optionSetsInPromise.push( prStDe.dataElement.optionSet.id );
-                                //promise = promise.then( getOptionSet( prStDe.dataElement.optionSet.id ) );
                                 promise = promise.then( getD2Object( prStDe.dataElement.optionSet.id, 'optionSets', '../api/optionSets', 'fields=id,name,version,options[id,name,code]', 'idb' ) );
                             }
                             d.resolve();
@@ -445,20 +429,6 @@
     return mainPromise;    
 }
 
-/*function getOptionSet( id )
-{
-    return function() {
-        return $.ajax( {
-            url: '../api/optionSets.json?filter=id:eq:' + id +'&fields=id,name,version,options[id,name,code]',
-            type: 'GET'
-        }).done( function( response ){            
-            _.each( _.values( response.optionSets ), function( optionSet ) {                
-                dhis2.ec.store.set( 'optionSets', optionSet );
-            });
-        });
-    };
-}*/
-
 function getMetaProgramValidations( programs )
 {    
     return getD2MetaObject(programs, 'programValidations', '../api/programValidations.json', 'paging=false&fields=id,program[id]');