diff --git a/packages/builder/src/builderStore/dataBinding.js b/packages/builder/src/builderStore/dataBinding.js index d86e94aba2..52368a0723 100644 --- a/packages/builder/src/builderStore/dataBinding.js +++ b/packages/builder/src/builderStore/dataBinding.js @@ -465,8 +465,8 @@ const filterCategoryByContext = (component, context) => { const { _component } = component if (_component.endsWith("formblock")) { if ( - (component.actionType == "Create" && context.type === "schema") || - (component.actionType == "View" && context.type === "form") + (component.actionType === "Create" && context.type === "schema") || + (component.actionType === "View" && context.type === "form") ) { return false } @@ -474,20 +474,21 @@ const filterCategoryByContext = (component, context) => { return true } +// Enrich binding category information for certain components const getComponentBindingCategory = (component, context, def) => { let icon = def.icon let category = component._instanceName if (component._component.endsWith("formblock")) { - let contextCategorySuffix = { - form: "Fields", - schema: "Row", + if (context.type === "form") { + category = `${component._instanceName} - Fields` + icon = "Form" + } else if (context.type === "schema") { + category = `${component._instanceName} - Row` + icon = "Data" } - category = `${component._instanceName} - ${ - contextCategorySuffix[context.type] - }` - icon = context.type === "form" ? "Form" : "Data" } + return { icon, category, diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 7a72b7a9c3..2d62a0667e 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -1289,15 +1289,14 @@ export const getFrontendStore = () => { const settings = getComponentSettings(component._component) const updatedSetting = settings.find(setting => setting.key === name) - // Can be a single string or array of strings - const resetFields = settings.filter(setting => { - return ( + // Reset dependent fields + settings.forEach(setting => { + const needsReset = name === setting.resetOn || (Array.isArray(setting.resetOn) && setting.resetOn.includes(name)) - ) - }) - resetFields?.forEach(setting => { - component[setting.key] = null + if (needsReset) { + component[setting.key] = setting.defaultValue || null + } }) if ( diff --git a/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte b/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte index 8e37d1b058..184057e45e 100644 --- a/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte +++ b/packages/builder/src/components/design/settings/controls/FormStepConfiguration.svelte @@ -5,7 +5,7 @@ import { currentAsset, store } from "builderStore" import { Helpers } from "@budibase/bbui" import { writable } from "svelte/store" - import { buildMultiStepFormBlockButtonConfig } from "@budibase/frontend-core/src/utils/utils" + import { Utils } from "@budibase/frontend-core" export let componentInstance export let componentBindings @@ -20,18 +20,18 @@ setContext("multi-step-form-block", multiStepStore) - $: currentStep = $multiStepStore.currentStep - $: stepCount = value?.length || 0 - $: multiStepStore.update(state => ({ ...state, stepCount })) - $: defaultButtonConfig = buildMultiStepFormBlockButtonConfig({ + $: defaultProps = Utils.buildMultiStepFormBlockDefaultProps({ _id: componentInstance._id, stepCount: stepCount, currentStep: currentStep, }) + $: currentStep = $multiStepStore.currentStep + $: stepCount = value?.length || 0 + $: multiStepStore.update(state => ({ ...state, stepCount })) $: dataSource = getDatasourceForProvider($currentAsset, componentInstance) $: emitCurrentStep(currentStep) $: sectionName = getSectionName($multiStepStore) - $: stepConfigInstance = buildPseudoInstance(value[currentStep] || {}) + $: stepInstance = buildPseudoInstance(value[currentStep], defaultProps) $: stepDef = { settings: [ { @@ -150,14 +150,15 @@ } } - const buildPseudoInstance = ({ buttons, fields, title, desc }) => { + const buildPseudoInstance = (instance, defaultProps) => { + const { buttons, fields, title, desc } = instance || {} return { _id: Helpers.uuid(), _component: "@budibase/standard-components/multistepformblockstep", _instanceName: `Step ${currentStep + 1}`, - buttons: buttons || defaultButtonConfig, + title: title ?? defaultProps.title, + buttons: buttons || defaultProps.buttons, fields, - title, desc, // Needed for field configuration @@ -169,7 +170,7 @@