Merge pull request #11011 from Budibase/form-step-updates
Persist the current step when remounting a form
This commit is contained in:
commit
211a4cbb35
|
@ -2,6 +2,7 @@
|
||||||
import { getContext } from "svelte"
|
import { getContext } from "svelte"
|
||||||
import InnerForm from "./InnerForm.svelte"
|
import InnerForm from "./InnerForm.svelte"
|
||||||
import { Helpers } from "@budibase/bbui"
|
import { Helpers } from "@budibase/bbui"
|
||||||
|
import { writable } from "svelte/store"
|
||||||
|
|
||||||
export let dataSource
|
export let dataSource
|
||||||
export let theme
|
export let theme
|
||||||
|
@ -23,6 +24,7 @@
|
||||||
let loaded = false
|
let loaded = false
|
||||||
let schema
|
let schema
|
||||||
let table
|
let table
|
||||||
|
let currentStep = writable(1)
|
||||||
|
|
||||||
$: fetchSchema(dataSource)
|
$: fetchSchema(dataSource)
|
||||||
$: schemaKey = generateSchemaKey(schema)
|
$: schemaKey = generateSchemaKey(schema)
|
||||||
|
@ -92,6 +94,7 @@
|
||||||
{initialValues}
|
{initialValues}
|
||||||
{disableValidation}
|
{disableValidation}
|
||||||
{editAutoColumns}
|
{editAutoColumns}
|
||||||
|
{currentStep}
|
||||||
>
|
>
|
||||||
<slot />
|
<slot />
|
||||||
</InnerForm>
|
</InnerForm>
|
||||||
|
|
|
@ -13,16 +13,19 @@
|
||||||
export let disableValidation = false
|
export let disableValidation = false
|
||||||
export let editAutoColumns = false
|
export let editAutoColumns = false
|
||||||
|
|
||||||
|
// We export this store so that when we remount the inner form we can still
|
||||||
|
// persist what step we're on
|
||||||
|
export let currentStep
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const { styleable, Provider, ActionTypes } = getContext("sdk")
|
const { styleable, Provider, ActionTypes } = getContext("sdk")
|
||||||
|
|
||||||
let fields = []
|
let fields = []
|
||||||
const currentStep = writable(1)
|
|
||||||
const formState = writable({
|
const formState = writable({
|
||||||
values: {},
|
values: {},
|
||||||
errors: {},
|
errors: {},
|
||||||
valid: true,
|
valid: true,
|
||||||
currentStep: 1,
|
currentStep: get(currentStep),
|
||||||
})
|
})
|
||||||
|
|
||||||
// Reactive derived stores to derive form state from field array
|
// Reactive derived stores to derive form state from field array
|
||||||
|
|
Loading…
Reference in New Issue