From 06abc4ba8c244bbad059e22281f1303fbcfe0662 Mon Sep 17 00:00:00 2001 From: ScottSut Date: Thu, 29 Oct 2020 12:51:21 +0800 Subject: [PATCH] fix(Control): Bugs caused by missing related variables --- webapp/app/components/Control/util.ts | 19 +++++++++++-------- 1 file changed, 11 insertions(+), 8 deletions(-) diff --git a/webapp/app/components/Control/util.ts b/webapp/app/components/Control/util.ts index 9a0b98294..0792b64f0 100644 --- a/webapp/app/components/Control/util.ts +++ b/webapp/app/components/Control/util.ts @@ -155,7 +155,7 @@ export function getVariableParams( case ControlTypes.NumberRange: case ControlTypes.Slider: params = value.reduce((arr, val, index) => { - if (val !== '' && !isNaN(val)) { + if (fieldsVariables[index] && val !== '' && !isNaN(val)) { const { name, valueType } = fieldsVariables[index] return arr.concat({ name, @@ -183,13 +183,16 @@ export function getVariableParams( break case ControlTypes.DateRange: if (value.length) { - params = value.map((v, index) => { - const { name } = fieldsVariables[index] - return { - name, - value: `'${moment(v).format(dateFormat)}'` - } - }) + params = value + .map((v, index) => { + return fieldsVariables[index] + ? { + name: fieldsVariables[index].name, + value: `'${moment(v).format(dateFormat)}'` + } + : null + }) + .filter((p) => p) } break default: