dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #13701
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 4469: Fixed issue, ouwt now invalidates tree if user orgunit changes
------------------------------------------------------------
revno: 4469
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Sat 2011-08-27 16:03:43 +0200
message:
Fixed issue, ouwt now invalidates tree if user orgunit changes
modified:
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/ouwt/ouwt.js'
--- dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-27 12:58:08 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-08-27 14:03:43 +0000
@@ -81,8 +81,31 @@
$( "#ouwt_loader" ).hide();
}
-
- var version = localStorage[getTagId( "Version" )];
+
+ function update_required( remoteVersion, remoteRoots )
+ {
+ var localVersion = localStorage[getTagId( "Version" )] ? localStorage[getTagId( "Version" )] : 0;
+ var localRoots = localStorage[getTagId( "Roots" )] ? localStorage[getTagId( "Roots" )] : [];
+
+ if ( localVersion != remoteVersion )
+ {
+ return true;
+ }
+
+ localRoots.sort();
+ remoteRoots.sort();
+
+ for ( var i in localRoots )
+ {
+ if ( remoteRoots[i] == null || localRoots[i] != remoteRoots[i] )
+ {
+ return true;
+ }
+ }
+
+ return false;
+ }
+
var should_update = false;
$.post( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action', {
@@ -92,11 +115,7 @@
if ( data.indexOf( "<!DOCTYPE" ) != 0 )
{
data = JSON.parse( data );
-
- if ( version != data.version )
- {
- should_update = true;
- }
+ should_update = update_required();
}
}, "text" ).complete(
function()