dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #19902
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 8877: mobile: minor changes, mostly for testing
------------------------------------------------------------
revno: 8877
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2012-11-05 14:05:21 +0100
message:
mobile: minor changes, mostly for testing
modified:
dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.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-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js'
--- dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js 2012-11-05 11:47:06 +0000
+++ dhis-2/dhis-web/dhis-web-mobile/src/main/webapp/dhis-web-mobile-resources/js/dhis2.storage.js 2012-11-05 13:05:21 +0000
@@ -41,19 +41,19 @@
cache : false
}).success(function ( data ) {
// clear out old localStorage, some phones doesn't like it when you overwrite old keys
- delete localStorage['organisationUnits'];
- delete localStorage['forms'];
+ localStorage.removeItem('organisationUnits';
+ localStorage.removeItem('forms');
if( data.organisationUnits ) {
- localStorage['organisationUnits'] = JSON.stringify(data.organisationUnits);
+ localStorage.setItem('organisationUnits', JSON.stringify(data.organisationUnits));
} else {
- localStorage['organisationUnits'] = JSON.stringify({});
+ localStorage.setItem('organisationUnits', JSON.stringify({}));
}
if( data.forms ) {
- localStorage['forms'] = JSON.stringify(data.forms);
+ localStorage.setItem('forms', JSON.stringify(data.forms));
} else {
- localStorage['forms'] = JSON.stringify({});
+ localStorage.setItem('forms', JSON.stringify({}));
}
});
};
@@ -64,8 +64,8 @@
dhis2.storage.FormManager.prototype.organisationUnits = function () {
if ( this._organisationUnits === undefined ) {
- if( localStorage['organisationUnits'] ) {
- this._organisationUnits = JSON.parse(localStorage['organisationUnits']);
+ if( localStorage.getItem('organisationUnits') ) {
+ this._organisationUnits = JSON.parse(localStorage.getItem('organisationUnits'));
}
}
@@ -83,8 +83,8 @@
dhis2.storage.FormManager.prototype.forms = function () {
if( this._forms === undefined ) {
- if( localStorage['forms'] ) {
- this._forms = JSON.parse( localStorage['forms'] );
+ if( localStorage.getItem('forms') ) {
+ this._forms = JSON.parse( localStorage.getItem('forms') );
}
}
@@ -96,7 +96,7 @@
};
dhis2.storage.FormManager.prototype.dataValueSets = function() {
- var dataValueSets = localStorage['dataValueSets'];
+ var dataValueSets = localStorage.getItem('dataValueSets');
if(dataValueSets !== undefined )
{
@@ -135,8 +135,10 @@
dataValueSets[dhis2.storage.getUniqueKey(dataValueSet)] = dataValueSet;
// delete old values
- delete localStorage['dataValueSets'];
- localStorage['dataValueSets'] = JSON.stringify( dataValueSets );
+ localStorage.removeItem('dataValueSets');
+ localStorage.setItem('dataValueSets', JSON.stringify( dataValueSets ));
+
+ alert('stored locally');
});
};
@@ -146,15 +148,16 @@
_.each(dataValueSets, function( value, key ) {
deferreds.push(dhis2.storage.makeUploadDataValueSetRequest( value ).success(function() {
- delete dataValueSets[key];
+ // Do not remove old dvs for now
+ // delete dataValueSets[key];
})
);
});
return $.when.apply( null, deferreds ).always(function() {
// delete old values
- delete localStorage['dataValueSets'];
- localStorage['dataValueSets'] = JSON.stringify( dataValueSets );
+ localStorage.removeItem('dataValueSets');
+ localStorage.setItem('dataValueSets', JSON.stringify( dataValueSets ));
});
};