← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17030: OUWT. Added trigger for selection of org unit

 

------------------------------------------------------------
revno: 17030
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Fri 2014-10-10 09:41:20 +0200
message:
  OUWT. Added trigger for selection of org unit
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-29 17:32:30 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js	2014-10-10 07:41:20 +0000
@@ -15,7 +15,7 @@
  * selection.setMultipleSelectionAllowed function to change this.
  */
 
-var organisationUnitTreePath = '../dhis-web-commons/ouwt/';
+var organisationUnitTreePath = "../dhis-web-commons/ouwt/";
 var organisationUnits = {};
 
 var selection = new Selection();
@@ -23,6 +23,7 @@
 
 var dhis2 = dhis2 || {};
 dhis2.ou = dhis2.ou || {};
+dhis2.ou.event = dhis2.ou.event || {};
 
 var OU_STORE_NAME = "dhis2ou";
 var OU_KEY = "ou";
@@ -32,6 +33,8 @@
 var OU_USERNAME_KEY = "ouUsername";
 var OU_SELECTED_KEY = "ouSelected";
 
+dhis2.ou.event.orgUnitSelected = "dhis2.ou.event.orgUnitSelected";
+
 dhis2.ou.store = null;
 dhis2.ou.memoryOnly = $('html').hasClass('ie7') || $('html').hasClass('ie8');
 
@@ -549,10 +552,6 @@
     };
 
     this.responseReceived = function() {
-        if( typeof listenerFunction !== 'function') {
-            return;
-        }
-
         var children = [];
         var ids = [];
         var names = [];
@@ -565,7 +564,11 @@
                 names.push( name );
             } );
 
-            listenerFunction( ids, names, children );
+            $( "#orgUnitTree" ).trigger( dhis2.ou.event.orgUnitSelected, [ids, names, children] );
+            
+            if( typeof listenerFunction === 'function') {
+            	listenerFunction( ids, names, children );
+            }
         } else {
             selected = selected[0];
 
@@ -579,7 +582,11 @@
                 ids.push( selected );
                 names.push( name );
 
-                listenerFunction( ids, names, children );
+                $( "#orgUnitTree" ).trigger( dhis2.ou.event.orgUnitSelected, [ids, names, children] );
+                
+                if( typeof listenerFunction === 'function') {
+                	listenerFunction( ids, names, children );
+                }                
             }
         }
     };