← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 13331: ouwt fixes for ie8, only memory-only storage if ie7, 8. Makes ouwt slow, but working in ie8.

 

------------------------------------------------------------
revno: 13331
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2013-12-19 15:36:41 +0100
message:
  ouwt fixes for ie8, only memory-only storage if ie7,8. Makes ouwt slow, but working in ie8.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.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-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js	2013-12-03 09:49:28 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/javascripts/dhis2/dhis2.storage.memory.js	2013-12-19 14:36:41 +0000
@@ -158,12 +158,9 @@
             value: function ( store, arr ) {
                 var self = this;
                 var deferred = $.Deferred();
-                var chained = deferred.then();
 
                 $.each( arr, function ( idx, item ) {
-                    chained = chained.then( function () {
-                        return self.set( store, item );
-                    } );
+                    self.set( store, item );
                 } );
 
                 deferred.resolveWith( this );

=== modified file 'dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2013-12-09 21:32:59 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2013-12-19 14:36:41 +0000
@@ -32,24 +32,40 @@
 var OU_USERNAME_KEY = "ouUsername";
 var OU_SELECTED_KEY = "ouSelected";
 
-dhis2.ou.store = new dhis2.storage.Store( {
-    name: OU_STORE_NAME,
-    objectStores: [ {
-      name: OU_KEY,
-      adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ]
-    }, {
-      name: OU_PARTIAL_KEY,
-      adapters: [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ]
+dhis2.ou.store = null;
+dhis2.ou.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
+
+$(function ()
+{
+    var adapters = [];
+    var partial_adapters = [];
+
+    if( dhis2.ou.memoryOnly ) {
+        adapters = [ dhis2.storage.InMemoryAdapter ];
+        partial_adapters = [ dhis2.storage.InMemoryAdapter ];
+    } else {
+        adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomLocalStorageAdapter, dhis2.storage.InMemoryAdapter ];
+        partial_adapters = [ dhis2.storage.IndexedDBAdapter, dhis2.storage.DomSessionStorageAdapter, dhis2.storage.InMemoryAdapter ];
     }
-    ]
-} );
-
-$( document ).ready( function ()
-{
+
+    dhis2.ou.store = new dhis2.storage.Store({
+        name: OU_STORE_NAME,
+        objectStores: [
+            {
+                name: OU_KEY,
+                adapters: adapters
+            },
+            {
+                name: OU_PARTIAL_KEY,
+                adapters: partial_adapters
+            }
+        ]
+    });
+
     dhis2.ou.store.open().done( function() {
         selection.load();
     } );
-} );
+});
 
 // -----------------------------------------------------------------------------
 // Selection
@@ -125,6 +141,10 @@
     };
 
     this.getVersion = function() {
+        if(dhis2.ou.memoryOnly) {
+            return -1;
+        }
+
         return localStorage[ OU_VERSION_KEY ] ? localStorage[ OU_VERSION_KEY ] : 0;
     };
 
@@ -304,14 +324,17 @@
             }
         } ).always( function() {
             if( should_update ) {
+                console.log('update');
                 selection.ajaxOrganisationUnits( false ).done(function( data ) {
                     selection.setRoots( data.roots );
                     selection.setVersion( data.version );
                     selection.setUsername( data.username );
+
                     selection.setOrganisationUnits( data.organisationUnits ).done(function() {
                         sync_and_reload();
                         $( "#orgUnitTree" ).trigger( "ouwtLoaded" );
                     });
+
                 } ).fail( function() {
                     sync_and_reload();
                     $( "#orgUnitTree" ).trigger( "ouwtLoaded" );