Fix svelte keying of component settings blocks
This commit is contained in:
parent
b02f631888
commit
af3802e28a
|
@ -50,7 +50,7 @@
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
{#if settings && settings.length > 0}
|
{#if settings && settings.length > 0}
|
||||||
{#each settings as setting (`${componentInstance._id}-${setting.key}`)}
|
{#each settings as setting}
|
||||||
{#if canRenderControl(setting)}
|
{#if canRenderControl(setting)}
|
||||||
<PropertyControl
|
<PropertyControl
|
||||||
type={setting.type}
|
type={setting.type}
|
||||||
|
|
|
@ -17,6 +17,8 @@
|
||||||
store.actions.components.updateConditions(tempValue)
|
store.actions.components.updateConditions(tempValue)
|
||||||
drawer.hide()
|
drawer.hide()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$: console.log(componentInstance?._id)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<DetailSummary
|
<DetailSummary
|
||||||
|
@ -27,12 +29,10 @@
|
||||||
<ActionButton on:click={openDrawer}>Configure conditions</ActionButton>
|
<ActionButton on:click={openDrawer}>Configure conditions</ActionButton>
|
||||||
</div>
|
</div>
|
||||||
</DetailSummary>
|
</DetailSummary>
|
||||||
{#key componentInstance?._id}
|
<Drawer bind:this={drawer} title="Conditions">
|
||||||
<Drawer bind:this={drawer} title="Conditions">
|
<svelte:fragment slot="description">
|
||||||
<svelte:fragment slot="description">
|
Show, hide and update components in response to conditions being met.
|
||||||
Show, hide and update components in response to conditions being met.
|
</svelte:fragment>
|
||||||
</svelte:fragment>
|
<Button cta slot="buttons" on:click={() => save()}>Save</Button>
|
||||||
<Button cta slot="buttons" on:click={save}>Save</Button>
|
<ConditionalUIDrawer slot="body" bind:conditions={tempValue} />
|
||||||
<ConditionalUIDrawer slot="body" bind:conditions={tempValue} />
|
</Drawer>
|
||||||
</Drawer>
|
|
||||||
{/key}
|
|
||||||
|
|
|
@ -16,11 +16,13 @@
|
||||||
<Tabs selected="Settings" noPadding>
|
<Tabs selected="Settings" noPadding>
|
||||||
<Tab title="Settings">
|
<Tab title="Settings">
|
||||||
<div class="container">
|
<div class="container">
|
||||||
<ScreenSettingsSection {componentInstance} {componentDefinition} />
|
{#key componentInstance?._id}
|
||||||
<ComponentSettingsSection {componentInstance} {componentDefinition} />
|
<ScreenSettingsSection {componentInstance} {componentDefinition} />
|
||||||
<DesignSection {componentInstance} {componentDefinition} />
|
<ComponentSettingsSection {componentInstance} {componentDefinition} />
|
||||||
<CustomStylesSection {componentInstance} {componentDefinition} />
|
<DesignSection {componentInstance} {componentDefinition} />
|
||||||
<ConditionalUISection {componentInstance} {componentDefinition} />
|
<CustomStylesSection {componentInstance} {componentDefinition} />
|
||||||
|
<ConditionalUISection {componentInstance} {componentDefinition} />
|
||||||
|
{/key}
|
||||||
</div>
|
</div>
|
||||||
</Tab>
|
</Tab>
|
||||||
</Tabs>
|
</Tabs>
|
||||||
|
|
|
@ -1,12 +1,18 @@
|
||||||
<script>
|
<script>
|
||||||
import { Button, Icon, DrawerContent, Layout, Select } from "@budibase/bbui"
|
import {
|
||||||
|
Button,
|
||||||
|
Body,
|
||||||
|
Icon,
|
||||||
|
DrawerContent,
|
||||||
|
Layout,
|
||||||
|
Select,
|
||||||
|
} from "@budibase/bbui"
|
||||||
import { flip } from "svelte/animate"
|
import { flip } from "svelte/animate"
|
||||||
import { dndzone } from "svelte-dnd-action"
|
import { dndzone } from "svelte-dnd-action"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
import DrawerBindableInput from "../../../common/bindings/DrawerBindableInput.svelte"
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
import ColorPicker from "./ColorPicker.svelte"
|
|
||||||
import { OperatorOptions, getValidOperatorsForType } from "helpers/lucene"
|
import { OperatorOptions, getValidOperatorsForType } from "helpers/lucene"
|
||||||
import { getBindableProperties } from "../../../../builderStore/dataBinding"
|
import { getBindableProperties } from "builderStore/dataBinding"
|
||||||
import { currentAsset, selectedComponent, store } from "builderStore"
|
import { currentAsset, selectedComponent, store } from "builderStore"
|
||||||
import { getComponentForSettingType } from "./componentSettings"
|
import { getComponentForSettingType } from "./componentSettings"
|
||||||
import PropertyControl from "./PropertyControl.svelte"
|
import PropertyControl from "./PropertyControl.svelte"
|
||||||
|
@ -15,16 +21,16 @@
|
||||||
|
|
||||||
const flipDurationMs = 150
|
const flipDurationMs = 150
|
||||||
const actionOptions = [
|
const actionOptions = [
|
||||||
{
|
|
||||||
label: "Show component",
|
|
||||||
value: "show",
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
label: "Hide component",
|
label: "Hide component",
|
||||||
value: "hide",
|
value: "hide",
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
label: "Update component setting",
|
label: "Show component",
|
||||||
|
value: "show",
|
||||||
|
},
|
||||||
|
{
|
||||||
|
label: "Update setting",
|
||||||
value: "update",
|
value: "update",
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -64,7 +70,8 @@
|
||||||
conditions = [
|
conditions = [
|
||||||
...conditions,
|
...conditions,
|
||||||
{
|
{
|
||||||
action: "show",
|
id: generate(),
|
||||||
|
action: "hide",
|
||||||
operator: OperatorOptions.Equals.value,
|
operator: OperatorOptions.Equals.value,
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
|
@ -94,16 +101,22 @@
|
||||||
on:consider={updateLinks}
|
on:consider={updateLinks}
|
||||||
>
|
>
|
||||||
{#each conditions as condition (condition.id)}
|
{#each conditions as condition (condition.id)}
|
||||||
<div class="condition" animate:flip={{ duration: flipDurationMs }}>
|
<div
|
||||||
|
class="condition"
|
||||||
|
class:update={condition.action === "update"}
|
||||||
|
animate:flip={{ duration: flipDurationMs }}
|
||||||
|
>
|
||||||
|
<Icon name="DragHandle" size="XL" />
|
||||||
<Select
|
<Select
|
||||||
|
draggable={false}
|
||||||
placeholder={null}
|
placeholder={null}
|
||||||
options={actionOptions}
|
options={actionOptions}
|
||||||
bind:value={condition.action}
|
bind:value={condition.action}
|
||||||
/>
|
/>
|
||||||
{#if condition.action === "update"}
|
{#if condition.action === "update"}
|
||||||
<Select options={settings} bind:value={condition.setting} />
|
<Select options={settings} bind:value={condition.setting} />
|
||||||
|
<div>TO</div>
|
||||||
{#if getSettingDefinition(condition.setting)}
|
{#if getSettingDefinition(condition.setting)}
|
||||||
<div>TO</div>
|
|
||||||
<PropertyControl
|
<PropertyControl
|
||||||
type={getSettingDefinition(condition.setting).type}
|
type={getSettingDefinition(condition.setting).type}
|
||||||
control={getComponentForSetting(condition.setting)}
|
control={getComponentForSetting(condition.setting)}
|
||||||
|
@ -117,6 +130,8 @@
|
||||||
.placeholder,
|
.placeholder,
|
||||||
}}
|
}}
|
||||||
/>
|
/>
|
||||||
|
{:else}
|
||||||
|
<Select disabled placeholder=" " />
|
||||||
{/if}
|
{/if}
|
||||||
{/if}
|
{/if}
|
||||||
<div>IF</div>
|
<div>IF</div>
|
||||||
|
@ -146,8 +161,10 @@
|
||||||
</div>
|
</div>
|
||||||
{/each}
|
{/each}
|
||||||
</div>
|
</div>
|
||||||
|
{:else}
|
||||||
|
<Body size="S">Add your first condition to get started.</Body>
|
||||||
{/if}
|
{/if}
|
||||||
<div class="button-container">
|
<div>
|
||||||
<Button secondary icon="Add" on:click={addCondition}>
|
<Button secondary icon="Add" on:click={addCondition}>
|
||||||
Add condition
|
Add condition
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -160,30 +177,27 @@
|
||||||
.container {
|
.container {
|
||||||
width: 100%;
|
width: 100%;
|
||||||
max-width: 1200px;
|
max-width: 1200px;
|
||||||
|
margin: 0 auto;
|
||||||
}
|
}
|
||||||
.conditions {
|
.conditions {
|
||||||
display: flex;
|
display: flex;
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-m);
|
||||||
}
|
}
|
||||||
.condition {
|
.condition {
|
||||||
gap: var(--spacing-l);
|
gap: var(--spacing-l);
|
||||||
display: flex;
|
display: grid;
|
||||||
flex-direction: row;
|
|
||||||
justify-content: space-between;
|
|
||||||
align-items: center;
|
align-items: center;
|
||||||
|
grid-template-columns: auto 1fr auto 1fr 1fr 1fr auto;
|
||||||
border-radius: var(--border-radius-s);
|
border-radius: var(--border-radius-s);
|
||||||
transition: background-color ease-in-out 130ms;
|
transition: background-color ease-in-out 130ms;
|
||||||
}
|
}
|
||||||
|
.condition.update {
|
||||||
|
grid-template-columns: auto 1fr 1fr auto 1fr auto 1fr 1fr 1fr auto;
|
||||||
|
}
|
||||||
.condition:hover {
|
.condition:hover {
|
||||||
background-color: var(--spectrum-global-color-gray-100);
|
background-color: var(--spectrum-global-color-gray-100);
|
||||||
}
|
}
|
||||||
.condition > :global(.spectrum-Form-item) {
|
|
||||||
flex: 1 1 auto;
|
|
||||||
width: 0;
|
|
||||||
}
|
|
||||||
.button-container {
|
|
||||||
}
|
|
||||||
</style>
|
</style>
|
||||||
|
|
|
@ -90,7 +90,7 @@
|
||||||
flex-direction: column;
|
flex-direction: column;
|
||||||
justify-content: flex-start;
|
justify-content: flex-start;
|
||||||
align-items: stretch;
|
align-items: stretch;
|
||||||
gap: var(--spacing-s);
|
gap: var(--spacing-m);
|
||||||
}
|
}
|
||||||
.link {
|
.link {
|
||||||
gap: var(--spacing-l);
|
gap: var(--spacing-l);
|
||||||
|
|
|
@ -70,7 +70,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="property-control" bind:this={anchor} data-cy={`setting-${key}`}>
|
<div class="property-control" bind:this={anchor} data-cy={`setting-${key}`}>
|
||||||
{#if type !== "boolean"}
|
{#if type !== "boolean" && label}
|
||||||
<div class="label">
|
<div class="label">
|
||||||
<Label>{label}</Label>
|
<Label>{label}</Label>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue