← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21678: tracker-capture: file upload/download feature

 

------------------------------------------------------------
revno: 21678
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2016-01-09 12:32:08 +0100
message:
  tracker-capture: file upload/download feature
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css
  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/scripts/services.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.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-event-capture/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2016-01-01 19:29:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/controllers.js	2016-01-09 11:32:08 +0000
@@ -339,7 +339,7 @@
                             if($scope.prStDes[dataValue.dataElement]){
                                 var val = dataValue.value;                                  
                                 if(angular.isObject($scope.prStDes[dataValue.dataElement].dataElement)){
-                                    val = CommonUtils.formatDataValue(val, $scope.prStDes[dataValue.dataElement].dataElement, $scope.optionSets, 'USER');                                                                          
+                                    val = CommonUtils.formatDataValue(null, val, $scope.prStDes[dataValue.dataElement].dataElement, $scope.optionSets, 'USER');                                                                          
                                 }
 
                                 event[dataValue.dataElement] = val;
@@ -592,7 +592,7 @@
             var val = $scope.currentEvent[dataElement];
             if(val){
                 valueExists = true;                
-                val = CommonUtils.formatDataValue(val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');
+                val = CommonUtils.formatDataValue(null, val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');
             }
             dataValues.push({dataElement: dataElement, value: val});
         }
@@ -723,7 +723,7 @@
         var dataValues = [];        
         for(var dataElement in $scope.prStDes){
             var val = $scope.currentEvent[dataElement];            
-            val = CommonUtils.formatDataValue(val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');            
+            val = CommonUtils.formatDataValue(null, val, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');            
             dataValues.push({dataElement: dataElement, value: val});
         }
         
@@ -851,7 +851,7 @@
         }        
                 
         if( newValue !== oldValue ){            
-            newValue = CommonUtils.formatDataValue(newValue, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');            
+            newValue = CommonUtils.formatDataValue(null, newValue, $scope.prStDes[dataElement].dataElement, $scope.optionSets, 'API');            
             var updatedSingleValueEvent = {event: $scope.currentEvent.event, dataValues: [{value: newValue, dataElement: dataElement}]};
             var updatedFullValueEvent = DHIS2EventService.reconstructEvent($scope.currentEvent, $scope.selectedProgramStage.programStageDataElements);
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2016-01-02 08:44:30 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/services.js	2016-01-09 11:32:08 +0000
@@ -533,53 +533,4 @@
             return def.promise;
         }
     };
-})
-
-/* service for dealing with events */
-.service('DHIS2EventService', function(){
-    return {     
-        //for simplicity of grid display, events were changed from
-        //event.datavalues = [{dataElement: dataElement, value: value}] to
-        //event[dataElement] = value
-        //now they are changed back for the purpose of storage.   
-        reconstructEvent: function(event, programStageDataElements){
-            var e = {};
-        
-            e.event         = event.event;
-            e.status        = event.status;
-            e.program       = event.program;
-            e.programStage  = event.programStage;
-            e.orgUnit       = event.orgUnit;
-            e.eventDate     = event.eventDate;
-
-            var dvs = [];
-            angular.forEach(programStageDataElements, function(prStDe){
-                if(event.hasOwnProperty(prStDe.dataElement.id)){
-                    dvs.push({dataElement: prStDe.dataElement.id, value: event[prStDe.dataElement.id]});
-                }
-            });
-
-            e.dataValues = dvs;
-            
-            if(event.coordinate){
-                e.coordinate = {latitude: event.coordinate.latitude ? event.coordinate.latitude : '',
-                                     longitude: event.coordinate.longitude ? event.coordinate.longitude : ''};
-            }
-
-            return e;
-        },
-        refreshList: function(eventList, currentEvent){
-            if(!eventList || !eventList.length){
-                return;
-            }
-            var continueLoop = true;
-            for(var i=0; i< eventList.length && continueLoop; i++){
-                if(eventList[i].event === currentEvent.event ){
-                    eventList[i] = currentEvent;
-                    continueLoop = false;
-                }
-            }            
-            return eventList;
-        }
-    };
 });

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css	2016-01-01 19:29:44 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/styles/style.css	2016-01-09 11:32:08 +0000
@@ -381,7 +381,6 @@
     background-color: #d0eBd0;
     padding-top: 10px;
     padding-bottom: 10px;    
-    //margin-bottom: 15px;
     border-radius: 3px;
 }
 
