dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #36814
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 18826: ouwt/de offline level bugfix, make sure to download additional dataset association data for multi...
------------------------------------------------------------
revno: 18826
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Wed 2015-04-08 16:55:13 +0700
message:
ouwt/de offline level bugfix, make sure to download additional dataset association data for multiorg forms (ou children)
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 2015-03-30 16:22:29 +0000
+++ dhis-2/dhis-web/dhis-web-commons-resources/src/main/webapp/dhis-web-commons/ouwt/ouwt.js 2015-04-08 09:55:13 +0000
@@ -745,7 +745,7 @@
};
var expandTreeAtOrgUnit = function( ou, select ) {
- select = select || false;
+ select = select || false;
if( organisationUnits[ou] == null ) {
subtree.ajaxGetLeaf(ou).done(function( data ) {
@@ -851,6 +851,7 @@
var def = $.Deferred();
subtree.ajaxGetChildren( parentId ).done(function( data ) {
+ $('#orgUnitTree').trigger('dhis2.ouwt.childrenLoaded', parentId);
def.resolveWith( window, [ data ] );
});
=== 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 2015-03-27 14:46:32 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2015-04-08 09:55:13 +0000
@@ -74,6 +74,9 @@
// Indicates whether current form is multi org unit
dhis2.de.multiOrganisationUnit = false;
+// List of parent for which we have fetched dataSet associations, used to optimize dhis2.de.fetchDataSets
+dhis2.de.fetchedChildren = [];
+
// "organisationUnits" object inherited from ouwt.js
// Constants
@@ -222,6 +225,12 @@
$.when( dhis2.de.getMultiOrgUnitSetting(), dhis2.de.loadMetaData(), dhis2.de.loadDataSetAssociations() ).done( function() {
dhis2.de.setMetaDataLoaded();
organisationUnitSelected( ids, names );
+
+ $('#orgUnitTree').on('dhis2.ouwt.childrenLoaded', function(e, ou) {
+ dhis2.de.fetchDataSets(ou).done(function() {
+ selection.responseReceived();
+ })
+ });
} );
} );
} );
@@ -980,21 +989,26 @@
{
var def = $.Deferred();
- $.ajax({
- type: 'GET',
- url: '../api/organisationUnits/' + ou,
- data: {
- fields: 'id,dataSets[id],children[id,dataSets[id]]'
- }
- }).done(function(data) {
- dhis2.de._updateDataSets(data);
-
- data.children.forEach(function( item ) {
- dhis2.de._updateDataSets(item);
+ if( dhis2.de.fetchedChildren.indexOf(ou) != -1 ) {
+ def.resolve();
+ } else {
+ $.ajax({
+ type: 'GET',
+ url: '../api/organisationUnits/' + ou,
+ data: {
+ fields: 'id,dataSets[id],children[id,dataSets[id]]'
+ }
+ }).done(function(data) {
+ dhis2.de._updateDataSets(data);
+
+ data.children.forEach(function( item ) {
+ dhis2.de._updateDataSets(item);
+ });
+
+ dhis2.de.fetchedChildren.push(ou);
+ def.resolve(data);
});
-
- def.resolve(data);
- });
+ }
return def.promise();
};