Skip to content

Commit

Permalink
fix(control): cascading filters logic
Browse files Browse the repository at this point in the history
  • Loading branch information
scottsut committed Oct 27, 2020
1 parent f02cb52 commit 4d541d9
Showing 1 changed file with 9 additions and 33 deletions.
42 changes: 9 additions & 33 deletions webapp/app/components/Control/Panel/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ class ControlPanel extends PureComponent<
// get cascading conditions
Object.entries(relatedViews).forEach(([viewId, relatedView]) => {
let filters = []
let variables = []
const variables = []

parents.forEach((parentControl) => {
const parentValue = controlValues[parentControl.key]
Expand Down Expand Up @@ -212,39 +212,15 @@ class ControlPanel extends PureComponent<
cascadeRelatedFields &&
formedViews[cascadeRelatedViewId]
) {
const { model, variable } = formedViews[cascadeRelatedViewId]
if (parentControl.optionWithVariable) {
variables = variables.concat(
getCustomOptionVariableParams(
parentControl,
Number(cascadeRelatedViewId),
parentValue,
variable
)
const { model } = formedViews[cascadeRelatedViewId]
filters = filters.concat(
getFilterParams(
parentControl,
cascadeRelatedFields,
parentValue,
model
)
} else {
if (
parentRelatedView.fieldType === ControlFieldTypes.Column
) {
filters = filters.concat(
getFilterParams(
parentControl,
cascadeRelatedFields,
parentValue,
model
)
)
} else {
variables = variables.concat(
getVariableParams(
parentControl,
cascadeRelatedFields,
parentValue,
variable
)
)
}
}
)
}
}
}
Expand Down

0 comments on commit 4d541d9

Please sign in to comment.