← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21664: Some minor fixes and cleanup

 

------------------------------------------------------------
revno: 21664
committer: Markus Bekken <markus.bekken@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2016-01-08 14:43:59 +0100
message:
  Some minor fixes and cleanup
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/components/dataentry/default-form.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-layout.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.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-buttons.html'
--- 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
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-buttons.html	2016-01-08 13:43:59 +0000
@@ -16,7 +16,7 @@
     <a href ng-click="deleteEvent()" 
        ng-disabled="selectedEnrollment.status === 'COMPLETED' || currentEvent.editingNotAllowed || currentEvent.orgUnit !== selectedOrgUnit.id"
        class="btn btn-danger">{{'delete'| translate}}</a>
-    <a href ng-click="showCreateEvent(currentStage)" 
+    <a href ng-click="showCreateEvent(null, eventCreationActions.add, currentStage)" 
        ng-if="stageNeedsEvent(currentStage) && selectedEnrollment.status === 'ACTIVE'"
        class="btn btn-primary">{{'add_new_event'| translate}}</a>    
     <a href class="btn btn-info" ng-click="print('print-div');">{{'print_form'| 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-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-01-08 13:43:59 +0000
@@ -547,11 +547,11 @@
         sortEventsByStage('ADD', newEvent);
     };
 
-    $scope.showCreateEvent = function (stage, eventCreationAction) {        
+    $scope.showCreateEvent = function (stage, eventCreationAction, suggestedStage) {        
         
         var availableStages = [];
         if(!stage){
-            if(!$scope.allEventsSorted || $scope.allEventsSorted.length === 0){                
+            if(!$scope.allEventsSorted || $scope.allEventsSorted.length === 0){                               
                 availableStages = $scope.programStages;
             }
             else{
@@ -610,6 +610,9 @@
                 },
                 events: function(){
                     return $scope.allEventsSorted;
+                },
+                suggestedStage: function(){
+                    return suggestedStage;
                 }
             }
         });
@@ -1459,7 +1462,7 @@
                     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';
@@ -1826,20 +1829,22 @@
     };   
     
     $scope.getEventPageForEvent = function(event){
-        var index = -1;
-        for(i = 0; i < $scope.allEventsSorted.length; i++){
-            if(event.event === $scope.allEventsSorted[i].event){
-                index = i;
-                break;
-            }
-        }
-        
-        if(index !== -1){
-            var page = Math.floor(index / $scope.eventPageSize);
-            $scope.eventPagingStart = page * $scope.eventPageSize;
-            $scope.eventPagingEnd = $scope.eventPagingStart + $scope.eventPageSize;
-        }
-    }
+        if(angular.isDefined(event) && angular.isObject(event)){
+            var index = -1;
+            for(i = 0; i < $scope.allEventsSorted.length; i++){
+                if(event.event === $scope.allEventsSorted[i].event){
+                    index = i;
+                    break;
+                }
+            }
+
+            if(index !== -1){
+                var page = Math.floor(index / $scope.eventPageSize);
+                $scope.eventPagingStart = page * $scope.eventPageSize;
+                $scope.eventPagingEnd = $scope.eventPagingStart + $scope.eventPageSize;
+            }
+        }        
+    };
 
     $scope.deselectCurrent = function(id){        
         

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2016-01-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2016-01-08 13:43:59 +0000
@@ -18,7 +18,7 @@
                         <span class="glyphicon glyphicon-info-sign" ></span>
                         <span ng-show="showHelpText[prStDe.dataElement.id]" ><br>{{prStDe.dataElement.description}}</span>
                     </a>    
-                    <span ng-if="otherValuesLists[prStDe.dataElement.id] && currentStage.id !== 'PUZaKR0Jh2k'" ng-repeat="altValue in otherValuesLists[prStDe.dataElement.id] track by $index">
+                    <span ng-if="otherValuesLists[prStDe.dataElement.id]" ng-repeat="altValue in otherValuesLists[prStDe.dataElement.id] track by $index">
                         <span class="label label-default">{{altValue | translate}}</span>
                    </span> 
                 </span>                

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-layout.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-layout.html	2016-01-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/event-layout.html	2016-01-08 13:43:59 +0000
@@ -17,7 +17,10 @@
                 &nbsp;<br/>
                 {{'next'| translate}}
             </div>
-        </div>        
+        </div>
+        <div ng-if="allEventsSorted.length < 1">
+            <div class="alert alert-warning">{{'no_events_exist'| translate}}</div> 
+        </div>
     </div>
     <div ng-class="{'col-sm-3': showStageTasks, 'col-xs-6': showStageTasks, 'col-sm-1': !showStageTasks, 'col-xs-2': !showStageTasks}">
         <div ng-if="showStageTasks && eventsLoaded" class="panel panel-info">
@@ -88,10 +91,7 @@
             </div>                 
             -->
         </div>
-    </div>
-    <div ng-if="allEventsSorted.length < 1">
-        <div class="alert alert-warning">{{'no_events_exist'| translate}}</div> 
-    </div>
+    </div>    
 </div>
 
 <hr>
\ No newline at end of file

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js	2016-01-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/new-event-controller.js	2016-01-08 13:43:59 +0000
@@ -21,7 +21,8 @@
                 eventCreationAction,
                 autoCreate,
                 EventUtils,
-                events) {
+                events,
+                suggestedStage) {
     $scope.stages = stages;
     $scope.allStages = allStages;
     $scope.events = events;
@@ -31,7 +32,8 @@
     $scope.isScheduleEvent = (eventCreationAction === $scope.eventCreationActions.schedule || eventCreationAction === $scope.eventCreationActions.referral);
     $scope.isReferralEvent = (eventCreationAction === $scope.eventCreationActions.referral);
     $scope.model = {selectedStage: stage, dueDateInvalid: false, eventDateInvalid: false};
-    $scope.stageSpecifiedOnModalOpen = angular.isObject(stage) ? true : false;    
+    $scope.stageSpecifiedOnModalOpen = angular.isObject(stage) ? true : false;
+    $scope.suggestedStage = suggestedStage;
     
     var orgPath = [];    
     var dummyEvent = {};
@@ -63,7 +65,7 @@
         
         var stagesById = [];
         
-        if(angular.isUndefined(events) || events.length === 0){
+        if((angular.isUndefined(events) || events.length === 0) && angular.isUndefined($scope.suggestedStage)){
             suggestedStage = availableStagesOrdered[0];
         }
         else{
@@ -72,25 +74,32 @@
             });
             
             var lastStageForEvents;
-            for(i = 0; i < events.length; i++){
-                var event = events[i];
-                var eventStage = stagesById[event.programStage];
-                    if(i > 0){
-                        if(eventStage.sortOrder > lastStageForEvents.sortOrder){
+            
+            if(angular.isUndefined($scope.suggestedStage)){
+                for(i = 0; i < events.length; i++){
+                    var event = events[i];
+                    var eventStage = stagesById[event.programStage];
+                        if(i > 0){
+                            if(eventStage.sortOrder > lastStageForEvents.sortOrder){
+                                lastStageForEvents = eventStage;
+                            }
+                            else if(eventStage.sortOrder === lastStageForEvents.sortOrder){
+                                if(eventStage.id !== lastStageForEvents.id){
+                                    if(eventStage.name.localeCompare(lastStageForEvents.name) > 0){
+                                        lastStageForEvents = eventStage;
+                                    }
+                                }                            
+                            }
+                        }
+                        else {
                             lastStageForEvents = eventStage;
                         }
-                        else if(eventStage.sortOrder === lastStageForEvents.sortOrder){
-                            if(eventStage.id !== lastStageForEvents.id){
-                                if(eventStage.name.localeCompare(lastStageForEvents.name) > 0){
-                                    lastStageForEvents = eventStage;
-                                }
-                            }                            
-                        }
-                    }
-                    else {
-                        lastStageForEvents = eventStage;
-                    }
-            }
+                }   
+            }
+            else {
+                lastStageForEvents = $scope.suggestedStage;
+            }
+
             
             for(j = 0; j < availableStagesOrdered.length; j++){
                 var availableStage = availableStagesOrdered[j];