← Back to team overview

dhis2-devs team mailing list archive

[Branch ~dhis2-devs-core/dhis2/trunk] Rev 17305: Data entry, better checks for option set versions

 

------------------------------------------------------------
revno: 17305
committer: Lars Helge Overland <larshelge@xxxxxxxxx>
branch nick: dhis2
timestamp: Tue 2014-10-28 12:22:52 -0400
message:
  Data entry, better checks for option set versions
modified:
  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-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-10-26 18:21:11 +0000
+++ dhis-2/dhis-web/dhis-web-dataentry/src/main/webapp/dhis-web-dataentry/javascript/form.js	2014-10-28 16:22:52 +0000
@@ -2760,7 +2760,7 @@
 {
     if ( window.DAO !== undefined && window.DAO.store !== undefined ) {
         DAO.store.get( 'optionSets', uid ).done( function ( obj ) {
-            if ( obj ) {
+            if ( obj && obj.optionSet ) {
                 var options = [];
 
                 if ( query == null || query == '' ) {
@@ -2838,14 +2838,14 @@
     _.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 ) {
+                if( !obj || !obj.optionSet || !obj.optionSet.version || !item.v || 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 ) {
-                          console.log( 'Successfully stored optionSet: ' + item.uid );
+                            console.log( 'Successfully stored optionSet: ' + item.uid );
 
                             var obj = {};
                             obj.id = item.uid;