dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #31279
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 15925: support selection blocking in ouwt
------------------------------------------------------------
revno: 15925
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-07-01 16:23:39 +0800
message:
support selection blocking in ouwt
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 2014-05-06 18:47:55 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2014-07-01 08:23:39 +0000
@@ -80,6 +80,7 @@
var autoSelectRoot = true;
var realRoot = true;
var includeChildren = false;
+ var blockedLevels = [];
this.setListenerFunction = function( listenerFunction_, skipInitialCall ) {
listenerFunction = listenerFunction_;
@@ -91,6 +92,32 @@
}
};
+ this.addBlockedLevel = function(level) {
+ if( $.isArray(level) ) {
+ $.each(level, function(idx, item) {
+ blockedLevels.push(item);
+ });
+ } else {
+ blockedLevels.push(level);
+ }
+
+ this.updateBlockedLevels();
+ };
+
+ this.getBlockedLevels = function() {
+ return blockedLevels;
+ };
+
+ this.updateBlockedLevels = function() {
+ $('#orgUnitTree').find('a').css('color', 'black');
+
+ $.each(blockedLevels, function( idx, item ) {
+ $('#orgUnitTree li[level=' + item + '] > a').css({
+ cursor: 'not-allowed'
+ }).removeAttr('href');
+ })
+ };
+
this.setMultipleSelectionAllowed = function( allowed ) {
multipleSelectionAllowed = allowed;
};
@@ -708,6 +735,8 @@
expandTreeAtOrgUnits( selected );
selectOrgUnits( selected );
+
+ selection.updateBlockedLevels();
};
// force reload
@@ -738,7 +767,7 @@
}
this.ajaxGetChildren = function( parentId ) {
- return $.post( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action?parentId=' + parentId );
+ return $.post( '../dhis-web-commons-ajax-json/getOrganisationUnitTree.action?parentId=' + parentId);
};
this.getChildren = function( parentId ) {
@@ -788,6 +817,7 @@
if( 'undefined' !== typeof organisationUnits[parent.c[0]] ) {
createChildren( parentTag, parent );
def.resolve();
+ selection.updateBlockedLevels();
}
else {
selection.getOrganisationUnit( parent.c[0] ).done(function(item) {
@@ -795,11 +825,14 @@
$.extend( organisationUnits, item );
createChildren( parentTag, parent );
def.resolve();
+ selection.updateBlockedLevels();
} else {
subtree.getChildren( parent.id ).done( function() {
createChildren( parentTag, parent );
def.resolve();
- } );
+ }).always(function() {
+ selection.updateBlockedLevels();
+ });
}
});
}
@@ -843,6 +876,7 @@
var $childTag = $( "<li/>" );
$childTag.attr( "id", getTagId( ou.id ) );
+ $childTag.attr( "level", ou.l );
$childTag.append( " " );
$childTag.append( $toggleTag );
$childTag.append( " " );