Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJeffrey Fisher <jeffrey.fisher@rtspecialty.com>2018-06-12 14:52:36 -0400
committerJeffrey Fisher <jeffrey.fisher@rtspecialty.com>2018-06-19 10:28:48 -0400
commit3e32442a43cf586ca1c662f1e379d9e99025f634 (patch)
tree38c04ee37a5734fcfe48b5d0d6995cd8ea53d9fc
parent345e570e67c3d92b5228053fad89128f565daa4c (diff)
downloadliza-3e32442a43cf586ca1c662f1e379d9e99025f634.tar.gz
liza-3e32442a43cf586ca1c662f1e379d9e99025f634.tar.bz2
liza-3e32442a43cf586ca1c662f1e379d9e99025f634.zip
[DEV-3192] fixed default value initialization
-rw-r--r--src/program/ProgramInit.js43
1 files changed, 22 insertions, 21 deletions
diff --git a/src/program/ProgramInit.js b/src/program/ProgramInit.js
index 9d76a69..a4eb634 100644
--- a/src/program/ProgramInit.js
+++ b/src/program/ProgramInit.js
@@ -66,34 +66,35 @@ module.exports = Class( 'ProgramInit',
while ( length-- )
{
var field = program.groupExclusiveFields[ group ][ length ],
- defaultValue;
+ defaultValue = {};
if ( defaults.hasOwnProperty(field) )
{
defaultValue = defaults[ field ];
- // Initialize with existing document data if any
- data[ field ] = doc_data[ field ] ? doc_data[ field ] : [];
+ }
- // If no document data, initialize with default value
- if ( !doc_data[ field ] )
- {
- data[ field ][ 0 ] = defaultValue;
- }
+ // Initialize with existing document data if any
+ data[ field ] = doc_data[ field ] ? doc_data[ field ] : [];
- // If min rows on the group is greater than the data
- // currently in the bucket, then populate the rest
- // of the data with the default data until the
- // arrays are the same length
- if ( groups.hasOwnProperty( group ) &&
- data[ field ].length < groups[ group ].min )
- {
- var index = data[ field ].length;
+ // If no document data, initialize with default value
+ if ( !doc_data[ field ] )
+ {
+ data[ field ][ 0 ] = defaultValue;
+ }
+
+ // If min rows on the group is greater than the data
+ // currently in the bucket, then populate the rest
+ // of the data with the default data until the
+ // arrays are the same length
+ if ( groups.hasOwnProperty( group ) &&
+ data[ field ].length < groups[ group ].min )
+ {
+ var index = data[ field ].length;
- while ( index < groups[ group ].min )
- {
- data[ field ][ index ] = defaultValue;
- index++;
- }
+ while ( index < groups[ group ].min )
+ {
+ data[ field ][ index ] = defaultValue;
+ index++;
}
}
}