Simplify reactive logic
This commit is contained in:
parent
9149828c7c
commit
c58ac5810e
|
@ -28,11 +28,10 @@
|
||||||
|
|
||||||
$: id = $component.id
|
$: id = $component.id
|
||||||
$: selected = $component.selected
|
$: selected = $component.selected
|
||||||
$: inBuilder = $builderStore.inBuilder
|
|
||||||
$: builderStep = $builderStore.metadata?.step
|
$: builderStep = $builderStore.metadata?.step
|
||||||
$: fetchSchema(dataSource)
|
$: fetchSchema(dataSource)
|
||||||
$: enrichedSteps = enrichSteps(steps, schema, id)
|
$: enrichedSteps = enrichSteps(steps, schema, id)
|
||||||
$: updateCurrentStep(enrichedSteps, selected, inBuilder, builderStep)
|
$: updateCurrentStep(enrichedSteps, selected, builderStep)
|
||||||
|
|
||||||
// Provide additional data context for live binding eval
|
// Provide additional data context for live binding eval
|
||||||
export const getAdditionalDataContext = () => {
|
export const getAdditionalDataContext = () => {
|
||||||
|
@ -44,17 +43,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const updateCurrentStep = (steps, selected, inBuilder, builderStep) => {
|
const updateCurrentStep = (steps, selected, builderStep) => {
|
||||||
// If we aren't in the builder or aren't selected then don't update the step
|
// If we aren't selected in the builder then just allowing the normal form
|
||||||
// context at all, allowing the normal form to take control.
|
// to take control.
|
||||||
if (!selected || !inBuilder) {
|
if (!selected) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
// Ensure we have a valid step selected
|
// Ensure we have a valid step selected
|
||||||
let newStep = Math.min(builderStep || 0, steps.length - 1)
|
let newStep = Math.min(builderStep || 0, steps.length - 1)
|
||||||
|
|
||||||
// Sanity check
|
|
||||||
newStep = Math.max(newStep, 0)
|
newStep = Math.max(newStep, 0)
|
||||||
|
|
||||||
// Add 1 because the form component expects 1 indexed rather than 0 indexed
|
// Add 1 because the form component expects 1 indexed rather than 0 indexed
|
||||||
|
|
Loading…
Reference in New Issue