Skip to content

Commit

Permalink
Merge pull request edp963#1993 from scottsut/controls
Browse files Browse the repository at this point in the history
fix(Control): Bugs caused by missing related variables
  • Loading branch information
ruanhan authored Oct 29, 2020
2 parents 3bcece3 + 06abc4b commit 95ee2d1
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions webapp/app/components/Control/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit 95ee2d1

Please sign in to comment.