← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18755: tracker-capture: program stage settings remindCompleted and blockEntryForm are now respected

 

------------------------------------------------------------
revno: 18755
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2015-03-30 17:34:54 +0200
message:
  tracker-capture: program stage settings remindCompleted and blockEntryForm are now respected
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/dataentry.html
  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/scripts/tracker-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-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-03-30 10:40:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2015-03-30 15:34:54 +0000
@@ -8,6 +8,7 @@
                 EventUtils,
                 orderByFilter,
                 SessionStorageService,
+                EnrollmentService,
                 ProgramStageFactory,
                 DHIS2EventFactory,
                 OptionSetService,
@@ -108,7 +109,7 @@
                             if(dhis2Event.eventDate){
                                 dhis2Event.eventDate = DateUtils.formatFromApiToUser(dhis2Event.eventDate);
                                 dhis2Event.sortingDate = dhis2Event.eventDate;
-                                dhis2Event.editingNotAllowed = dhis2Event.orgUnit !== $scope.selectedOrgUnit.id;
+                                dhis2Event.editingNotAllowed = setEventEditing(dhis2Event, eventStage);
                             }                       
 
                             dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);
@@ -127,6 +128,10 @@
         });          
     };
     
+    var setEventEditing = function(dhis2Event, stage){
+        return dhis2Event.editingNotAllowed = dhis2Event.orgUnit !== $scope.selectedOrgUnit.id || (stage.blockEntryForm && dhis2Event.status === 'COMPLETED');
+    };
+    
     $scope.enableRescheduling = function(){
         $scope.schedulingEnabled = !$scope.schedulingEnabled;
     };
@@ -548,6 +553,21 @@
         return 'form-control';
     };
     
+    var completeEnrollment = function(){
+        var modalOptions = {
+            closeButtonText: 'cancel',
+            actionButtonText: 'complete',
+            headerText: 'complete_enrollment',
+            bodyText: 'would_you_like_to_complete_enrollment'
+        };
+
+        ModalService.showModal({}, modalOptions).then(function(result){            
+            EnrollmentService.complete($scope.selectedEnrollment).then(function(data){                
+                $scope.selectedEnrollment.status = 'COMPLETED';            
+            });
+        });
+    };
+    
     $scope.completeIncompleteEvent = function(){
         var modalOptions;
         var dhis2Event = EventUtils.reconstruct($scope.currentEvent, $scope.currentStage, $scope.optionSets);        
@@ -582,10 +602,21 @@
                 }
                 
                 setStatusColor();
-                
-                if($scope.currentEvent.status === 'COMPLETED' && $scope.currentStage.allowGenerateNextVisit){
-                    $scope.showCreateEvent($scope.currentStage);
-                }
+                sortEventsByStage();
+                
+                setEventEditing($scope.currentEvent, $scope.currentStage);
+                
+                if($scope.currentEvent.status === 'COMPLETED'){
+                    
+                    if($scope.currentStage.remindCompleted){
+                        completeEnrollment($scope.currentStage);
+                    }
+                    else{
+                        if($scope.currentStage.allowGenerateNextVisit){
+                            $scope.showCreateEvent($scope.currentStage);
+                        }
+                    }
+                }                
             });
         });
     };
@@ -624,7 +655,9 @@
                     $scope.currentEvent.status = 'SKIPPED';
                 }
                 
-                setStatusColor();                
+                setStatusColor();
+                setEventEditing($scope.currentEvent, $scope.currentStage);
+                sortEventsByStage();
             });
         });
     };

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-03-30 13:21:20 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2015-03-30 15:34:54 +0000
@@ -153,22 +153,22 @@
                     <div class='row'><hr></div>
                     <a href ng-click="completeIncompleteEvent()" 
                        class="btn btn-warning" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed"
+                       ng-disabled="currentEvent.enrollmentStatus !== '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()" 
                        class="btn btn-warning"
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed"
+                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.orgUnit !== selectedOrgUnit.id"
                        ng-if="currentEvent.eventDate && currentEvent.status === 'COMPLETED'">{{'incomplete'| translate}}</a>                       
                     <a href ng-click="validateEvent()" 
                        class="btn btn-info" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed" 
+                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.orgUnit !== selectedOrgUnit.id" 
                        ng-if="currentEvent.eventDate">{{'validate'| translate}}</a>                        
                     <a href ng-click="skipUnskipEvent()" 
                        class="btn btn-warning" 
-                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed"
+                       ng-disabled="currentEvent.enrollmentStatus !== 'ACTIVE' || currentEvent.editingNotAllowed && currentEvent.orgUnit !== selectedOrgUnit.id"
                        ng-if="!currentEvent.eventDate">{{currentEvent.status === 'SKIPPED' ? 'unskip' : 'skip'| translate}}</a>
                     <a href ng-click="deleteEvent()" 
-                       ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED' || currentEvent.editingNotAllowed"
+                       ng-disabled="currentEvent.enrollmentStatus === 'COMPLETED' || currentEvent.editingNotAllowed && currentEvent.orgUnit !== selectedOrgUnit.id"
                        class="btn btn-danger">{{'delete'| translate}}</a>
                 </div>
                 <!-- data entry/event buttons ends -->

=== 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	2015-03-26 14:59:40 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/i18n_app.properties	2015-03-30 15:34:54 +0000
@@ -249,6 +249,7 @@
 cancel=Cancel
 are_you_sure_to_delete_relationship=Are you sure you want to delete the relationship?
 are_you_sure_to_delete_enrollment=Are you sure you want to delete the selected enrollment?
+would_you_like_to_complete_enrollment=Would you like to complete the current enrollment?
 are_you_sure_to_complete_enrollment=Are you sure you want to complete the selected enrollment?
 are_you_sure_to_terminate_enrollment=Are you sure you want to terminate the selected enrollment?
 are_you_sure_to_delete_event=Are you sure you want to delete the selected event?

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-03-30 10:40:41 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/tracker-capture.js	2015-03-30 15:34:54 +0000
@@ -407,7 +407,7 @@
         return $.ajax( {
             url: '../api/programStages.json',
             type: 'GET',
-            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,allowGenerateNextVisit,generatedByEnrollmentDate,reportDateDescription,minDaysFromStart,repeatable,openAfterEnrollment,standardInterval,periodType,reportDateToUse,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
+            data: 'filter=id:eq:' + id +'&fields=id,name,sortOrder,version,dataEntryForm,captureCoordinates,blockEntryForm,autoGenerateEvent,allowGenerateNextVisit,generatedByEnrollmentDate,remindCompleted,reportDateDescription,minDaysFromStart,repeatable,openAfterEnrollment,standardInterval,periodType,reportDateToUse,programStageSections[id,name,programStageDataElements[dataElement[id]]],programStageDataElements[displayInReports,allowProvidedElsewhere,allowFutureDate,compulsory,dataElement[id,code,name,formName,type,optionSet[id]]]'
         }).done( function( response ){            
             _.each( _.values( response.programStages ), function( programStage ) {
                 dhis2.tc.store.set( 'programStages', programStage );