← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 21517: event-capture: meta-data loading better performance - completed

 

------------------------------------------------------------
revno: 21517
committer: Abyot Asalefew Gizaw <abyota@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2015-12-22 14:43:14 +0100
message:
  event-capture: meta-data loading better performance - completed
modified:
  dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.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-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js'
--- dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-12-22 13:24:59 +0000
+++ dhis-2/dhis-web/dhis-web-apps/src/main/webapp/dhis-web-event-capture/scripts/event-capture.js	2015-12-22 13:43:14 +0000
@@ -367,7 +367,6 @@
                         dhis2.ec.store.get('optionSets', prStDe.dataElement.optionSet.id).done(function(obj) {
                             if( (!obj || obj.version !== prStDe.dataElement.optionSet.version) && optionSetsInPromise.indexOf(prStDe.dataElement.optionSet.id) === -1) {
                                 optionSetsInPromise.push( prStDe.dataElement.optionSet.id );
-                                promise = promise.then( getD2Object( prStDe.dataElement.optionSet.id, 'optionSets', '../api/optionSets', 'fields=id,name,version,options[id,name,code]', 'idb' ) );
                             }
                             d.resolve();
                         });
@@ -383,6 +382,18 @@
         def.resolve();
 
         promise = promise.done( function () {
+            
+            if( optionSetsInPromise && optionSetsInPromise.length > 0 ){
+                var _optionSetsInPromise = optionSetsInPromise.toString();
+                _optionSetsInPromise = '[' + _optionSetsInPromise + ']';
+                
+                var filter = 'fields=id,name,version,options[id,name,code]';                
+                filter = filter + '&filter=id:in:' + _optionSetsInPromise + '&paging=false';
+                
+                var url = '../api/optionSets';
+                promise = promise.then( getD2Objects( 'optionSets', 'optionSets', url, filter ) );
+            }
+            
             mainDef.resolve( programs );
         } );
     }).fail(function(){
@@ -397,7 +408,7 @@
 function getMetaProgramValidations( programs, programIds )
 {
     programs.programIds = programIds;
-    return getD2MetaObject(programs, 'programValidations', '../api/programValidations.json', 'paging=false&fields=id&filter=program.id:in:');
+    return getD2MetaObjects(programs, 'programValidations', '../api/programValidations.json', 'paging=false&fields=id&filter=program.id:in:');
 }
 
 function getProgramValidations( programValidations )
@@ -407,7 +418,7 @@
 
 function getMetaProgramIndicators( programs )
 {   
-    return getD2MetaObject(programs, 'programIndicators', '../api/programIndicators.json', 'paging=false&fields=id&filter=program.id:in:');
+    return getD2MetaObjects(programs, 'programIndicators', '../api/programIndicators.json', 'paging=false&fields=id&filter=program.id:in:');
 }
 
 function getProgramIndicators( programIndicators )
@@ -417,7 +428,7 @@
 
 function getMetaProgramRules( programs )
 {
-    return getD2MetaObject(programs, 'programRules', '../api/programRules.json', 'paging=false&fields=id&filter=program.id:in:');
+    return getD2MetaObjects(programs, 'programRules', '../api/programRules.json', 'paging=false&fields=id&filter=program.id:in:');
 }
 
 function getProgramRules( programRules )
@@ -427,7 +438,7 @@
 
 function getMetaProgramRuleVariables( programs )
 {    
-    return getD2MetaObject(programs, 'programRuleVariables', '../api/programRuleVariables.json', 'paging=false&fields=id&filter=program.id:in:');
+    return getD2MetaObjects(programs, 'programRuleVariables', '../api/programRuleVariables.json', 'paging=false&fields=id&filter=program.id:in:');
 }
 
 function getProgramRuleVariables( programRuleVariables )
@@ -435,7 +446,7 @@
     return checkAndGetD2Objects( programRuleVariables, 'programRuleVariables', '../api/programRuleVariables', 'fields=id,name,name,programRuleVariableSourceType,program[id],programStage[id],dataElement[id]');
 }
 
-function getD2MetaObject( programs, objNames, url, filter )
+function getD2MetaObjects( programs, objNames, url, filter )
 {
     if( !programs || !programs.programIds){
         return;