← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21113: event-capture: check if program is configured for skip offline

 

------------------------------------------------------------
revno: 21113
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-11-18 17:35:26 +0100
message:
  event-capture: check if program is configured for skip offline
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties
  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/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties	2015-11-16 15:48:46 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/i18n/i18n_app.properties	2015-11-18 16:35:26 +0000
@@ -149,4 +149,6 @@
 show_main_menu=Show main menu
 close_editing=Close editing
 fill_all_category_options=Please fill all category options
-custom_form_has_invalid_dataelement=Custom form has invalid data element.
\ No newline at end of file
+custom_form_has_invalid_dataelement=Custom form has invalid data element.
+offline=Offline
+program_is_skip_offline=You are currently offline. But program is configured to be skipped during offline.
\ No newline at end of file

=== 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-11-17 10:32:17 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2015-11-18 16:35:26 +0000
@@ -116,6 +116,18 @@
         }        
     });
     
+    function checkSkipOffline() {
+        if(dhis2.ec.isOffline && $scope.selectedProgram && $scope.selectedProgram.skipOffline){
+            var dialogOptions = {
+                headerText: 'offline',
+                bodyText: 'program_is_skip_offline'
+            };
+
+            DialogService.showDialog({}, dialogOptions);
+            return;
+        }
+    }
+    
     //load programs associated with the selected org unit.
     $scope.loadPrograms = function() {
         
@@ -135,8 +147,7 @@
         $scope.currentGridColumnId = '';           
         $scope.displayCustomForm = false;
         
-        if (angular.isObject($scope.selectedOrgUnit)) {    
-            
+        if (angular.isObject($scope.selectedOrgUnit)) {
             ProgramFactory.getProgramsByOu($scope.selectedOrgUnit, $scope.selectedProgram).then(function(response){
                 $scope.programs = response.programs;
                 $scope.selectedProgram = response.selectedProgram;
@@ -156,6 +167,8 @@
         $scope.sortHeader = {};
         $scope.filterText = {};
         
+        checkSkipOffline();
+        
         if( $scope.userAuthority && $scope.userAuthority.canAddOrUpdateEvent &&
                 $scope.selectedProgram && 
                 $scope.selectedProgram.programStages && 
@@ -271,6 +284,8 @@
     //get events for the selected program (and org unit)
     $scope.loadEvents = function(){   
         
+        checkSkipOffline();
+        
         $scope.noteExists = false;            
         $scope.dhis2Events = [];
         $scope.eventLength = 0;
@@ -285,7 +300,7 @@
                 };
 
                 DialogService.showDialog({}, dialogOptions);
-                return false;
+                return;
             }            
             attributeCategoryUrl.cp = $scope.selectedOptions.join(';');
         }
@@ -546,6 +561,8 @@
     
     $scope.addEvent = function(addingAnotherEvent){                
         
+        checkSkipOffline();
+        
         //check for form validity
         $scope.outerForm.submitted = true;        
         if( $scope.outerForm.$invalid ){
@@ -553,7 +570,7 @@
             angular.forEach($scope.selectedProgramStage.programStageSections, function(section){
                 section.open = true;
             });
-            return false;
+            return;
         }
         
         //the form is valid, get the values
@@ -577,7 +594,7 @@
             };
 
             DialogService.showDialog({}, dialogOptions);
-            return false;
+            return;
         }        
         
         if(addingAnotherEvent){
@@ -621,7 +638,7 @@
                 };
 
                 DialogService.showDialog({}, dialogOptions);
-                return false;
+                return;
             }
             
             //dhis2Event.attributeCc = $scope.selectedProgram.categoryCombo.id;
@@ -676,6 +693,8 @@
     
     $scope.updateEvent = function(){
         
+        checkSkipOffline();
+        
         //check for form validity
         $scope.outerForm.submitted = true;        
         if( $scope.outerForm.$invalid ){
@@ -683,7 +702,7 @@
             angular.forEach($scope.selectedProgramStage.programStageSections, function(section){
                 section.open = true;
             });
-            return false;
+            return;
         }
         
         //the form is valid, get the values
@@ -735,6 +754,9 @@
     };
     
     $scope.updateEventDate = function () {
+        
+        checkSkipOffline();
+        
         $scope.updateSuccess = false;
         
         $scope.currentElement = {id: 'eventDate'};
@@ -747,7 +769,7 @@
             $scope.currentEvent.eventDate = $scope.currentEventOriginialValue.eventDate;            
             $scope.resetEventValue($scope.currentEvent);
             $scope.currentElement.updated = false;
-            return false;
+            return;
         }
 
         //get new and old values
@@ -758,7 +780,7 @@
             $scope.currentEvent.eventDate = oldValue;            
             $scope.resetEventValue($scope.currentEvent);
             $scope.currentElement.updated = false;
-            return false;
+            return;
         }
         
         if(newValue !== oldValue){
@@ -783,6 +805,9 @@
     };
             
     $scope.updateEventDataValue = function(currentEvent, dataElement){
+        
+        checkSkipOffline();
+        
         $scope.updateSuccess = false;
         
         //get current element

=== 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-10-30 15:13:52 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-11-18 16:35:26 +0000
@@ -20,6 +20,7 @@
 var EVENT_VALUES = 'EVENT_VALUES';
 var optionSetsInPromise = [];
 
+dhis2.ec.isOffline = false;
 dhis2.ec.store = null;
 dhis2.ec.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
 var adapters = [];    
@@ -67,6 +68,8 @@
 {
     if (loggedIn)
     {   
+        dhis2.ec.isOffline = false;
+        
         var OfflineECStorageService = angular.element('body').injector().get('OfflineECStorageService');
 
         OfflineECStorageService.hasLocalData().then(function(localData){
@@ -111,6 +114,7 @@
         setHeaderMessage(i18n_no_orgunits);
     }
     else {
+        dhis2.ec.isOffline = true;
         setHeaderMessage(i18n_offline_notification);
     }
 });
@@ -241,7 +245,7 @@
     $.ajax({
         url: '../api/programs.json',
         type: 'GET',
-        data:'filter=programType:eq:WITHOUT_REGISTRATION&paging=false&fields=id,name,version,categoryCombo[id,isDefault,categories[id,categoryOptions[id]]],programStages[id,version,programStageSections[id],programStageDataElements[dataElement[id,optionSet[id,version]]]]'
+        data:'filter=programType:eq:WITHOUT_REGISTRATION&paging=false&fields=id,version,categoryCombo[id,isDefault,categories[id,categoryOptions[id]]],programStages[id,version,programStageSections[id],programStageDataElements[dataElement[id,optionSet[id,version]]]]'
     }).done( function(response) {        
         def.resolve( response.programs ? response.programs: [] );
     }).fail(function(){
@@ -306,7 +310,7 @@
         return $.ajax( {
             url: '../api/programs/' + id + '.json',
             type: 'GET',
-            data: 'fields=id,name,programType,version,dataEntryMethod,enrollmentDateLabel,incidentDateLabel,displayIncidentDate,ignoreOverdueEvents,categoryCombo[id,isDefault,categories[id]],organisationUnits[id,name],programStages[id,name,version],userRoles[id,name]'
+            data: 'fields=id,name,programType,version,dataEntryMethod,skipOffline,enrollmentDateLabel,incidentDateLabel,displayIncidentDate,ignoreOverdueEvents,categoryCombo[id,isDefault,categories[id]],organisationUnits[id,name],programStages[id,name,version],userRoles[id,name]'
         }).done( function( program ){            
             var ou = {};
             _.each(_.values( program.organisationUnits), function(o){