← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16604: tracker capture - scheduling and messaging, WIP

 

------------------------------------------------------------
revno: 16604
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-09-01 17:32:05 +0200
message:
  tracker capture - scheduling and messaging, WIP
added:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js
  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/en.json
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html


--
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/dashboard/dashboard-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js	2014-07-18 16:47:49 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dashboard/dashboard-controller.js	2014-09-01 15:32:05 +0000
@@ -24,6 +24,7 @@
     $rootScope.selectedWidget = {title: 'current_selections', view: "components/selected/selected.html", show: false, expand: true};
     $rootScope.profileWidget = {title: 'profile', view: "components/profile/profile.html", show: true, expand: true};
     $rootScope.relationshipWidget = {title: 'relationships', view: "components/relationship/relationship.html", show: true, expand: true};
+    $rootScope.schedulingMessagingWidget = {title: 'scheduling_messaging', view: "components/scheduling-messaging/scheduling-messaging.html", show: true, expand: true};
     $rootScope.notesWidget = {title: 'notes', view: "components/notes/notes.html", show: true, expand: true};    
    
     $rootScope.biggerDashboardWidgets.push($rootScope.enrollmentWidget);
@@ -32,6 +33,7 @@
     $rootScope.smallerDashboardWidgets.push($rootScope.selectedWidget);
     $rootScope.smallerDashboardWidgets.push($rootScope.profileWidget);
     $rootScope.smallerDashboardWidgets.push($rootScope.relationshipWidget);
+    $rootScope.smallerDashboardWidgets.push($rootScope.schedulingMessagingWidget);
     $rootScope.smallerDashboardWidgets.push($rootScope.notesWidget);
     
     //selections  

