1
0
Fork 0
mirror of synced 2024-06-26 10:00:41 +12:00
budibase/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte

58 lines
1.5 KiB
Svelte
Raw Normal View History

<script>
2020-12-05 03:46:21 +13:00
import {
Input,
Select,
Label,
DatePicker,
Toggle,
RichText,
} from "@budibase/bbui"
2020-11-28 03:59:27 +13:00
import { backendUiStore } from "builderStore"
import { TableNames } from "constants"
2020-09-12 02:09:56 +12:00
import Dropzone from "components/common/Dropzone.svelte"
import { capitalise } from "../../../helpers"
import LinkedRowSelector from "components/common/LinkedRowSelector.svelte"
2020-08-08 03:13:57 +12:00
export let meta
2020-11-28 04:24:43 +13:00
export let creating
2020-08-25 02:48:34 +12:00
export let value = meta.type === "boolean" ? false : ""
2020-10-07 04:02:48 +13:00
$: type = meta.type
$: label = capitalise(meta.name)
2020-11-28 04:24:43 +13:00
$: editingUser =
!creating && $backendUiStore.selectedTable?._id === TableNames.USERS
</script>
2020-10-07 04:02:48 +13:00
{#if type === 'options'}
<Select thin secondary {label} data-cy="{meta.name}-select" bind:value>
<option value="">Choose an option</option>
2020-08-25 02:48:34 +12:00
{#each meta.constraints.inclusion as opt}
2020-06-01 23:15:44 +12:00
<option value={opt}>{opt}</option>
{/each}
2020-08-08 03:13:57 +12:00
</Select>
2020-10-07 04:02:48 +13:00
{:else if type === 'datetime'}
<DatePicker {label} bind:value />
2020-10-07 04:02:48 +13:00
{:else if type === 'attachment'}
<div>
<Label extraSmall grey forAttr={'dropzone-label'}>{label}</Label>
<Dropzone bind:files={value} />
</div>
2020-10-07 04:02:48 +13:00
{:else if type === 'boolean'}
<Toggle text={label} bind:checked={value} data-cy="{meta.name}-input" />
2020-10-07 04:02:48 +13:00
{:else if type === 'link'}
<LinkedRowSelector bind:linkedRows={value} schema={meta} />
{:else if type === 'longform'}
<div>
<Label extraSmall grey>{label}</Label>
<RichText bind:value />
</div>
{:else}
2020-11-28 03:59:27 +13:00
<Input
thin
{label}
data-cy="{meta.name}-input"
{type}
bind:value
2020-11-28 04:24:43 +13:00
disabled={editingUser} />
2020-08-11 22:23:07 +12:00
{/if}