1
0
Fork 0
mirror of synced 2024-06-02 02:25:17 +12:00
budibase/packages/builder/src/components/database/DataTable/modals/RecordFieldControl.svelte

54 lines
1 KiB
Svelte
Raw Normal View History

<script>
2020-08-08 03:13:57 +12:00
import { Input, Select } from "@budibase/bbui"
export let type = "text"
2020-08-15 03:31:53 +12:00
export let value = type === "checkbox" ? false : ""
export let label
export let options = []
2020-06-01 23:15:44 +12:00
const handleInput = event => {
if (event.target.type === "checkbox") {
2020-05-07 21:53:34 +12:00
value = event.target.checked
return
}
if (event.target.type === "number") {
2020-05-07 21:53:34 +12:00
value = parseInt(event.target.value)
return
}
2020-05-07 21:53:34 +12:00
value = event.target.value
}
</script>
2020-06-01 23:15:44 +12:00
{#if type === 'select'}
2020-08-11 22:23:07 +12:00
<Select thin secondary data-cy="{label}-select" bind:value>
2020-07-08 08:29:20 +12:00
<option />
2020-06-01 23:15:44 +12:00
{#each options as opt}
<option value={opt}>{opt}</option>
{/each}
2020-08-08 03:13:57 +12:00
</Select>
{:else}
2020-08-12 04:58:01 +12:00
{#if type === 'checkbox'}
<label>{label}</label>
{/if}
2020-08-08 03:13:57 +12:00
<Input
thin
placeholder={label}
2020-06-12 03:10:26 +12:00
data-cy="{label}-input"
2020-08-15 03:31:53 +12:00
checked={value}
2020-06-01 23:15:44 +12:00
{type}
{value}
on:input={handleInput}
on:change={handleInput} />
2020-08-11 22:23:07 +12:00
{/if}
2020-08-12 04:58:01 +12:00
<style>
label {
font-weight: 500;
font-size: var(--font-size-s);
float: left;
margin-right: 8px;
}
</style>