=== 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	2014-07-17 12:53:18 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2014-09-01 15:32:05 +0000
@@ -390,7 +390,7 @@
             var e = {event: $scope.currentEvent.event,
                  enrollment: $scope.currentEvent.enrollment,
                  dueDate: $scope.currentEvent.dueDate,
-                 status: $scope.currentEvent.status === 'SCHEDULE' ? 'ACTIVE' : $scope.currentEvent.status,
+                 status: $scope.currentEvent.status == 'SCHEDULE' ? 'ACTIVE' : $scope.currentEvent.status,
                  program: $scope.currentEvent.program,
                  programStage: $scope.currentEvent.programStage,
                  orgUnit: $scope.currentEvent.orgUnit,
@@ -408,6 +408,7 @@
                 for(var i=0; i< $scope.dhis2Events.length && continueLoop; i++){
                     if($scope.dhis2Events[i].event === $scope.currentEvent.event ){
                         $scope.dhis2Events[i].statusColor = statusColor;
+                        $scope.dhis2Events[i].status = e.status;
                         continueLoop = false;
                     }
                 }

=== 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	2014-08-25 15:28:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry.html	2014-09-01 15:32:05 +0000
@@ -26,7 +26,7 @@
                                 {{dhis2Event.name}}<br/>
                                 {{dhis2Event.sortingDate}}         
                             </span>
-                            <i class="fa fa-arrow-right" ng-show="$index < dhis2Events.length - 1"></i>
+                            <i class="fa fa-arrow-right" ng-if="$index < dhis2Events.length - 1"></i>
                         </td>                        
                     </tr>
                 </tbody>                
@@ -47,7 +47,7 @@
                                 {{dummyEvent.name}}<br/>
                                 {{dummyEvent.dueDate}}         
                             </span>
-                            <i class="fa fa-arrow-right" ng-show="$index < dummyEvents.length - 1"></i>
+                            <i class="fa fa-arrow-right" ng-if="$index < dummyEvents.length - 1"></i>
                         </td>                        
                     </tr>                        
                 </tbody>                
@@ -57,12 +57,12 @@
                     <div class="col-md-6">
                         {{currentDummyEvent.reportDateDescription}}
                         <input type="text" placeholder="yyyy-mm-dd" name="eventDate" class="form-control" ng-date ng-model="currentDummyEvent.eventDate" ng-required="false"/>
-                        <span ng-show="eventCreationForm.submitted && eventCreationForm.eventDate.$invalid" class="error">{{'required'| translate}}</span>
+                        <span ng-if="eventCreationForm.submitted && eventCreationForm.eventDate.$invalid" class="error">{{'required'| translate}}</span>
                     </div>
                     <div class="col-md-6">
                         {{'due_date'| translate}}
                         <input type="text" placeholder="yyyy-mm-dd" name="dueDate" class="form-control" ng-date ng-model="currentDummyEvent.dueDate" ng-required="true"/>
-                        <span ng-show="eventCreationForm.submitted && eventCreationForm.dueDate.$invalid" class="error">{{'required'| translate}}</span>
+                        <span ng-if="eventCreationForm.submitted && eventCreationForm.dueDate.$invalid" class="error">{{'required'| translate}}</span>
                     </div>                        
                 </div>
                 <div class="row vertical-spacing">   
@@ -74,7 +74,7 @@
             </form>            
         </div>        
 
-        <div ng-show="currentEvent && !showEventCreationDiv">
+        <div ng-if="currentEvent && !showEventCreationDiv">
             <div class="row">
                 <div class="col-md-6">
                     {{currentEvent.reportDateDescription}}
@@ -87,7 +87,7 @@
                            ng-model="currentEvent.eventDate" 
                            ng-required="true" 
                            blur-or-change="saveEventDate()"/>
-                    <span ng-show="invalidDate" class="error">{{'date_required'| translate}}</span>     
+                    <span ng-if="invalidDate" class="error">{{'date_required'| translate}}</span>     
                 </div>
                 <div class="col-md-6">
                     {{'due_date'| translate}}
@@ -102,7 +102,7 @@
                            ng-disabled="currentEvent.eventDate"/>
                 </div>                        
             </div>
-            <div ng-show="currentEvent.eventDate">
+            <div ng-if="currentEvent.eventDate">
             
                 <div class='row'><hr></div>
                 <div class='col-md-12' ng-if="customForm">

=== added directory 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging'
=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging-controller.js	2014-09-01 15:32:05 +0000
@@ -0,0 +1,122 @@
+trackerCapture.controller('SchedulingMessagingController',
+        function($scope,                
+                storage,
+                DateUtils,
+                EventUtils,
+                DHIS2EventFactory,
+                EnrollmentService,
+                CurrentSelection,
+                orderByFilter,
+                TranslationService) {
+
+    TranslationService.translate();
+    
+    var loginDetails = storage.get('LOGIN_DETAILS');
+    var storedBy = '';
+    if(loginDetails){
+        storedBy = loginDetails.userCredentials.username;
+    }
+    
+    var today = DateUtils.format(moment());
+    
+    $scope.$on('dashboardWidgets', function(event, args) {
+        var selections = CurrentSelection.get();          
+        $scope.selectedOrgUnit = storage.get('SELECTED_OU');        
+        $scope.selectedEntity = selections.tei;      
+        $scope.selectedProgram = selections.pr;        
+        $scope.selectedEnrollment = selections.enrollment;   
+        $scope.selectedProgramWithStage = [];
+        
+        if($scope.selectedOrgUnit && 
+                $scope.selectedProgram && 
+                $scope.selectedEntity && 
+                $scope.selectedEnrollment){
+            
+            angular.forEach($scope.selectedProgram.programStages, function(stage){
+                $scope.selectedProgramWithStage[stage.id] = stage;
+            });
+
+            /*EnrollmentService.get(selections.enrollment.enrollment).then(function(data){    
+                $scope.selectedEnrollment = data;   
+                if(!angular.isUndefined( $scope.selectedEnrollment.notes)){
+                    $scope.selectedEnrollment.notes = orderByFilter($scope.selectedEnrollment.notes, '-storedDate');            
+                    angular.forEach($scope.selectedEnrollment.notes, function(note){
+                        note.storedDate = moment(note.storedDate).format('YYYY-MM-DD @ hh:mm A');
+                    });
+                }
+            });*/
+            $scope.dhis2Events = '';
+            DHIS2EventFactory.getEventsByStatus($scope.selectedEntity.trackedEntityInstance, $scope.selectedOrgUnit.id, $scope.selectedProgram.id, 'ACTIVE').then(function(data){
+                $scope.dhis2Events = data;
+                if(angular.isObject($scope.dhis2Events)){
+                    angular.forEach($scope.dhis2Events, function(dhis2Event){
+
+                        if(dhis2Event.enrollment === $scope.selectedEnrollment.enrollment){
+                            var eventStage = $scope.selectedProgramWithStage[dhis2Event.programStage];
+                            if(angular.isObject(eventStage)){
+
+                                dhis2Event.name = eventStage.name; 
+                                dhis2Event.reportDateDescription = eventStage.reportDateDescription;
+                                dhis2Event.dueDate = DateUtils.format(dhis2Event.dueDate);
+
+                                if(dhis2Event.eventDate){
+                                    dhis2Event.eventDate = DateUtils.format(dhis2Event.eventDate);
+                                    dhis2Event.sortingDate = DateUtils.format(dhis2Event.eventDate);
+                                }
+                                else{
+                                    dhis2Event.sortingDate = dhis2Event.dueDate;
+                                }                       
+
+                                dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);  
+                                dhis2Event = EventUtils.setEventOrgUnitName(dhis2Event);
+                            } 
+                        }
+                    });
+                }
+            });
+        }
+    });
+    
+    $scope.saveDueDate = function(){
+        $scope.dueDateSaved = false;
+
+        if($scope.currentEvent.dueDate == ''){
+            $scope.invalidDate = true;
+            return false;
+        }
+        else{
+            var rawDate = $filter('date')($scope.currentEvent.dueDate, 'yyyy-MM-dd'); 
+            var convertedDate = moment($scope.currentEvent.dueDate, 'YYYY-MM-DD')._d;
+            convertedDate = $filter('date')(convertedDate, 'yyyy-MM-dd'); 
+
+            if(rawDate !== convertedDate){
+                $scope.invalidDate = true;
+                return false;
+            } 
+
+            var e = {event: $scope.currentEvent.event,
+                 enrollment: $scope.currentEvent.enrollment,
+                 dueDate: $scope.currentEvent.dueDate,
+                 status: $scope.currentEvent.status,
+                 program: $scope.currentEvent.program,
+                 programStage: $scope.currentEvent.programStage,
+                 orgUnit: $scope.currentEvent.orgUnit,
+                 trackedEntityInstance: $scope.currentEvent.trackedEntityInstance
+                };
+
+            DHIS2EventFactory.update(e).then(function(data){            
+                $scope.invalidDate = false;
+                $scope.dueDateSaved = true;
+                $scope.currentEvent.sortingDate = $scope.currentEvent.dueDate;                
+                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;
+                    }
+                } 
+            });
+        }              
+    };
+});
\ No newline at end of file

