← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17453: disabled google map; fix to indexeddb issue when refreshing

 

------------------------------------------------------------
revno: 17453
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2014-11-12 17:49:17 +0100
message:
  disabled google map; fix to indexeddb issue when refreshing
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html


--
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/event-capture.appcache'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache	2014-11-03 13:12:05 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/event-capture.appcache	2014-11-12 16:49:17 +0000
@@ -20,6 +20,7 @@
 
 ../dhis-web-commons/javascripts/jQuery/ui/css/redmond/jquery-ui.css
 ../dhis-web-commons/javascripts/jQuery/calendars/css/ui-redmond.calendars.picker.css    
+../dhis-web-commons/javascripts/jQuery/calendars/css/ui.calendars.picker.css 
 
 ../dhis-web-commons/fonts/LiberationSans-Regular-webfont.eot
 ../dhis-web-commons/fonts/LiberationSans-Regular-webfont.woff

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2014-11-03 10:34:14 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/index.html	2014-11-12 16:49:17 +0000
@@ -66,14 +66,14 @@
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.storage.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.contextmenu.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.appcache.js"></script>
-        <!--<script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>-->
+        <script type="text/javascript" src="../dhis-web-commons/ouwt/ouwt.js"></script>
         
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angularLocalStorage.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate.min.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-static-files.min.js"></script>
         <script type="text/javascript" src="../dhis-web-commons/javascripts/angular/plugins/angular-translate-loader-url.min.js"></script>
 
-        <!--<script type="text/javascript" src="scripts/event-capture.js"></script>-->
+        <script type="text/javascript" src="scripts/event-capture.js"></script>
         <script type="text/javascript" src="scripts/app.js"></script>
         <script type="text/javascript" src="scripts/services.js"></script>
         <script type="text/javascript" src="scripts/directives.js"></script>
@@ -83,7 +83,7 @@
         <script type="text/javascript" src="scripts/map-controller.js"></script>
         <script type="text/javascript" src="scripts/notes-controller.js"></script>        
         <script type="text/javascript" src="scripts/filters.js"></script>
-        <script type="text/javascript" src="scripts/orgunitTreeSearch.js"></script>
+        <!--<script type="text/javascript" src="scripts/orgunitTreeSearch.js"></script>-->
 
         <!-- Menu scripts -->
         <script type="text/javascript" src="../dhis-web-commons/javascripts/dhis2/dhis2.translate.js"></script>

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js	2014-11-03 11:11:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/directives.js	2014-11-12 16:49:17 +0000
@@ -17,14 +17,14 @@
     };   
 })
 
-.directive('selectedOrgUnit', function() {        
+.directive('selectedOrgUnit', function($timeout, storage) {        
 
     return {        
         restrict: 'A',        
-        link: function(scope, element, attrs){           
+        link: function(scope, element, attrs){
             
             //when tree has loaded, get selected orgunit - if there is any - and inform angular           
-            $(function() {                 
+            /*$(function() {                 
                 
                 var adapters = [];
                 var partial_adapters = [];
@@ -73,6 +73,39 @@
             function organisationUnitSelected( orgUnits, orgUnitNames ) {
                 scope.selectedOrgUnit = {id: orgUnits[0], name: orgUnitNames[0], programs: []};    
                 scope.$apply();                
+            }*/
+            
+            //reloadtree, incase not loaded
+            $(function() {                
+                dhis2.ou.store.open().done( function() {
+                    selection.load();
+                    $( "#orgUnitTree" ).one( "ouwtLoaded", function() {
+                        var selected = selection.getSelected()[0];
+                        selection.getOrganisationUnit(selected).done(function(data){
+                            if( data ){
+                                $timeout(function() {
+                                    scope.selectedOrgUnit = {id: selected, name: data[selected].n, programs: []};
+                                    scope.$apply();
+                                });
+                            }                        
+                        });
+                    });                    
+                });
+            });
+            
+            //listen to user selection, and inform angular         
+            selection.responseReceived();
+            selection.setListenerFunction( organisationUnitSelected );
+            
+            function organisationUnitSelected( orgUnits, orgUnitNames ) {
+                var ou = {id: orgUnits[0], name: orgUnitNames[0]};
+                var selectedOld = storage.get('SELECTED_OU');
+                if(!selectedOld || ou.id !== selectedOld.id){
+                    $timeout(function() {
+                        scope.selectedOrgUnit = ou;
+                        scope.$apply();
+                    });
+                }
             }
         }  
     };

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2014-11-03 10:34:14 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2014-11-12 16:49:17 +0000
@@ -25,6 +25,34 @@
 
 dhis2.ec.store = null;
 dhis2.ec.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
+var adapters = [];    
+if( dhis2.ec.memoryOnly ) {
+    adapters = [ dhis2.storage.InMemoryAdapter ];
+} else {
+    adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
+}
+
+dhis2.ec.store = new dhis2.storage.Store({
+    name: EC_STORE_NAME,
+    objectStores: [
+        {
+            name: 'ecPrograms',
+            adapters: adapters
+        },
+        {
+            name: 'programStages',
+            adapters: adapters
+        },
+        {
+            name: 'geoJsons',
+            adapters: adapters
+        },
+        {
+            name: 'optionSets',
+            adapters: adapters
+        }            
+    ]        
+});
 
 (function($) {
     $.safeEach = function(arr, fn)
@@ -45,6 +73,8 @@
  */
 $(document).ready(function()
 {
+    downloadMetaData();
+    
     $.ajaxSetup({
         type: 'POST',
         cache: false
@@ -136,7 +166,7 @@
 }
 
 function downloadMetaData(){
-    var adapters = [];    
+    /*var adapters = [];    
     if( dhis2.ec.memoryOnly ) {
         adapters = [ dhis2.storage.InMemoryAdapter ];
     } else {
@@ -164,7 +194,7 @@
                 adapters: adapters
             }            
         ]        
-    });
+    });*/
     
     var def = $.Deferred();
     var promise = def.promise();
@@ -174,7 +204,7 @@
     promise = promise.then( getCalendarSetting );
     promise = promise.then( getLoginDetails );
     promise = promise.then( getOrgUnitLevels );
-    promise = promise.then( getGeoJsonsByLevel );
+    //promise = promise.then( getGeoJsonsByLevel );
     promise = promise.then( getMetaPrograms );     
     promise = promise.then( getPrograms );     
     promise = promise.then( getProgramStages );
@@ -257,7 +287,7 @@
     if( !ouLevels ){
         return;
     }
-    
+
     var mainDef = $.Deferred();
     var mainPromise = mainDef.promise();
 

=== modified file 'dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html	2014-11-03 11:11:25 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/views/home.html	2014-11-12 16:49:17 +0000
@@ -1,5 +1,5 @@
-<script src="../dhis-web-commons/ouwt/ouwt.js"></script>
-<script src="scripts/event-capture.js"></script>
+<!--<script src="../dhis-web-commons/ouwt/ouwt.js"></script>
+<script src="scripts/event-capture.js"></script>-->
 
 <div id="leftBar">