1
0
Fork 0
mirror of synced 2024-06-27 02:20:35 +12:00

Improve performance of multistep form block even more and fix missing params

This commit is contained in:
Andrew Kingston 2024-03-20 15:50:23 +00:00
parent 65b4b6c35d
commit 9149828c7c

View file

@ -28,9 +28,11 @@
$: id = $component.id
$: selected = $component.selected
$: inBuilder = $builderStore.inBuilder
$: builderStep = $builderStore.metadata?.step
$: fetchSchema(dataSource)
$: updateCurrentStep(enrichedSteps, $builderStore, id, selected)
$: enrichedSteps = enrichSteps(steps, schema, id, $currentStep)
$: enrichedSteps = enrichSteps(steps, schema, id)
$: updateCurrentStep(enrichedSteps, selected, inBuilder, builderStep)
// Provide additional data context for live binding eval
export const getAdditionalDataContext = () => {
@ -42,17 +44,15 @@
}
}
const updateCurrentStep = (steps, builderStore, id, selected) => {
const { componentId, step } = builderStore.metadata || {}
const updateCurrentStep = (steps, selected, inBuilder, builderStep) => {
// If we aren't in the builder or aren't selected then don't update the step
// context at all, allowing the normal form to take control.
if (!selected || !builderStore.inBuilder || componentId !== id) {
if (!selected || !inBuilder) {
return
}
// Ensure we have a valid step selected
let newStep = Math.min(step || 0, steps.length - 1)
let newStep = Math.min(builderStep || 0, steps.length - 1)
// Sanity check
newStep = Math.max(newStep, 0)
@ -61,7 +61,7 @@
currentStep.set(newStep + 1)
}
const fetchSchema = async () => {
const fetchSchema = async dataSource => {
schema = (await fetchDatasourceSchema(dataSource)) || {}
}