=== added file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html	1970-01-01 00:00:00 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/scheduling-messaging/scheduling-messaging.html	2014-09-01 15:32:05 +0000
@@ -0,0 +1,15 @@
+<div class="panel panel-default" ng-controller="SchedulingMessagingController">
+    <div class="panel-heading handle bold">
+        {{schedulingMessagingWidget.title| translate}}
+        <span class="pull-right">
+            <a class="small-horizonal-spacing" href ng-click="expandCollapse(schedulingMessagingWidget)">
+                <span ng-show="schedulingMessagingWidget.expand"><i class="fa fa-chevron-up" title="{{'collapse'| translate}}"></i></span>
+                <span ng-show="!schedulingMessagingWidget.expand"><i class="fa fa-chevron-down" title="{{'expand'| translate}}"></i></span>
+            </a>
+            <a class="small-horizonal-spacing" href ng-click="removeWidget(schedulingMessagingWidget)" title="{{'remove'| translate}}"><i class="fa fa-times-circle"></i></a>            
+        </span>        
+    </div>    
+    <div ng-show="schedulingMessagingWidget.expand" class="panel-body dashboard-element-container">        
+        <div ng-show="!selectedEnrollment" class="alert alert-warning">{{'not_yet_enrolled_scheduling'| translate}}</div>
+    </div>
+</div>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-09-01 13:04:19 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/i18n/en.json	2014-09-01 15:32:05 +0000
@@ -165,6 +165,8 @@
     "scheduling": "Scheduling",
     "reschedule": "Reschedule",
     "rescheduling": "Rescheduling",
+    "scheduling_messaging": "Scheduling and Messaging",
+    "not_yet_enrolled_scheduling": "Not yet enrolled. Scheduling not possible.",
     "schedule_details": "Schedule details",
     "enroll": "Enroll",
     "new_enrollment": "New enrollment",

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html	2014-08-27 15:40:36 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/index.html	2014-09-01 15:32:05 +0000
@@ -79,8 +79,9 @@
         <script type="text/javascript" src="components/report/overdue-events-controller.js"></script>
         <script type="text/javascript" src="components/report/upcoming-events-controller.js"></script>
         <script type="text/javascript" src="components/selected/selected-controller.js"></script>
-        <script type="text/javascript" src="components/relationship/relationship-controller.js"></script>
+        <script type="text/javascript" src="components/relationship/relationship-controller.js"></script>        
         <script type="text/javascript" src="components/profile/profile-controller.js"></script>
+        <script type="text/javascript" src="components/scheduling-messaging/scheduling-messaging-controller.js"></script>
         <script type="text/javascript" src="components/notes/notes-controller.js"></script>
 
         <!-- Menu scripts -->