← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 14081: event capture - WIP, event deletion

 

------------------------------------------------------------
revno: 14081
committer: Abyot Asalefew Gizaw abyota@xxxxxxxxx
branch nick: dhis2
timestamp: Thu 2014-02-20 15:31:59 +0100
message:
  event capture - WIP, event deletion
modified:
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js
  dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/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-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js	2014-02-20 13:58:38 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/controllers.js	2014-02-20 14:31:59 +0000
@@ -309,6 +309,7 @@
     };
     
     $scope.removeEvent = function(){
+        
         var dhis2Event = ContextMenuSelectedItem.getSelectedItem();
         
         var modalOptions = {
@@ -319,7 +320,20 @@
         };
 
         ModalService.showModal({}, modalOptions).then(function(result){
-            console.log('The event to be deleted is:  ', dhis2Event);
+            
+            DHIS2EventFactory.delete(dhis2Event).then(function(data){
+                
+                var continueLoop = true, index = -1;
+                for(var i=0; i< $scope.dhis2Events.length && continueLoop; i++){
+                    if($scope.dhis2Events[i].event === dhis2Event.event ){
+                        $scope.dhis2Events[i] = dhis2Event;
+                        continueLoop = false;
+                        index = i;
+                    }
+                }
+                $scope.dhis2Events.splice(index,1);                
+                $scope.currentEvent = {};             
+            });
         });        
     };
     

=== modified file 'dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/services.js'
--- dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/services.js	2014-02-20 11:41:24 +0000
+++ dhis-2/dhis-web/dhis-web-event-capture/src/main/webapp/dhis-web-event-capture/app/scripts/services.js	2014-02-20 14:31:59 +0000
@@ -580,6 +580,13 @@
             });
             return promise;            
         },
+        
+        delete: function(dhis2Event){
+           var promise = $http.delete(dhis2Url + '/api/events/' + dhis2Event.event).then(function(response){
+                return response.data;
+            });
+            return promise;           
+        },
     
         update: function(dhis2Event){            
             var promise = $http.put(dhis2Url + '/api/events/' + dhis2Event.event, dhis2Event).then(function(response){