Skip to content

Commit

Permalink
Add string to number conversion to completeConfiguration.
Browse files Browse the repository at this point in the history
  • Loading branch information
danielwippermann committed Apr 23, 2014
1 parent 8a5a230 commit 2a59933
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/base-configuration-optimizer.js
Expand Up @@ -277,9 +277,25 @@ var BaseConfigurationOptimizer = ConfigurationOptimizer.extend({
throw new Error('Unable to complete value ' + JSON.stringify({ key: key, value: value }));
}

var numericValue = value.value;
if (_.isString(numericValue)) {
if (numericValue.charAt(0) === '#') {
var valueTextId = numericValue.slice(1);
var valueText = refValue.valueTextById [valueTextId];
if (valueText !== undefined) {
numericValue = valueText;
} else {
throw new Error('Unable to convert value text ID to numeric value: ' + JSON.stringify(numericValue));
}
} else {
numericValue = numericValue | 0;
}
}

var configValue = _.extend({}, value, {
valueId: refValue.id,
valueIndex: refValue.index,
value: numericValue,
priority: refValue.priority || 0,
valueTextById: refValue.valueTextById,
});
Expand Down

0 comments on commit 2a59933

Please sign in to comment.