dhis2-devs team mailing list archive
-
dhis2-devs team
-
Mailing list archive
-
Message #23780
[Branch ~dhis2-devs-core/dhis2/trunk] Rev 11586: in aggregated entry, only load optionsets into browser-store if optionset isnt already loaded, or...
------------------------------------------------------------
revno: 11586
committer: Morten Olav Hansen <mortenoh@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2013-08-06 14:28:56 +0700
message:
in aggregated entry, only load optionsets into browser-store if optionset isnt already loaded, or optionset.version !== stored.version
modified:
dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js
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/responseMetaData.vm
--
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-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js'
--- dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-08-06 06:45:39 +0000
+++ dhis-2/dhis-web/dhis-web-caseentry/src/main/webapp/dhis-web-caseentry/javascript/anonymousRegistration.js 2013-08-06 07:28:56 +0000
@@ -76,8 +76,7 @@
_.each( metaData.optionSets, function ( item, idx ) {
DAO.store.get('optionSets', item.uid).done(function(obj) {
- if(typeof obj === 'undefined' || obj.optionSet.version !== item.v) {
- console.log('loading ', item);
+ if(!obj || obj.optionSet.version !== item.v) {
promise = promise.then(function() {
return $.ajax({
url: 'getOptionSet.action',
@@ -93,8 +92,6 @@
DAO.store.set('optionSets', obj);
});
});
- } else {
- console.log('skipping ', item);
}
});
} );
=== 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 2013-07-20 12:35:56 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js 2013-08-06 07:28:56 +0000
@@ -2181,27 +2181,35 @@
}
function loadOptionSets() {
- var optionSetUids = _.values( optionSets );
- optionSetUids = _.union(optionSetUids);
+ var options = _.values( optionSets );
+ var uids = [];
var deferred = $.Deferred();
var promise = deferred.promise();
- _.each( optionSetUids, function ( item, idx ) {
- promise = promise.then( function () {
- return $.ajax( {
- url: '../api/optionSets/' + item + '.json?links=false',
- type: 'GET',
- cache: false
- } ).done( function ( data ) {
- log( 'Successfully stored optionSet: ' + item );
-
- var obj = {};
- obj.id = item;
- obj.optionSet = data;
- DAO.store.set( 'optionSets', obj );
- } );
- } );
+ _.each( options, function ( item, idx ) {
+ if(uids.indexOf(item.uid) == -1) {
+ DAO.store.get('optionSets', item.uid).done(function(obj) {
+ if(!obj || obj.optionSet.version !== item.v) {
+ promise = promise.then( function () {
+ return $.ajax( {
+ url: '../api/optionSets/' + item.uid + '.json?links=false',
+ type: 'GET',
+ cache: false
+ } ).done( function ( data ) {
+ log( 'Successfully stored optionSet: ' + item.uid );
+
+ var obj = {};
+ obj.id = item.uid;
+ obj.optionSet = data;
+ DAO.store.set( 'optionSets', obj );
+ } );
+ } );
+
+ uids.push( item.uid );
+ }
+ });
+ }
} );
promise = promise.then( function () {
@@ -2223,7 +2231,7 @@
item = item + '-val';
optionSetKey = optionSetKey.dataElementId + '-' + optionSetKey.optionComboId;
- autocompleteOptionSetField( item, optionSets[optionSetKey] );
+ autocompleteOptionSetField( item, optionSets[optionSetKey].uid );
} );
}
=== modified file 'dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm'
--- dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2013-07-09 04:09:21 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/responseMetaData.vm 2013-08-06 07:28:56 +0000
@@ -16,7 +16,7 @@
"optionSets": {
#set( $size = $dataElementsWithOptionSet.size() )
#foreach( $dataElement in $dataElementsWithOptionSet )
-"${dataElement.uid}-${dataElement.categoryCombo.getSortedOptionCombos().get(0).uid}":"$encoder.jsonEncode( ${dataElement.optionSet.uid} )"
+"${dataElement.uid}-${dataElement.categoryCombo.getSortedOptionCombos().get(0).uid}":{"uid": "$encoder.jsonEncode( ${dataElement.optionSet.uid} )", "v":${dataElement.optionSet.version}}
#if( $velocityCount < $size ),#end
#end },