dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #15051
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 5281: ouwt: added option for allowing unselect of root, also added option for disabling autoSelectRoot
------------------------------------------------------------
revno: 5281
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Sun 2011-12-04 12:08:52 +0100
message:
ouwt: added option for allowing unselect of root, also added option for disabling autoSelectRoot
modified:
dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.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-10-21 10:46:54 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2011-12-04 11:08:52 +0000
@@ -31,7 +31,11 @@
function Selection()
{
- var listenerFunction = undefined, multipleSelectionAllowed = false, unselectAllowed = false;
+ var listenerFunction = undefined;
+ var multipleSelectionAllowed = false;
+ var unselectAllowed = false;
+ var rootUnselectAllowed = false;
+ var autoSelectRoot = true;
this.setListenerFunction = function( listenerFunction_, skipInitialCall )
{
@@ -56,6 +60,16 @@
unselectAllowed = allowed;
};
+ this.setRootUnselectAllowed = function( allowed )
+ {
+ rootUnselectAllowed = allowed;
+ };
+
+ this.setAutoSelectRoot = function( autoSelect )
+ {
+ autoSelectRoot = autoSelect;
+ };
+
this.load = function()
{
function sync_and_reload()
@@ -64,13 +78,16 @@
if ( sessionStorage[getTagId( "Selected" )] == null && roots.length > 0 )
{
- if ( multipleSelectionAllowed )
- {
- sessionStorage[getTagId( "Selected" )] = roots;
- }
- else
- {
- sessionStorage[getTagId( "Selected" )] = roots[0];
+ if( autoSelectRoot )
+ {
+ if ( multipleSelectionAllowed )
+ {
+ sessionStorage[getTagId( "Selected" )] = roots;
+ }
+ else
+ {
+ sessionStorage[getTagId( "Selected" )] = roots[0];
+ }
}
}
@@ -252,10 +269,21 @@
{
var $linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
- if ( $linkTag.hasClass( "selected" ) && unselectAllowed )
+ if ( $linkTag.hasClass( "selected" ) && ( unselectAllowed || rootUnselectAllowed ) )
{
var selected = JSON.parse( sessionStorage[getTagId( "Selected" )] );
+ if( rootUnselectAllowed && !unselectAllowed && !multipleSelectionAllowed )
+ {
+ var roots = JSON.parse( localStorage[getTagId( "Roots" )] );
+
+ if( roots != selected )
+ {
+ console.log("They are not equal.. do nothing")
+ return;
+ }
+ }
+
if ( !!selected && $.isArray( selected ) )
{
var idx = undefined;
=== modified file 'dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js'
--- dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2011-09-27 08:37:54 +0000
+++ dhis-2/dhis-web/dhis-web-maintenance/dhis-web-maintenance-organisationunit/src/main/webapp/dhis-web-maintenance-organisationunit/javascript/organisationUnit.js 2011-12-04 11:08:52 +0000
@@ -4,6 +4,8 @@
$( document ).ready( function()
{
+ selection.setAutoSelectRoot( false );
+ selection.setRootUnselectAllowed( true );
selection.setListenerFunction( organisationUnitSelected, true );
} );