dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #35985
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18429: tracker-capture: bug fix in auto refreshing when switching between events
------------------------------------------------------------
revno: 18429
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2015-02-26 13:06:33 +0100
message:
tracker-capture: bug fix in auto refreshing when switching between events
modified:
dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-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-controller.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-02-20 16:29:28 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js 2015-02-26 12:06:33 +0000
@@ -50,7 +50,8 @@
$scope.allowEventCreation = false;
$scope.repeatableStages = [];
$scope.eventsByStage = [];
- $scope.programStages = [];
+ $scope.programStages = [];
+ $scope.prStDes = [];
var selections = CurrentSelection.get();
$scope.selectedOrgUnit = storage.get('SELECTED_OU');
@@ -67,7 +68,12 @@
angular.forEach(stages, function(stage){
if(stage.openAfterEnrollment){
$scope.currentStage = stage;
- }
+ }
+
+ angular.forEach(stage.programStageDataElements, function(prStDe){
+ $scope.prStDes[prStDe.dataElement.id] = prStDe;
+ });
+
$scope.selectedProgramWithStage[stage.id] = stage;
$scope.eventsByStage[stage.id] = [];
});
@@ -103,6 +109,7 @@
}
dhis2Event.statusColor = EventUtils.getEventStatusColor(dhis2Event);
+ dhis2Event = processEvent(dhis2Event, eventStage);
if($scope.currentStage && $scope.currentStage.id === dhis2Event.programStage){
$scope.currentEvent = dhis2Event;
@@ -216,40 +223,28 @@
$scope.displayCustomForm = !$scope.displayCustomForm;
};
- $scope.getDataEntryForm = function(){
-
- $scope.currentEvent.providedElsewhere = [];
+ $scope.getDataEntryForm = function(){
$scope.currentStage = $scope.selectedProgramWithStage[$scope.currentEvent.programStage];
angular.forEach($scope.currentStage.programStageSections, function(section){
section.open = true;
});
-
- $scope.prStDes = [];
- angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
- $scope.prStDes[prStDe.dataElement.id] = prStDe;
- });
$scope.customForm = CustomFormService.getForProgramStage($scope.currentStage);
- $scope.displayCustomForm = $scope.customForm ? true:false;
+ $scope.displayCustomForm = $scope.customForm ? true:false;
- $scope.allowProvidedElsewhereExists = false;
- angular.forEach($scope.currentStage.programStageDataElements, function(prStDe){
- $scope.currentStage.programStageDataElements[prStDe.dataElement.id] = prStDe.dataElement;
- if(prStDe.allowProvidedElsewhere){
- $scope.allowProvidedElsewhereExists = true;
- }
- });
-
- if($scope.currentStage.captureCoordinates){
- $scope.currentEvent.coordinate = {latitude: $scope.currentEvent.coordinate.latitude ? $scope.currentEvent.coordinate.latitude : '',
- longitude: $scope.currentEvent.coordinate.longitude ? $scope.currentEvent.coordinate.longitude : ''};
- }
-
- angular.forEach($scope.currentEvent.dataValues, function(dataValue){
+ $scope.currentEventOriginal = angular.copy($scope.currentEvent);
+ };
+
+ var processEvent = function(event, stage){
+
+ event.providedElsewhere = [];
+
+ angular.forEach(event.dataValues, function(dataValue){
+
var val = dataValue.value;
- var de = $scope.currentStage.programStageDataElements[dataValue.dataElement];
+ var de = $scope.prStDes[dataValue.dataElement].dataElement;
if(de){
if(val && de.type === 'string' && de.optionSet && $scope.optionSets[de.optionSet.id].options ){
val = OptionSetService.getName($scope.optionSets[de.optionSet.id].options, val);
@@ -266,13 +261,26 @@
}
}
}
- $scope.currentEvent[dataValue.dataElement] = val;
+ event[dataValue.dataElement] = val;
if(dataValue.providedElsewhere){
- $scope.currentEvent.providedElsewhere[dataValue.dataElement] = dataValue.providedElsewhere;
- }
- });
-
- $scope.currentEventOriginal = angular.copy($scope.currentEvent);
+ event.providedElsewhere[dataValue.dataElement] = dataValue.providedElsewhere;
+ }
+ });
+
+ if(stage.captureCoordinates){
+ event.coordinate = {latitude: event.coordinate.latitude ? event.coordinate.latitude : '',
+ longitude: event.coordinate.longitude ? event.coordinate.longitude : ''};
+ }
+
+
+ event.allowProvidedElsewhereExists = false;
+ angular.forEach(stage.programStageDataElements, function(prStDe){
+ if(prStDe.allowProvidedElsewhere){
+ event.allowProvidedElsewhereExists = true;
+ }
+ });
+
+ return event;
};
$scope.saveDatavalue = function(prStDe){
@@ -317,6 +325,15 @@
]
};
DHIS2EventFactory.updateForSingleValue(ev).then(function(response){
+ var index = -1;
+ for(var i=0; i<$scope.eventsByStage[$scope.currentEvent.programStage].length && index === -1; i++){
+ if($scope.eventsByStage[$scope.currentEvent.programStage][i].event === $scope.currentEvent.event){
+ index = i;
+ }
+ }
+ if(index !== -1){
+ $scope.eventsByStage[$scope.currentEvent.programStage].splice(index,1,$scope.currentEvent);
+ }
$scope.currentElement.saved = true;
$scope.currentEventOriginal = angular.copy($scope.currentEvent);
});