Update DeleteRow button action to take explicit props and fix massive width
This commit is contained in:
parent
12ea52f3b1
commit
5a891054cb
|
@ -1,53 +1,35 @@
|
||||||
<script>
|
<script>
|
||||||
import { Select, Label } from "@budibase/bbui"
|
import { Select, Label } from "@budibase/bbui"
|
||||||
import { store, currentAsset } from "builderStore"
|
import { store, currentAsset, backendUiStore } from "builderStore"
|
||||||
import {
|
import { getBindableProperties } from "builderStore/dataBinding"
|
||||||
getDataProviderComponents,
|
import DrawerBindableInput from "components/common/DrawerBindableInput.svelte"
|
||||||
getDatasourceForProvider,
|
|
||||||
getSchemaForDatasource,
|
|
||||||
} from "builderStore/dataBinding"
|
|
||||||
|
|
||||||
export let parameters
|
export let parameters
|
||||||
|
|
||||||
$: dataProviderComponents = getDataProviderComponents(
|
$: tableOptions = $backendUiStore.tables || []
|
||||||
$currentAsset,
|
$: bindings = getBindableProperties($currentAsset, $store.selectedComponentId)
|
||||||
$store.selectedComponentId
|
|
||||||
)
|
|
||||||
$: {
|
|
||||||
// Automatically set rev and table ID based on row ID
|
|
||||||
if (parameters.providerId) {
|
|
||||||
parameters.rowId = `{{ ${parameters.providerId}._id }}`
|
|
||||||
parameters.revId = `{{ ${parameters.providerId}._rev }}`
|
|
||||||
const providerComponent = dataProviderComponents.find(
|
|
||||||
provider => provider._id === parameters.providerId
|
|
||||||
)
|
|
||||||
const datasource = getDatasourceForProvider(
|
|
||||||
$currentAsset,
|
|
||||||
providerComponent
|
|
||||||
)
|
|
||||||
const { table } = getSchemaForDatasource(datasource)
|
|
||||||
if (table) {
|
|
||||||
parameters.tableId = table._id
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="root">
|
<div class="root">
|
||||||
{#if dataProviderComponents.length === 0}
|
<Label small>Table</Label>
|
||||||
<div class="cannot-use">
|
<Select thin secondary bind:value={parameters.tableId}>
|
||||||
Delete row can only be used within a component that provides data, such as
|
<option value="" />
|
||||||
a List
|
{#each tableOptions as table}
|
||||||
</div>
|
<option value={table._id}>{table.name}</option>
|
||||||
{:else}
|
{/each}
|
||||||
<Label small>Datasource</Label>
|
</Select>
|
||||||
<Select thin secondary bind:value={parameters.providerId}>
|
|
||||||
<option value="" />
|
<Label small>Row ID</Label>
|
||||||
{#each dataProviderComponents as provider}
|
<DrawerBindableInput
|
||||||
<option value={provider._id}>{provider._instanceName}</option>
|
{bindings}
|
||||||
{/each}
|
value={parameters.rowId}
|
||||||
</Select>
|
on:change={value => (parameters.rowId = value.detail)} />
|
||||||
{/if}
|
|
||||||
|
<Label small>Row Rev</Label>
|
||||||
|
<DrawerBindableInput
|
||||||
|
{bindings}
|
||||||
|
value={parameters.revId}
|
||||||
|
on:change={value => (parameters.revId = value.detail)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
@ -57,11 +39,7 @@
|
||||||
row-gap: var(--spacing-s);
|
row-gap: var(--spacing-s);
|
||||||
grid-template-columns: auto 1fr;
|
grid-template-columns: auto 1fr;
|
||||||
align-items: baseline;
|
align-items: baseline;
|
||||||
}
|
max-width: 800px;
|
||||||
|
margin: 0 auto;
|
||||||
.cannot-use {
|
|
||||||
color: var(--red);
|
|
||||||
font-size: var(--font-size-s);
|
|
||||||
margin: auto;
|
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
|
|
Loading…
Reference in New Issue