← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 12538: rewrote removeEvent in anonymous, now will properly check to see if event exists locally. was an ...

 

------------------------------------------------------------
revno: 12538
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2013-10-09 22:03:59 +0200
message:
  rewrote removeEvent in anonymous, now will properly check to see if event exists locally. was an issue if a psi was started online, then continued offline.. there was no way to delete local data.
modified:
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
  dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.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-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-10-09 19:44:17 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js	2013-10-09 20:03:59 +0000
@@ -207,7 +207,7 @@
         data: JSON.stringify( event ),
         cache: false
     } ).done( function ( json ) {
-        if ( json.response == 'success' ) {
+        if ( json.response === 'success' ) {
             DAO.store.delete( 'dataValues', event.id ).done( function () {
                 updateOfflineEvents();
                 searchEvents( eval( getFieldValue( 'listAll' ) ) );
@@ -271,7 +271,7 @@
         promise = promise.then( loadOptionSets );
         promise = promise.then( updateOfflineEvents );
         promise = promise.then( checkOfflineData );
-        promise = promise.then( function () {
+        promise.then( function () {
             $("#programId").removeAttr('disabled');
 
             selection.setListenerFunction( organisationUnitSelected );
@@ -854,18 +854,19 @@
 function removeEvent( programStageId ) {
     var s = "" + programStageId;
 
-    if( s.indexOf("local") != -1) {
-        if ( confirm( i18n_comfirm_delete_event ) ) {
-            DAO.store.delete( 'dataValues', programStageId ).always( function () {
-                updateOfflineEvents();
-
-                // needed, seemed that from time-to-time the events are updated too early, could be idb related
-                setTimeout(updateOfflineEvents, 400);
-            } );
+    DAO.store.get('dataValues', programStageId).done(function(obj) {
+        if(obj) {
+            if( confirm(i18n_comfirm_delete_event) ) {
+                DAO.store.delete('dataValues', programStageId).always(function() {
+                    updateOfflineEvents();
+                    // needed, seemed that from time-to-time the events are updated too early, could be idb related
+                    setTimeout(updateOfflineEvents, 100);
+                });
+            }
+        } else {
+            removeItem( programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' );
         }
-    } else {
-        removeItem( programStageId, '', i18n_comfirm_delete_event, 'removeCurrentEncounter.action' );
-    }
+    });
 }
 
 function showUpdateEvent( programStageInstanceId ) {

=== modified file 'dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-10-09 19:39:35 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/entry.js	2013-10-09 20:03:59 +0000
@@ -743,8 +743,6 @@
 };
 
 function loadProgramStageInstance( programStageInstanceId, always ) {
-    console.log('loading: ' + programStageInstanceId);
-
     $( "#programStageInstanceId" ).val( programStageInstanceId );
     $( "#entryFormContainer input[id='programStageInstanceId']" ).val( programStageInstanceId );