Cleanup
This commit is contained in:
parent
173a76dc52
commit
f4d2efdaa1
|
@ -31,6 +31,7 @@
|
||||||
$: dataSource = getDatasourceForProvider($currentAsset, componentInstance)
|
$: dataSource = getDatasourceForProvider($currentAsset, componentInstance)
|
||||||
$: emitCurrentStep(currentStep)
|
$: emitCurrentStep(currentStep)
|
||||||
$: sectionName = getSectionName($multiStepStore)
|
$: sectionName = getSectionName($multiStepStore)
|
||||||
|
$: stepConfigInstance = buildPseudoInstance(value[currentStep] || {})
|
||||||
$: stepDef = {
|
$: stepDef = {
|
||||||
settings: [
|
settings: [
|
||||||
{
|
{
|
||||||
|
@ -39,7 +40,7 @@
|
||||||
settings: [
|
settings: [
|
||||||
{
|
{
|
||||||
type: "formStepControls",
|
type: "formStepControls",
|
||||||
label: "Multi-steps",
|
label: "Steps",
|
||||||
key: "steps",
|
key: "steps",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -88,40 +89,32 @@
|
||||||
}
|
}
|
||||||
|
|
||||||
const addStep = () => {
|
const addStep = () => {
|
||||||
const nextStep = currentStep + 1
|
dispatch("change", value.toSpliced(currentStep + 1, 0, {}))
|
||||||
dispatch("change", [
|
|
||||||
...value.slice(0, nextStep),
|
|
||||||
{},
|
|
||||||
...value.slice(nextStep),
|
|
||||||
])
|
|
||||||
multiStepStore.update(state => ({
|
multiStepStore.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
currentStep: nextStep,
|
currentStep: currentStep + 1,
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const removeStep = () => {
|
const removeStep = () => {
|
||||||
dispatch("change", value.toSpliced(currentStep, 1))
|
dispatch("change", value.toSpliced(currentStep, 1))
|
||||||
const newStep = Math.min(currentStep, stepCount - 2)
|
|
||||||
multiStepStore.update(state => ({
|
multiStepStore.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
currentStep: newStep,
|
currentStep: Math.min(currentStep, stepCount - 2),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const previousStep = () => {
|
const previousStep = () => {
|
||||||
const prevStepIdx = Math.max(currentStep - 1, 0)
|
|
||||||
multiStepStore.update(state => ({
|
multiStepStore.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
currentStep: prevStepIdx,
|
currentStep: Math.max(currentStep - 1, 0),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
const nextStep = () => {
|
const nextStep = () => {
|
||||||
const nextStepIdx = currentStep + 1
|
|
||||||
multiStepStore.update(state => ({
|
multiStepStore.update(state => ({
|
||||||
...state,
|
...state,
|
||||||
currentStep: Math.min(nextStepIdx, value.length - 1),
|
currentStep: Math.min(currentStep + 1, value.length - 1),
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -130,9 +123,7 @@
|
||||||
...value[currentStep],
|
...value[currentStep],
|
||||||
[field.key]: val,
|
[field.key]: val,
|
||||||
}
|
}
|
||||||
let newValue = value.slice()
|
dispatch("change", value.toSpliced(currentStep, 1, newStep))
|
||||||
newValue[currentStep] = newStep
|
|
||||||
dispatch("change", newValue)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const handleStepAction = action => {
|
const handleStepAction = action => {
|
||||||
|
@ -162,18 +153,17 @@
|
||||||
const buildPseudoInstance = ({ buttons, fields, title, desc }) => {
|
const buildPseudoInstance = ({ buttons, fields, title, desc }) => {
|
||||||
return {
|
return {
|
||||||
_id: Helpers.uuid(),
|
_id: Helpers.uuid(),
|
||||||
_component: "@budibase/standard-components/multistepformblock-step",
|
_component: "@budibase/standard-components/multistepformblockstep",
|
||||||
|
_instanceName: `Step ${currentStep + 1}`,
|
||||||
buttons: buttons || defaultButtonConfig,
|
buttons: buttons || defaultButtonConfig,
|
||||||
fields,
|
fields,
|
||||||
title,
|
title,
|
||||||
desc,
|
desc,
|
||||||
dataSource,
|
|
||||||
step: currentStep + 1,
|
|
||||||
_instanceName: `Step ${currentStep + 1}`,
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
$: stepConfigInstance = buildPseudoInstance(value[currentStep] || {})
|
// Needed for field configuration
|
||||||
|
dataSource,
|
||||||
|
}
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="nested-section">
|
<div class="nested-section">
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
{#if stepCount === 1}
|
{#if stepCount === 1}
|
||||||
|
<div class="stretch">
|
||||||
<ActionButton
|
<ActionButton
|
||||||
icon="MultipleAdd"
|
icon="MultipleAdd"
|
||||||
secondary
|
secondary
|
||||||
|
@ -24,6 +25,7 @@
|
||||||
>
|
>
|
||||||
Add Step
|
Add Step
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
|
</div>
|
||||||
{:else}
|
{:else}
|
||||||
<div class="step-actions">
|
<div class="step-actions">
|
||||||
<ActionButton
|
<ActionButton
|
||||||
|
@ -65,11 +67,13 @@
|
||||||
{/if}
|
{/if}
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.stretch :global(.spectrum-ActionButton) {
|
||||||
|
width: 100%;
|
||||||
|
}
|
||||||
.step-actions {
|
.step-actions {
|
||||||
display: flex;
|
display: flex;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-s);
|
||||||
}
|
}
|
||||||
|
|
||||||
.step-actions :global(.spectrum-ActionButton) {
|
.step-actions :global(.spectrum-ActionButton) {
|
||||||
height: 32px;
|
height: 32px;
|
||||||
}
|
}
|
||||||
|
|
|
@ -210,7 +210,7 @@
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
{/if}
|
{/if}
|
||||||
{/each}
|
{/each}
|
||||||
{#if componentDefinition?.block && !tag}
|
{#if componentDefinition?.block && !tag && componentDefinition.ejectable !== false}
|
||||||
<DetailSummary name="Eject" collapsible={false}>
|
<DetailSummary name="Eject" collapsible={false}>
|
||||||
<EjectBlockButton />
|
<EjectBlockButton />
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
|
|
|
@ -6038,6 +6038,7 @@
|
||||||
"icon": "AssetsAdded",
|
"icon": "AssetsAdded",
|
||||||
"block": true,
|
"block": true,
|
||||||
"hasChildren": false,
|
"hasChildren": false,
|
||||||
|
"ejectable": false,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 400,
|
||||||
"height": 400
|
"height": 400
|
||||||
|
|
Loading…
Reference in New Issue