@@ -413,8 +412,8 @@
 }
 
 .ui-datepicker-group .ui-datepicker-header {
-    //height: 1.5em; 
-    height: inherit;  //this is to make it play nice with bootstrap
+    /*height: 1.5em;*/ 
+    height: inherit;  /*this is to make it play nice with bootstrap*/
 }
 
 .btn-file {

=== 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-08 17:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/dataentry-controller.js	2016-01-09 11:32:08 +0000
@@ -8,6 +8,7 @@
                 $log,
                 $timeout,
                 $translate,
+                $window,
                 CommonUtils,
                 DateUtils,
                 EventUtils,
@@ -421,6 +422,7 @@
                 }
             });
             
+            $scope.fileNames = CurrentSelection.getFileNames();            
             $scope.allEventsSorted = orderByFilter($scope.allEventsSorted, '-sortingDate').reverse();
             sortEventsByStage(null);
             $scope.showDataEntry($scope.currentEvent, true);
@@ -778,6 +780,7 @@
     };
     
     $scope.getDataEntryForm = function () {
+        $scope.currentFileNames = $scope.fileNames[$scope.currentEvent.event] ? $scope.fileNames[$scope.currentEvent.event] : [];
         $scope.currentStage = $scope.stagesById[$scope.currentEvent.programStage];
         $scope.currentStageEvents = $scope.eventsByStage[$scope.currentEvent.programStage];
         if(!$scope.currentStage.multiSelectGroups) {
@@ -840,7 +843,7 @@
         $scope.executeRules();
     };
 
-    $scope.saveDatavalue = function (prStDe, field) {        
+    $scope.saveDatavalue = function (prStDe, field) {
         $scope.saveDataValueForEvent(prStDe, field, $scope.currentEvent, false);
     };
     
@@ -880,7 +883,7 @@
 
         $scope.currentElement = {id: currentElement.dataElement.id, event: eventToSave.event, saved: false};
         
-        value = CommonUtils.formatDataValue(value, prStDe.dataElement, $scope.optionSets, 'API');
+        value = CommonUtils.formatDataValue(eventToSave.event, value, prStDe.dataElement, $scope.optionSets, 'API');
         var dataValue = {
             dataElement: prStDe.dataElement.id,
             value: value,
@@ -949,7 +952,7 @@
 
         if (oldValue !== value) {
             
-            value = CommonUtils.formatDataValue(value, prStDe.dataElement, $scope.optionSets, 'API');
+            value = CommonUtils.formatDataValue(eventToSave.event, value, prStDe.dataElement, $scope.optionSets, 'API');
             
             //Do not change the input notification variables for background updates
             if(!backgroundUpdate) {
@@ -973,6 +976,8 @@
             };
             return DHIS2EventFactory.updateForSingleValue(ev).then(function (response) {
 
+                $scope.updateFileNames();
+                
                 if(!backgroundUpdate) {
                     $scope.currentElement.saved = true;
                     $scope.currentElement.pending = false;
@@ -1850,6 +1855,63 @@
                 
                 DialogService.showDialog({}, dialogOptions);        
     };
+    
+    $scope.downloadFile = function(eventUid, dataElementUid, e) {
+        eventUid = eventUid ? eventUid : $scope.currentEvent.event ? $scope.currentEvent.event : null;        
+        if( !eventUid || !dataElementUid){
+            
+            var dialogOptions = {
+                headerText: 'error',
+                bodyText: 'missing_file_identifier'
+            };
+
+            DialogService.showDialog({}, dialogOptions);
+            return;
+        }
+        
+        $window.open('../api/events/files?eventUid=' + eventUid +'&dataElementUid=' + dataElementUid, '_blank', '');
+        if(e){
+            e.stopPropagation();
+            e.preventDefault();
+        }
+    };
+    
+    $scope.deleteFile = function(dataElement){
+        
+        if( !dataElement ){            
+            var dialogOptions = {
+                headerText: 'error',
+                bodyText: 'missing_file_identifier'
+            };
+            DialogService.showDialog({}, dialogOptions);
+            return;
+        }
+        
+        var modalOptions = {
+            closeButtonText: 'cancel',
+            actionButtonText: 'remove',
+            headerText: 'remove',
+            bodyText: 'are_you_sure_to_remove'
+        };
+
+        ModalService.showModal({}, modalOptions).then(function(result){            
+            $scope.fileNames[$scope.currentEvent.event][dataElement] = null;
+            $scope.currentEvent[dataElement] = null;
+            $scope.saveDatavalue($scope.prStDes[dataElement], null);
+            //$scope.updateEventDataValue($scope.currentEvent, dataElement);
+        });
+    };
+    
+    $scope.updateFileNames = function(){        
+        for(var dataElement in $scope.currentFileNames){
+            if($scope.currentFileNames[dataElement]){
+                if(!$scope.fileNames[$scope.currentEvent.event]){
+                    $scope.fileNames[$scope.currentEvent.event] = [];
+                }                 
+                $scope.fileNames[$scope.currentEvent.event][dataElement] = $scope.currentFileNames[dataElement];
+            }
+        }
+    };
 })
 .controller('EventOptionsInTableController', function($scope, $translate){
     

=== 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-08 17:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/components/dataentry/default-form.html	2016-01-09 11:32:08 +0000
@@ -262,6 +262,40 @@
                             <div class="not-for-screen">
                                 <input type="text" class="form-control" value={{currentEvent[prStDe.dataElement.id]}}>
                             </div>
+                        </div>
+                        <div ng-switch-when="FILE_RESOURCE">
+                            <div class="hideInPrint">
+                                <div class="input-group">
+                                    <div class="form-control">
+                                        <a href ng-click="downloadFile(currentEvent.event, prStDe.dataElement.id)">{{fileNames[currentEvent.event][prStDe.dataElement.id]}}</a>                                        
+                                    </div>
+                                    <span class="input-group-btn">
+                                        <span class="btn btn-primary btn-file">
+                                            <span ng-if="currentEvent[prStDe.dataElement.id]" 
+                                                  title="{{'delete' | translate}}" 
+                                                  d2-file-input-name="fileNames[currentEvent.event][prStDe.dataElement.id]" 
+                                                  d2-file-input-delete="currentEvent[prStDe.dataElement.id]">
+                                                <a href ng-click="deleteFile(prStDe.dataElement.id)"><i class="fa fa-trash alert-danger"></i></a>
+                                            </span>
+                                            <span ng-if="!currentEvent[prStDe.dataElement.id]" title="{{'upload' | translate}}">
+                                                <i class="fa fa-upload"></i>
+                                                <input type="file" 
+                                                       ng-required={{prStDe.compulsory}}
+                                                       ng-disabled="selectedEnrollment.status !== 'ACTIVE' || currentEvent.editingNotAllowed || assignedFields[currentEvent.event][prStDe.dataElement.id]" 
+                                                       name="foo"
+                                                       input-field-id={{prStDe.dataElement.id}}
+                                                       d2-file-input-ps="currentStage"
+                                                       d2-file-input="currentEvent" 
+                                                       d2-file-input-current-name="currentFileNames"
+                                                       d2-file-input-name="fileNames">
+                                            </span>                                                
+                                        </span>
+                                    </span>                
+                                </div>
+                            </div>
+                            <div class="not-for-screen">
+                                <input type="text" class="form-control" value={{currentEvent[prStDe.dataElement.id]}}>
+                            </div>
                         </div>                        
                         <div ng-switch-default>
                             <div class="hideInPrint">
@@ -553,7 +587,41 @@
                                             <div class="not-for-screen">
                                                 <input type="text" class="form-control" value={{currentEvent[prStDes[de.dataElement.id].dataElement.id]}}>
                                             </div>
-                                        </div>                                        
+                                        </div>
+                                        <div ng-switch-when="FILE_RESOURCE">
+                                            <div class="hideInPrint">
+                                                <div class="input-group">
+                                                    <div class="form-control">
+                                                        <a href ng-click="downloadFile(currentEvent.event, de.dataElement.id)">{{fileNames[currentEvent.event][de.dataElement.id]}}</a>                                        
+                                                    </div>
+                                                    <span class="input-group-btn">
+                                                        <span class="btn btn-primary btn-file">
+                                                            <span ng-if="currentEvent[de.dataElement.id]" 
+                                                                  title="{{'delete' | translate}}" 
+                                                                  d2-file-input-name="fileNames[currentEvent.event][de.dataElement.id]" 
+                                                                  d2-file-input-delete="currentEvent[de.dataElement.id]">
+                                                                <a href ng-click="deleteFile(de.dataElement.id)"><i class="fa fa-trash alert-danger"></i></a>
+                                                            </span>
+                                                            <span ng-if="!currentEvent[de.dataElement.id]" title="{{'upload' | translate}}">
+                                                                <i class="fa fa-upload"></i>
+                                                                <input type="file" 
+                                                                       ng-required={{prStDes[de.dataElement.id].compulsory}}
+                                                                       ng-disabled="assignedFields[de.dataElement.id]"
+                                                                       name="foo"
+                                                                       input-field-id={{de.dataElement.id}}
+                                                                       d2-file-input-ps="currentStage"
+                                                                       d2-file-input="currentEvent" 
+                                                                       d2-file-input-current-name="currentFileNames"
+                                                                       d2-file-input-name="fileNames">
+                                                            </span>                                                
+                                                        </span>
+                                                    </span>                
+                                                </div>
+                                            </div>
+                                            <div class="not-for-screen">
+                                                <input type="text" class="form-control" value={{currentEvent[prStDe.dataElement.id]}}>
+                                            </div>
+                                        </div>
                                         <div ng-switch-default>
                                             <div class="hideInPrint">
                                                 <input type="text" 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-01-08 17:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/scripts/services.js	2016-01-09 11:32:08 +0000
@@ -1474,75 +1474,6 @@
     }; 
 })
 
-/* current selections */
-.service('CurrentSelection', function(){
-    this.currentSelection = {};
-    this.relationshipInfo = {};
-    this.optionSets = null;
-    this.attributesById = null;
-    this.ouLevels = null;
-    this.sortedTeiIds = [];
-    this.selectedTeiEvents = null;
-    this.relationshipOwner = {};
-    this.selectedTeiEvents = [];
-    
-    this.set = function(currentSelection){  
-        this.currentSelection = currentSelection;        
-    };    
-    this.get = function(){
-        return this.currentSelection;
-    };
-    
-    this.setRelationshipInfo = function(relationshipInfo){  
-        this.relationshipInfo = relationshipInfo;        
-    };    
-    this.getRelationshipInfo = function(){
-        return this.relationshipInfo;
-    };
-    
-    this.setOptionSets = function(optionSets){
-        this.optionSets = optionSets;
-    };
-    this.getOptionSets = function(){
-        return this.optionSets;
-    };    
-    
-    this.setAttributesById = function(attributesById){
-        this.attributesById = attributesById;
-    };
-    this.getAttributesById = function(){
-        return this.attributesById;
-    }; 
-    
-    this.setOuLevels = function(ouLevels){
-        this.ouLevels = ouLevels;
-    };
-    this.getOuLevels = function(){
-        return this.ouLevels;
-    };
-    
-    this.setSortedTeiIds = function(sortedTeiIds){
-        this.sortedTeiIds = sortedTeiIds;
-    };
-    this.getSortedTeiIds = function(){
-        return this.sortedTeiIds;
-    };
-    
-    this.setSelectedTeiEvents = function(selectedTeiEvents){
-        this.selectedTeiEvents = selectedTeiEvents;
-    };
-    this.getSelectedTeiEvents = function(){
-        return this.selectedTeiEvents;
-    };
-    
-    this.setRelationshipOwner = function(relationshipOwner){
-        this.relationshipOwner = relationshipOwner;
-    };
-    this.getRelationshipOwner = function(){
-        return this.relationshipOwner;
-    };
-})
-
 /*Orgunit service for local db */
 .service('OuService', function($window, $q){
     
@@ -1922,7 +1853,7 @@
                 
             angular.forEach(programStage.programStageDataElements, function(prStDe){
                 if(dhis2Event[prStDe.dataElement.id]){                    
-                    var value = CommonUtils.formatDataValue(dhis2Event[prStDe.dataElement.id], prStDe.dataElement, optionSets, 'API');                    
+                    var value = CommonUtils.formatDataValue(dhis2Event.event, dhis2Event[prStDe.dataElement.id], prStDe.dataElement, optionSets, 'API');                    
                     var val = {value: value, dataElement: prStDe.dataElement.id};
                     if(dhis2Event.providedElsewhere[prStDe.dataElement.id]){
                         val.providedElsewhere = dhis2Event.providedElsewhere[prStDe.dataElement.id];
@@ -1951,7 +1882,7 @@
                 if( prStDe ){                
                     var val = dataValue.value;
                     if(prStDe.dataElement){
-                        val = CommonUtils.formatDataValue(val, prStDe.dataElement, optionSets, 'USER');                        
+                        val = CommonUtils.formatDataValue(event.event, val, prStDe.dataElement, optionSets, 'USER');                        
                     }    
                     event[dataValue.dataElement] = val;
                     if(dataValue.providedElsewhere){

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2016-01-07 21:16:02 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-tracker-capture/styles/style.css	2016-01-09 11:32:08 +0000
@@ -1477,5 +1477,23 @@
     outline-style: none;
 }
 
+.btn-file {
+    position: relative;
+    overflow: hidden;
+}
+.btn-file input[type=file] {
+    position: absolute;
+    top: 0;
+    right: 0;
+    min-width: 100%;
+    min-height: 100%;
+    font-size: 100px;
+    text-align: right;
+    filter: alpha(opacity=0);
+    opacity: 0;
+    background: red;
+    cursor: inherit;
+    display: block;
+}
 
 

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2016-01-08 17:45:04 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.angular.services.js	2016-01-09 11:32:08 +0000
@@ -262,11 +262,12 @@
 })
 
 /* service for common utils */
-.service('CommonUtils', function(DateUtils, OptionSetService){    
+.service('CommonUtils', function(DateUtils, OptionSetService, CurrentSelection, FileService){    
     
     return {
-        formatDataValue: function(val, obj, optionSets, destination){                               
-            if(val && 
+        formatDataValue: function(event, val, obj, optionSets, destination){            
+        	var fileNames = CurrentSelection.getFileNames();
+        	if(val && 
                     obj.valueType === 'NUMBER' || 
                     obj.valueType === 'INTEGER' ||
                     obj.valueType === 'INTEGER_POSITIVE' ||
@@ -305,7 +306,18 @@
                 else{
                     val = val === true ? 'true' : '';
                 }            
-            }         
+            }
+            if(event && val && destination === 'USER' && obj.valueType === 'FILE_RESOURCE'){
+            	FileService.get(val).then(function(response){
+                    if(response && response.name){
+                        if(!fileNames[event]){
+                            fileNames[event] = [];
+                        } 
+                        fileNames[event][obj.id] = response.name;
+                        CurrentSelection.setFileNames( fileNames );
+                    }
+                });
+            }
             return val;
         },
         displayBooleanAsYesNo: function(value, dataElement){
@@ -1906,4 +1918,130 @@
             }
         }
     };
+})
+
+/* service for dealing with events */
+.service('DHIS2EventService', function(){
+    return {     
+        //for simplicity of grid display, events were changed from
+        //event.datavalues = [{dataElement: dataElement, value: value}] to
+        //event[dataElement] = value
+        //now they are changed back for the purpose of storage.   
+        reconstructEvent: function(event, programStageDataElements){
+            var e = {};
+        
+            e.event         = event.event;
+            e.status        = event.status;
+            e.program       = event.program;
+            e.programStage  = event.programStage;
+            e.orgUnit       = event.orgUnit;
+            e.eventDate     = event.eventDate;
+
+            var dvs = [];
+            angular.forEach(programStageDataElements, function(prStDe){
+                if(event.hasOwnProperty(prStDe.dataElement.id)){
+                    dvs.push({dataElement: prStDe.dataElement.id, value: event[prStDe.dataElement.id]});
+                }
+            });
+
+            e.dataValues = dvs;
+            
+            if(event.coordinate){
+                e.coordinate = {latitude: event.coordinate.latitude ? event.coordinate.latitude : '',
+                                     longitude: event.coordinate.longitude ? event.coordinate.longitude : ''};
+            }
+
+            return e;
+        },
+        refreshList: function(eventList, currentEvent){
+            if(!eventList || !eventList.length){
+                return;
+            }
+            var continueLoop = true;
+            for(var i=0; i< eventList.length && continueLoop; i++){
+                if(eventList[i].event === currentEvent.event ){
+                    eventList[i] = currentEvent;
+                    continueLoop = false;
+                }
+            }            
+            return eventList;
+        }
+    };
+})
+
+/* current selections */
+.service('CurrentSelection', function(){
+    this.currentSelection = {};
+    this.relationshipInfo = {};
+    this.optionSets = null;
+    this.attributesById = null;
+    this.ouLevels = null;
+    this.sortedTeiIds = [];
+    this.selectedTeiEvents = null;
+    this.relationshipOwner = {};
+    this.selectedTeiEvents = [];
+    this.fileNames = [];
+    
+    this.set = function(currentSelection){  
+        this.currentSelection = currentSelection;        
+    };    
+    this.get = function(){
+        return this.currentSelection;
+    };
+    
+    this.setRelationshipInfo = function(relationshipInfo){  
+        this.relationshipInfo = relationshipInfo;        
+    };    
+    this.getRelationshipInfo = function(){
+        return this.relationshipInfo;
+    };
+    
+    this.setOptionSets = function(optionSets){
+        this.optionSets = optionSets;
+    };
+    this.getOptionSets = function(){
+        return this.optionSets;
+    };    
+    
+    this.setAttributesById = function(attributesById){
+        this.attributesById = attributesById;
+    };
+    this.getAttributesById = function(){
+        return this.attributesById;
+    }; 
+    
+    this.setOuLevels = function(ouLevels){
+        this.ouLevels = ouLevels;
+    };
+    this.getOuLevels = function(){
+        return this.ouLevels;
+    };
+    
+    this.setSortedTeiIds = function(sortedTeiIds){
+        this.sortedTeiIds = sortedTeiIds;
+    };
+    this.getSortedTeiIds = function(){
+        return this.sortedTeiIds;
+    };
+    
+    this.setSelectedTeiEvents = function(selectedTeiEvents){
+        this.selectedTeiEvents = selectedTeiEvents;
+    };
+    this.getSelectedTeiEvents = function(){
+        return this.selectedTeiEvents;
+    };
+    
+    this.setRelationshipOwner = function(relationshipOwner){
+        this.relationshipOwner = relationshipOwner;
+    };
+    this.getRelationshipOwner = function(){
+        return this.relationshipOwner;
+    };
+    
+    this.setFileNames = function(fileNames){
+        this.fileNames = fileNames;
+    };
+    this.getFileNames = function(){
+        return this.fileNames;
+    };
 });
\ No newline at end of file