From a244b34e53b5cbb8aa8b8708aaef57beafc739b5 Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 14 Dec 2023 14:33:43 +0000 Subject: [PATCH] Fix multi step settings rendering and improve multi step form block client rendering when inside builder --- .../controls/FormStepConfiguration.svelte | 42 +++++++++---------- .../app/blocks/MultiStepFormblock.svelte | 27 ++++++------ .../src/components/app/forms/Form.svelte | 12 +----- packages/frontend-core/src/utils/utils.js | 2 +- 4 files changed, 36 insertions(+), 47 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte b/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte index f91f398fe7..7004102576 100644 --- a/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte +++ b/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte @@ -23,18 +23,32 @@ setContext("multi-step-form-block", multiStepStore) - $: defaultProps = Utils.buildMultiStepFormBlockDefaultProps({ - _id: componentInstance._id, - stepCount: stepCount, - step: $multiStepStore.currentStep, - }) $: stepCount = value?.length || 0 $: updateStore(stepCount) $: dataSource = getDatasourceForProvider($currentAsset, componentInstance) $: emitCurrentStep($currentStep) $: stepLabel = getStepLabel($multiStepStore) $: stepDef = getDefinition(stepLabel) - $: stepInstance = buildPseudoInstance(value, $currentStep, defaultProps) + $: stepSettings = value?.[$currentStep] || {} + $: defaults = Utils.buildMultiStepFormBlockDefaultProps({ + _id: componentInstance._id, + stepCount: $multiStepStore.stepCount, + currentStep: $multiStepStore.currentStep, + actionType: componentInstance.actionType, + dataSource: componentInstance.dataSource, + }) + $: stepInstance = { + _id: Helpers.uuid(), + _component: componentType, + _instanceName: `Step ${currentStep + 1}`, + title: stepSettings.title ?? defaults.title, + buttons: stepSettings.buttons || defaults.buttons, + fields: stepSettings.fields, + desc: stepSettings.desc, + + // Needed for field configuration + dataSource, + } const getDefinition = stepLabel => { let def = cloneDeep(store.actions.components.getDefinition(componentType)) @@ -130,22 +144,6 @@ updateStep(field, val) } } - - const buildPseudoInstance = (value, currentStep, defaultProps) => { - const { buttons, fields, title, desc } = value?.[currentStep] || {} - return { - _id: Helpers.uuid(), - _component: componentType, - _instanceName: `Step ${currentStep + 1}`, - title: title ?? defaultProps.title, - buttons: buttons || defaultProps.buttons, - fields, - desc, - - // Needed for field configuration - dataSource, - } - }
diff --git a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte index 4a9621f68e..ce4804047d 100644 --- a/packages/client/src/components/app/blocks/MultiStepFormblock.svelte +++ b/packages/client/src/components/app/blocks/MultiStepFormblock.svelte @@ -1,20 +1,24 @@