← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21642: Added button for completing and exiting the TEI dashbaord

 

------------------------------------------------------------
revno: 21642
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2016-01-07 11:59:31 +0100
message:
  Added button for completing and exiting the TEI dashbaord
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-buttons.html
  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/i18n/i18n_app.properties
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties


--
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-buttons.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-buttons.html	2015-12-21 13:28:07 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-buttons.html	2016-01-07 10:59:31 +0000
@@ -1,11 +1,11 @@
 <!-- data entry/event buttons begins -->                
 <div class="form-group hideInPrint" ng-if="displayCustomForm !== 'TABLE'">
     <div class='row'><hr></div>
-    <a href ng-click="completeIncompleteEvent()" 
+    <a href ng-click="completeIncompleteEvent(null, outerForm)" 
        class="btn btn-warning" 
        ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
        ng-if="currentEvent.eventDate && (currentEvent.status === 'SCHEDULE' || currentEvent.status === 'ACTIVE' || currentEvent.status === 'VISITED')">{{'complete'| translate}}</a>
-    <a href ng-click="completeIncompleteEvent()" 
+    <a href ng-click="completeIncompleteEvent(null, outerForm)" 
        class="btn btn-warning"
        ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.status !== 'COMPLETED' || currentEvent.orgUnit !== selectedOrgUnit.id"
        ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>    

=== 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	2016-01-01 19:29:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-01-07 10:59:31 +0000
@@ -24,7 +24,7 @@
                 PeriodService,
                 TrackerRulesFactory,
                 EventCreationService,
-                $q) {
+                $q,$location) {
 
     $scope.printForm = false;
     $scope.printEmptyForm = false;
@@ -1346,9 +1346,10 @@
         return dhis2EventToUpdate;
     };
     
