dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13702
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4470: Fixed bug with StorageManager
------------------------------------------------------------
revno: 4470
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-27 17:00:52 +0200
message:
Fixed bug with StorageManager
modified:
dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-27 11:43:07 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2011-08-27 15:00:52 +0000
@@ -981,6 +981,7 @@
if ( dataSets[localId] == null )
{
storageManager.deleteForm( localId );
+ storageManager.deleteFormVersion( localId );
log( 'Deleted locally stored form: ' + localId );
}
}
@@ -995,14 +996,14 @@
for ( i in formIds )
{
- var dataSetId = formIds[i];
+ var localId = formIds[i];
- var remoteVersion = dataSets[dataSetId].version;
- var localVersion = formVersions[dataSetId];
+ var remoteVersion = dataSets[localId].version;
+ var localVersion = formVersions[localId];
if ( remoteVersion == null || localVersion == null || remoteVersion != localVersion )
{
- storageManager.downloadForm( dataSetId, remoteVersion );
+ storageManager.downloadForm( localId, remoteVersion );
}
}
}
@@ -1150,7 +1151,9 @@
*/
this.deleteForm = function( dataSetId )
{
- localStorage.removeItem( dataSetId );
+ var id = KEY_FORM_PREFIX + dataSetId;
+
+ localStorage.removeItem( id );
};
/**
@@ -1266,6 +1269,25 @@
return null;
};
+
+ /**
+ * Deletes the form version of the data set with the given identifier.
+ *
+ * @param dataSetId the identifier of the data set of the form.
+ */
+ this.deleteFormVersion = function( dataSetId )
+ {
+ if ( localStorage[KEY_FORM_VERSIONS] != null )
+ {
+ var formVersions = JSON.parse( localStorage[KEY_FORM_VERSIONS] );
+
+ if ( formVersions[dataSetId] != null )
+ {
+ delete formVersions[dataSetId];
+ localStorage[KEY_FORM_VERSIONS] = JSON.stringify( formVersions );
+ }
+ }
+ }
this.getAllFormVersions = function()
{