Add collapsed button option to multistep form block

This commit is contained in:
Andrew Kingston 2024-09-02 16:30:14 +01:00
parent 049e2767c3
commit 3b827c35a2
No known key found for this signature in database
4 changed files with 22 additions and 4 deletions

View File

@ -28,7 +28,7 @@
>
{text || "Action"}
</Button>
<Popover bind:this={popover} {align} {anchor} {offset}>
<Popover bind:this={popover} {align} {anchor} {offset} resizable={false}>
<Menu>
{#each buttons as button}
<MenuItem on:click={() => handleClick(button)} disabled={button.disabled}>

View File

@ -54,6 +54,8 @@
_instanceName: `Step ${currentStep + 1}`,
title: savedInstance.title ?? defaults?.title,
buttons: savedInstance.buttons || defaults?.buttons,
buttonsCollapsed: savedInstance.buttonsCollapsed,
buttonsCollapsedText: savedInstance.buttonsCollapsedText,
fields: savedInstance.fields,
desc: savedInstance.desc,

View File

@ -7076,6 +7076,18 @@
"key": "buttons",
"wide": true,
"nested": true
},
{
"type": "boolean",
"label": "Collapse",
"key": "buttonsCollapsed"
},
{
"type": "text",
"label": "Collapsed text",
"key": "buttonsCollapsedText",
"dependsOn": "buttonsCollapsed",
"placeholder": "Action"
}
]
},

View File

@ -77,7 +77,7 @@
const enrichSteps = (steps, schema, id) => {
const safeSteps = steps?.length ? steps : [{}]
return safeSteps.map((step, idx) => {
const { title, desc, fields, buttons } = step
const { title, fields, buttons } = step
const defaultProps = Utils.buildMultiStepFormBlockDefaultProps({
_id: id,
stepCount: safeSteps.length,
@ -86,10 +86,10 @@
dataSource,
})
return {
...step,
_stepId: Helpers.uuid(),
fields: getDefaultFields(fields || [], schema),
title: title ?? defaultProps.title,
desc,
buttons: buttons || defaultProps.buttons,
}
})
@ -172,7 +172,11 @@
{#if buttonPosition === "bottom"}
<BlockComponent
type="buttongroup"
props={{ buttons: step.buttons }}
props={{
buttons: step.buttons,
collapsed: step.buttonsCollapsed,
collapsedText: step.buttonsCollapsedText,
}}
order={3}
/>
{/if}