1
0
Fork 0
mirror of synced 2024-06-03 02:55:14 +12:00
budibase/packages/builder/src/components/design/PropertiesPanel/PropertyControls/EventsEditor/actions/SaveRow.svelte

86 lines
2.1 KiB
Svelte
Raw Normal View History

2020-10-09 10:06:44 +13:00
<script>
import { Select, Label, Body } from "@budibase/bbui"
import { store, currentAsset } from "builderStore"
import { tables } from "stores/backend"
import {
getDataProviderComponents,
getSchemaForDatasource,
} from "builderStore/dataBinding"
2020-10-09 10:06:44 +13:00
import SaveFields from "./SaveFields.svelte"
export let parameters
$: dataProviderComponents = getDataProviderComponents(
$currentAsset,
$store.selectedComponentId
)
$: schemaFields = getSchemaFields(parameters?.tableId)
$: tableOptions = $tables || []
2020-10-09 10:06:44 +13:00
const getSchemaFields = tableId => {
const { schema } = getSchemaForDatasource({ type: "table", tableId })
return Object.values(schema || {})
2020-10-09 10:06:44 +13:00
}
const onFieldsChanged = e => {
parameters.fields = e.detail
}
</script>
<div class="root">
<Body small grey>
Choosing a Data Source will automatically use the data it provides, but it's
optional.<br />
You can always add or override fields manually.
</Body>
<div class="fields">
<Label small>Data Source</Label>
<Select thin secondary bind:value={parameters.providerId}>
<option value="">None</option>
{#each dataProviderComponents as provider}
<option value={provider._id}>{provider._instanceName}</option>
2020-10-09 10:06:44 +13:00
{/each}
</Select>
<Label small>Table</Label>
<Select thin secondary bind:value={parameters.tableId}>
<option value="" />
{#each tableOptions as table}
<option value={table._id}>{table.name}</option>
{/each}
</Select>
{#if parameters.tableId}
<SaveFields
parameterFields={parameters.fields}
{schemaFields}
on:change={onFieldsChanged} />
{/if}
</div>
2020-10-09 10:06:44 +13:00
</div>
<style>
.root {
max-width: 800px;
margin: 0 auto;
}
.root :global(p) {
line-height: 1.5;
}
.fields {
2020-10-09 10:06:44 +13:00
display: grid;
column-gap: var(--spacing-l);
2020-10-09 10:06:44 +13:00
row-gap: var(--spacing-s);
grid-template-columns: auto 1fr auto 1fr auto;
align-items: baseline;
}
.fields :global(> div:nth-child(2)),
.fields :global(> div:nth-child(4)) {
2020-10-09 10:06:44 +13:00
grid-column-start: 2;
grid-column-end: 6;
}
</style>