Added migration to fix caclulation changes
Migrate `.currentValue` to `.value` and `.value` to `.total`
This commit is contained in:
@@ -170,7 +170,7 @@ const transformsByPropType = {
|
|||||||
function getComputedPropertyTransforms(key, toKey){
|
function getComputedPropertyTransforms(key, toKey){
|
||||||
if (!toKey) toKey = key;
|
if (!toKey) toKey = key;
|
||||||
return [
|
return [
|
||||||
{from: key, to: `${key}.calculation`},
|
{from: key, to: `${key}.calculation`, up: calculationUp, down: calculationDown},
|
||||||
{from: `${key}Result`, to: `${toKey}.value`, up: nanToNull},
|
{from: `${key}Result`, to: `${toKey}.value`, up: nanToNull},
|
||||||
{from: `${key}Errors`, to: `${toKey}.errors`, up: trimErrors},
|
{from: `${key}Errors`, to: `${toKey}.errors`, up: trimErrors},
|
||||||
];
|
];
|
||||||
@@ -179,11 +179,20 @@ function getComputedPropertyTransforms(key, toKey){
|
|||||||
function getInlineComputationTransforms(key){
|
function getInlineComputationTransforms(key){
|
||||||
return [
|
return [
|
||||||
{from: key, to: `${key}.text`},
|
{from: key, to: `${key}.text`},
|
||||||
{from: `${key}Calculations`, to: `${key}.inlineCalculations`},
|
{from: `${key}Calculations`, to: `${key}.inlineCalculations`, up: calculationUp, down: calculationDown},
|
||||||
{from: `${key}Calculations.$.result`, to: `${key}.inlineCalculations.$.value`},
|
{from: `${key}Calculations.$.result`, to: `${key}.inlineCalculations.$.value`},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function calculationUp(val){
|
||||||
|
if (!val) return val;
|
||||||
|
return val.replace('.value', '.total').replace('.currentValue', '.value');
|
||||||
|
}
|
||||||
|
|
||||||
|
function calculationDown(val){
|
||||||
|
return val.replace('.value', '.currentValue').replace('.total', '.value');
|
||||||
|
}
|
||||||
|
|
||||||
function nanToNull(val){
|
function nanToNull(val){
|
||||||
if (Number.isNaN(val)){
|
if (Number.isNaN(val)){
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
Reference in New Issue
Block a user