-    $scope.completeIncompleteEvent = function (inTableView) {
+    $scope.completeIncompleteEvent = function (inTableView, outerForm) {
             
         var modalOptions;
+        var modalDefaults = {};
         var dhis2Event = $scope.makeDhis2EventToUpdate();        
         
         if ($scope.currentEvent.status === 'COMPLETED') {//activiate event
@@ -1362,10 +1363,13 @@
         }
         else {//complete event
                 if(angular.isUndefined(inTableView) || inTableView === false){
-                $scope.outerForm.$setSubmitted();
-                if($scope.outerForm.$invalid){
-                    return;
-                }
+                    if(!outerForm){
+                        outerForm = $scope.outerForm;
+                    }
+                    outerForm.$setSubmitted();
+                    if(outerForm.$invalid){
+                        return;
+                    }
             }
             
             if(angular.isDefined($scope.errorMessages[$scope.currentEvent.event]) && $scope.errorMessages[$scope.currentEvent.event].length > 0) {
@@ -1385,65 +1389,75 @@
                 modalOptions = {
                     closeButtonText: 'cancel',
                     actionButtonText: 'complete',
+                    secondActionButtonText: 'complete_and_exit',
                     headerText: 'complete',
-                    bodyText: 'are_you_sure_to_complete_event'
+                    bodyText: 'are_you_sure_to_complete_event',
                 };
+                modalDefaults.templateUrl = 'components/dataentry/modal-complete-event.html';
                 dhis2Event.status = 'COMPLETED';
             }
         }        
-        
-        ModalService.showModal({}, modalOptions).then(function (result) {            
-            $scope.executeCompleteIncompleteEvent(dhis2Event);
-        });        
+
+        ModalService.showModal(modalDefaults, modalOptions).then(function (result) {
+            var backToDashboard = false;
+            if(result === 'ok-exit'){
+                backToDashboard = true;
+            }
+            $scope.executeCompleteIncompleteEvent(dhis2Event,backToDashboard);
+        });           
     };
     
-    $scope.executeCompleteIncompleteEvent = function(dhis2Event){
+    $scope.executeCompleteIncompleteEvent = function(dhis2Event, backToDashboard){
             
         DHIS2EventFactory.update(dhis2Event).then(function (data) {
-
-            if ($scope.currentEvent.status === 'COMPLETED') {//activiate event                    
-                $scope.currentEvent.status = 'ACTIVE';
-            }
-            else {//complete event                    
-                $scope.currentEvent.status = 'COMPLETED';
-
-            }
-
-            setStatusColor();
-
-            setEventEditing($scope.currentEvent, $scope.currentStage);
-
-            if ($scope.currentEvent.status === 'COMPLETED') {
-
-                if ($scope.currentStage.remindCompleted) {
-                    completeEnrollment($scope.currentStage);
-                }
-                else {
-                    if ($scope.currentStage.allowGenerateNextVisit) {
-                        if($scope.currentStage.repeatable){
-                            $scope.showCreateEvent($scope.currentStage, $scope.eventCreationActions.add);
-                        }
-                        else{
-                            var index = -1, stage = null;
-                            for(var i=0; i<$scope.programStages.length && index===-1; i++){
-                                if($scope.currentStage.id === $scope.programStages[i].id){
-                                    index = i;
-                                    stage = $scope.programStages[i+1];
-                                }
-                            }
-                            if(stage ){
-                                if(!$scope.eventsByStage[stage.id] || $scope.eventsByStage[stage.id] && $scope.eventsByStage[stage.id].length === 0){
-                                    $scope.showCreateEvent(stage, $scope.eventCreationActions.add);
-                                }
-                            }                                
-                        }
-                    }
-                }
-
-                if($scope.displayCustomForm !== "TABLE") {
-                    //Close the event when the event is completed, to make it 
-                    //more clear that the completion went through.
-                    $scope.showDataEntry($scope.currentEvent, false);
+            if(backToDashboard){
+                selection.load();
+                $location.path('/').search({program: $scope.selectedProgramId}); 
+            }else{
+                if ($scope.currentEvent.status === 'COMPLETED') {//activiate event                    
+                    $scope.currentEvent.status = 'ACTIVE';
+                }
+                else {//complete event                    
+                    $scope.currentEvent.status = 'COMPLETED';
+
+                }
+
+                setStatusColor();
+
+                setEventEditing($scope.currentEvent, $scope.currentStage);
+
+                if ($scope.currentEvent.status === 'COMPLETED') {
+
+                    if ($scope.currentStage.remindCompleted) {
+                        completeEnrollment($scope.currentStage);
+                    }
+                    else {
+                        if ($scope.currentStage.allowGenerateNextVisit) {
+                            if($scope.currentStage.repeatable){
+                                $scope.showCreateEvent($scope.currentStage, $scope.eventCreationActions.add);
+                            }
+                            else{
+                                var index = -1, stage = null;
+                                for(var i=0; i<$scope.programStages.length && index===-1; i++){
+                                    if($scope.currentStage.id === $scope.programStages[i].id){
+                                        index = i;
+                                        stage = $scope.programStages[i+1];
+                                    }
+                                }
+                                if(stage ){
+                                    if(!$scope.eventsByStage[stage.id] || $scope.eventsByStage[stage.id] && $scope.eventsByStage[stage.id].length === 0){
+                                        $scope.showCreateEvent(stage, $scope.eventCreationActions.add);
+                                    }
+                                }                                
+                            }
+                        }
+                    }
+
+                    if($scope.displayCustomForm !== "TABLE") {
+                        //Close the event when the event is completed, to make it 
+                        //more clear that the completion went through.
+                        $scope.showDataEntry($scope.currentEvent, false);
+                    }
                 }
             }
         });
@@ -1860,5 +1874,5 @@
         for(var key in $scope.eventTableOptions){
             $scope.eventTableOptionsArr[$scope.eventTableOptions[key].sort] = $scope.eventTableOptions[key];
         }
-    }        
+    }   
 });
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2016-01-06 09:00:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2016-01-07 10:59:31 +0000
@@ -395,3 +395,4 @@
 events_today_scheduled=Scheduled
 print_form=Print form
 value_must_be_email=Please enter a valid email address
+complete_and_exit =Complete and exit

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties	2016-01-06 09:00:50 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app_ar.properties	2016-01-07 10:59:31 +0000
@@ -269,3 +269,4 @@
 events_today_skipped = \u062a\u062e\u0637\u064a(\u062c\u0648\u062c\u0644 \u062a\u0631\u062c\u0645\u0629)
 events_today_scheduled = \u0627\u0644\u0645\u0642\u0631\u0631(\u062c\u0648\u062c\u0644 \u062a\u0631\u062c\u0645\u0629)
 value_must_be_email = \u064a\u062c\u0628 \u0623\u0646 \u062a\u0643\u0648\u0646 \u0642\u064a\u0645\u0629 \u0639\u0646\u0648\u0627\u0646 \u0627\u0644\u0628\u0631\u064a\u062f \u0627\u0644\u0625\u0644\u0643\u062a\u0631\u0648\u0646\u064a(\u062c\u0648\u062c\u0644 \u062a\u0631\u062c\u0645\u0629)
+complete_and_exit=\u0643\u0627\u0645\u0644\u0629 \u0648\u0627\u0644\u062e\u0631\u0648\u062c(\u062c\u0648\u062c\u0644 \u062a\u0631\u062c\u0645\u0629)
\ No newline at end of file