← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17515: Ouwt / data entry. Passing currently selected org unit ids/names in trigger, which avoids nasty e...

 

------------------------------------------------------------
revno: 17515
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Mon 2014-11-17 22:59:40 +0100
message:
  Ouwt / data entry. Passing currently selected org unit ids/names in trigger, which avoids nasty explicit call to responseReceived.
modified:
  dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js
  dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.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-11-17 20:47:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2014-11-17 21:59:40 +0000
@@ -314,8 +314,18 @@
                     selection.sync();
                     subtree.reloadTree();
 
+                    var ids = [];
+                    var names = [];
+
+                    $.each( selection.getSelected(), function( i, id ) {
+                    	var ou = organisationUnits[id];
+                        var name = !!ou ? ou.n : '';
+                        ids.push( id );
+                        names.push( name );
+                    } );
+                    
                     $( "#ouwt_loader" ).hide();
-                    $( "#orgUnitTree" ).trigger( "ouwtLoaded" );
+                    $( "#orgUnitTree" ).trigger( "ouwtLoaded", [ids, names] );
                 } );
             } );
         }

=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-17 17:24:22 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-11-17 21:59:40 +0000
@@ -154,8 +154,6 @@
     };
 } )( jQuery );
 
-selection.setListenerFunction( organisationUnitSelected );
-
 /**
  * Page init. The order of events is:
  *
@@ -171,12 +169,13 @@
 
     $( '#loaderSpan' ).show();
 
-    $( '#orgUnitTree' ).one( 'ouwtLoaded', function()
+    $( '#orgUnitTree' ).one( 'ouwtLoaded', function( event, ids, names )
     {
         console.log( 'Ouwt loaded' );
         
         $.when( dhis2.de.loadMetaData(), dhis2.de.loadDataSetAssociations() ).done( function() {
         	dhis2.de.setMetaDataLoaded();
+        	organisationUnitSelected( ids, names );
         } );
     } );
 
@@ -311,7 +310,6 @@
 dhis2.de.setMetaDataLoaded = function()
 {
     dhis2.de.metaDataIsLoaded = true;
-    selection.responseReceived(); // Notify that meta data is loaded
     $( '#loaderSpan' ).hide();
     console.log( 'Meta-data loaded' );