dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #33556
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17143: minor fix in ouwt, if selection === 0, wait 1s to make sure that all promises have finished (this...
------------------------------------------------------------
revno: 17143
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-17 13:19:47 +0700
message:
minor fix in ouwt, if selection === 0, wait 1s to make sure that all promises have finished (this bug is only visible in cases where hundres of OUs are selected)
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-10-10 14:03:12 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2014-10-17 06:19:47 +0000
@@ -403,43 +403,51 @@
} else {
selection.busy( true );
- $.ajax( {
- url: organisationUnitTreePath + "clearselected.action",
- type: 'POST'
- }).done(function() {
- var selected = selection.getSelected();
-
- if( multipleSelectionAllowed ) {
- var q = '';
-
- $.each( selected, function( i, item ) {
- q += "id=" + item;
-
- if( i < (selected.length - 1) ) {
- q += '&';
- }
- });
-
- $.ajax({
- 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( function() {
- selection.busy( false );
- fn();
- } );
- }
- }).always(function() {
- selection.busy( false );
- });
+ if( selection.getSelected() && selection.getSelected().length === 0 ) {
+ setTimeout(doSync, 1000);
+ } else {
+ doSync();
+ }
+
+ function doSync() {
+ $.ajax( {
+ url: organisationUnitTreePath + "clearselected.action",
+ type: 'POST'
+ }).done(function() {
+ var selected = selection.getSelected();
+
+ if( multipleSelectionAllowed ) {
+ var q = '';
+
+ $.each( selected, function( i, item ) {
+ q += "id=" + item;
+
+ if( i < (selected.length - 1) ) {
+ q += '&';
+ }
+ });
+
+ $.ajax({
+ 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( function() {
+ selection.busy( false );
+ fn();
+ } );
+ }
+ }).always(function() {
+ selection.busy( false );
+ });
+ }
}
};