← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16156: tracker capture - menu for event skip or unskip(schedule back)

 

------------------------------------------------------------
revno: 16156
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2014-07-17 14:53:18 +0200
message:
  tracker capture - menu for event skip or unskip(schedule back)
modified:
  dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json
  dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.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-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java'
--- dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2014-07-17 10:35:43 +0000
+++ dhis-2/dhis-services/dhis-service-dxf2/src/main/java/org/hisp/dhis/dxf2/events/event/AbstractEventService.java	2014-07-17 12:53:18 +0000
@@ -394,6 +394,15 @@
                     i18nManager.getI18nFormat() );
             }
         }
+        else if ( event.getStatus() == EventStatus.SKIPPED )
+        {
+            programStageInstance.setStatus( EventStatus.SKIPPED );            
+        }
+        
+        else if ( event.getStatus() == EventStatus.SCHEDULE )
+        {
+            programStageInstance.setStatus( EventStatus.SCHEDULE );            
+        } 
 
         programStageInstance.setDueDate( dueDate );
         programStageInstance.setOrganisationUnit( organisationUnit );

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-07-17 10:35:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-07-17 12:53:18 +0000
@@ -227,17 +227,17 @@
                 $scope.showDummyEventDiv = false;
                 $scope.showEventCreationDiv = false;
                 
-                angular.forEach($scope.currentEvent.notes, function(note){
-                    note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
-                });
-                
-                if($scope.currentEvent.notes.length > 0 ){
-                    $scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');
-                }
-                
-                if($scope.currentEvent.eventDate){
-                    $scope.getDataEntryForm();
-                }
+                if($scope.currentEvent.notes){
+                    angular.forEach($scope.currentEvent.notes, function(note){
+                        note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
+                    });
+
+                    if($scope.currentEvent.notes.length > 0 ){
+                        $scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');
+                    }
+                }
+                
+                $scope.getDataEntryForm();
             }               
         }
     }; 
@@ -251,7 +251,9 @@
         $scope.currentEvent.providedElsewhere = [];
 
         $scope.currentEvent.dueDate = DateUtils.format($scope.currentEvent.dueDate);
-        $scope.currentEvent.eventDate = DateUtils.format($scope.currentEvent.eventDate);
+        if($scope.currentEvent.eventDate){
+            $scope.currentEvent.eventDate = DateUtils.format($scope.currentEvent.eventDate);
+        }        
 
         if(!angular.isUndefined( $scope.currentEvent.notes)){
             $scope.currentEvent.notes = orderByFilter($scope.currentEvent.notes, '-storedDate');            
@@ -554,6 +556,51 @@
         });
     };
     
+    $scope.skipUnskipEvent = function(){
+        var modalOptions;
+        var dhis2Event = EventUtils.reconstruct($scope.currentEvent, $scope.currentStage);   
+
+        if($scope.currentEvent.status === 'SKIPPED'){//unskip event
+            modalOptions = {
+                closeButtonText: 'cancel',
+                actionButtonText: 'unskip',
+                headerText: 'unskip',
+                bodyText: 'are_you_sure_to_unskip_event'
+            };
+            dhis2Event.status = 'ACTIVE';        
+        }
+        else{//skip event
+            modalOptions = {
+                closeButtonText: 'cancel',
+                actionButtonText: 'skip',
+                headerText: 'skip',
+                bodyText: 'are_you_sure_to_skip_event'
+            };
+            dhis2Event.status = 'SKIPPED';
+        }        
+
+        ModalService.showModal({}, modalOptions).then(function(result){
+            
+            DHIS2EventFactory.update(dhis2Event).then(function(data){
+                
+                if($scope.currentEvent.status === 'SKIPPED'){//activiate event                    
+                    $scope.currentEvent.status = 'SCHEDULE'; 
+                }
+                else{//complete event                    
+                    $scope.currentEvent.status = 'SKIPPED';
+                }
+                var statusColor = EventUtils.getEventStatusColor($scope.currentEvent);  
+                var continueLoop = true;
+                for(var i=0; i< $scope.dhis2Events.length && continueLoop; i++){
+                    if($scope.dhis2Events[i].event === $scope.currentEvent.event ){
+                        $scope.dhis2Events[i].statusColor = statusColor;
+                        continueLoop = false;
+                    }
+                }           
+            });
+        });
+    };
+    
     $scope.validateEvent = function(){};    
     
     $scope.deleteEvent = function(){

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-07-17 10:35:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-07-17 12:53:18 +0000
@@ -143,8 +143,8 @@
                 <div class="btn-group btn-group-justified">
                         <a href ng-click="completeIncompleteEvent()" class="btn btn-warning" ng-if="currentEvent.eventDate && currentEvent.status === 'ACTIVE'">{{'complete'| translate}}</a>
                         <a href ng-click="completeIncompleteEvent()" class="btn btn-warning" ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>                       
-                        <a href ng-click="validateEvent()" class="btn btn-info" ng-disabled="true" ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>
-                        <a href ng-click="skipEvent()" class="btn btn-warning" ng-if="!currentEvent.eventDate">{{'skipped'| translate}}</a>               
+                        <a href ng-click="validateEvent()" class="btn btn-info" ng-disabled="true" ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>                        
+                        <a href ng-click="skipUnskipEvent()" class="btn btn-warning" ng-if="!currentEvent.eventDate">{{currentEvent.status === 'SKIPPED' ? 'unskip' : 'skip' | translate}}</a>
                     <a href ng-click="deleteEvent()" class="btn btn-danger">{{'delete'| translate}}</a>
                 </div>
             </div>

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-07-17 10:35:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-07-17 12:53:18 +0000
@@ -69,6 +69,8 @@
     "search_note": "Search notes",
     "add_your_note_here": "Add your note here",
     "skipped": "Skipped",
+    "skip": "Skip",
+    "unskip": "Schedule back",
     "complete": "Complete",
     "incomplete": "Incomplete",
     "validate": "Validate",
@@ -196,6 +198,8 @@
     "are_you_sure_to_delete_event": "Are you sure you want to delete the selected event?",
     "are_you_sure_to_complete_event": "Are you sure you want to complete the selected event?",
     "are_you_sure_to_incomplete_event": "Are you sure you want to incomplete the selected event?",
+    "are_you_sure_to_skip_event": "Are you sure you want to skip the selected event?",
+    "are_you_sure_to_unskip_event": "Are you sure you want to schedule back the selected event?",
     "more": "More",    
     "advanced_search": "Advanced search",
     "profile": "Profile",

=== modified file 'dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-07-17 10:35:43 +0000
+++ dhis-2/dhis-web/dhis-web-tracker-capture/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2014-07-17 12:53:18 +0000
@@ -1198,7 +1198,8 @@
                     programStage: dhis2Event.programStage, 
                     orgUnit: dhis2Event.orgUnit, 
                     trackedEntityInstance: dhis2Event.trackedEntityInstance,
-                    status: dhis2Event.status
+                    status: dhis2Event.status,
+                    dueDate: dhis2Event.dueDate
                 };
                 
             angular.forEach(programStage.programStageDataElements, function(prStDe){