dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #32933
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 16744: disable selection while setting server state in ouwt
------------------------------------------------------------
revno: 16744
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Thu 2014-09-18 17:53:08 +0700
message:
disable selection while setting server state 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-09-17 10:16:52 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2014-09-18 10:53:08 +0000
@@ -285,6 +285,20 @@
} );
};
+ this.busy = function( busy ) {
+ if( busy ) {
+ $("#orgUnitTree").css("cursor", "wait")
+ .find("a").css("cursor", "wait");
+ } else {
+ $("#orgUnitTree").css("cursor", "auto")
+ .find("a").css("cursor", "auto");
+ }
+ };
+
+ this.isBusy = function() {
+ return $("#orgUnitTree").css("cursor") == "wait";
+ };
+
this.load = function ()
{
function sync_and_reload()
@@ -411,6 +425,8 @@
subtree.reloadTree();
} );
} else {
+ selection.busy( true );
+
$.post( organisationUnitTreePath + "clearselected.action", function() {
var selected = selection.getSelected();
@@ -429,13 +445,18 @@
url: organisationUnitTreePath + "addorgunit.action",
data: q,
type: 'POST'
+ } ).complete( function() {
+ selection.busy( false );
});
} else {
selected = $.isArray( selected ) ? selected[0] : selected;
$.post( organisationUnitTreePath + "setorgunit.action", {
id: selected
- } ).complete( fn );
+ } ).complete( function() {
+ selection.busy( false );
+ fn();
+ } );
}
} );
}
@@ -453,6 +474,10 @@
};
this.select = function( unitId ) {
+ if( selection.isBusy() ) {
+ return;
+ }
+
var $linkTag = $( "#" + getTagId( unitId ) ).find( "a" ).eq( 0 );
if( $linkTag.hasClass( "selected" ) && ( unselectAllowed || rootUnselectAllowed ) ) {
@@ -488,9 +513,14 @@
selection.clearSelected();
}
+ selection.busy( true );
+
$.post( organisationUnitTreePath + "removeorgunit.action", {
id: unitId
- } ).complete( this.responseReceived );
+ } ).complete( function() {
+ selection.busy( false );
+ selection.responseReceived();
+ });
$linkTag.removeClass( "selected" );
} else {
@@ -504,9 +534,14 @@
selected.push( unitId );
selection.setSelected( selected );
+ selection.busy( true );
+
$.post( organisationUnitTreePath + "addorgunit.action", {
id: unitId
- } ).complete( this.responseReceived );
+ } ).complete( function() {
+ selection.busy( false );
+ selection.responseReceived();
+ });
$linkTag.addClass( "selected" );
}
@@ -514,6 +549,8 @@
{
selection.setSelected( unitId );
+ selection.busy( true );
+
$.ajax( {
url:organisationUnitTreePath + "setorgunit.action",
data:{
@@ -521,7 +558,10 @@
},
type:'POST',
timeout:10000,
- complete:this.responseReceived
+ complete: function() {
+ selection.busy(false);
+ selection.responseReceived();
+ }
} );
$( "#orgUnitTree" ).find( "a" ).removeClass( "selected" );