Merge branch 'bugfix/table-col-types' of github.com:Budibase/budibase into custom-view-backend
This commit is contained in:
commit
8117ff0c84
|
@ -15,22 +15,20 @@
|
||||||
import LinkedRecordSelector from "components/common/LinkedRecordSelector.svelte"
|
import LinkedRecordSelector from "components/common/LinkedRecordSelector.svelte"
|
||||||
import * as api from "../api"
|
import * as api from "../api"
|
||||||
|
|
||||||
export let onClosed
|
|
||||||
export let field = {}
|
|
||||||
|
|
||||||
let fieldDefinitions = cloneDeep(FIELDS)
|
let fieldDefinitions = cloneDeep(FIELDS)
|
||||||
|
|
||||||
|
export let onClosed
|
||||||
|
export let field = {
|
||||||
|
type: "string",
|
||||||
|
constraints: fieldDefinitions.STRING.constraints,
|
||||||
|
}
|
||||||
|
|
||||||
let originalName = field.name
|
let originalName = field.name
|
||||||
|
|
||||||
$: required =
|
$: required =
|
||||||
field.constraints &&
|
field.constraints &&
|
||||||
field.constraints.presence &&
|
field.constraints.presence &&
|
||||||
!field.constraints.presence.allowEmpty
|
!field.constraints.presence.allowEmpty
|
||||||
$: if (field.type) {
|
|
||||||
field.constraints = merge(
|
|
||||||
fieldDefinitions[field.type.toUpperCase()].constraints,
|
|
||||||
field.constraints
|
|
||||||
)
|
|
||||||
}
|
|
||||||
|
|
||||||
async function saveColumn() {
|
async function saveColumn() {
|
||||||
backendUiStore.update(state => {
|
backendUiStore.update(state => {
|
||||||
|
@ -43,14 +41,26 @@
|
||||||
})
|
})
|
||||||
onClosed()
|
onClosed()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function handleFieldConstraints(event) {
|
||||||
|
const { type, constraints } = fieldDefinitions[
|
||||||
|
event.target.value.toUpperCase()
|
||||||
|
]
|
||||||
|
field.type = type
|
||||||
|
field.constraints = constraints
|
||||||
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="actions">
|
<div class="actions">
|
||||||
<Input placeholder="Name" thin bind:value={field.name} />
|
<Input placeholder="Name" thin bind:value={field.name} />
|
||||||
|
|
||||||
<Select secondary thin bind:value={field.type}>
|
<Select
|
||||||
|
secondary
|
||||||
|
thin
|
||||||
|
on:change={handleFieldConstraints}
|
||||||
|
bind:value={field.value}>
|
||||||
{#each Object.values(fieldDefinitions) as field}
|
{#each Object.values(fieldDefinitions) as field}
|
||||||
<option value={field.type}>{field.name}</option>
|
<option value={field.value}>{field.name}</option>
|
||||||
{/each}
|
{/each}
|
||||||
</Select>
|
</Select>
|
||||||
|
|
||||||
|
@ -63,28 +73,28 @@
|
||||||
on:change={() => (field.constraints.presence.allowEmpty = required)} />
|
on:change={() => (field.constraints.presence.allowEmpty = required)} />
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{#if field.type === 'string'}
|
{#if field.value === 'string' && field.constraints}
|
||||||
<NumberBox
|
<NumberBox
|
||||||
label="Max Length"
|
label="Max Length"
|
||||||
bind:value={field.constraints.length.maximum} />
|
bind:value={field.constraints.length.maximum} />
|
||||||
<ValuesList
|
<ValuesList
|
||||||
label="Categories"
|
label="Categories"
|
||||||
bind:values={field.constraints.inclusion} />
|
bind:values={field.constraints.inclusion} />
|
||||||
{:else if field.type === 'datetime'}
|
{:else if field.value === 'datetime' && field.constraints}
|
||||||
<DatePicker
|
<DatePicker
|
||||||
label="Min Value"
|
label="Min Value"
|
||||||
bind:value={field.constraints.datetime.earliest} />
|
bind:value={field.constraints.datetime.earliest} />
|
||||||
<DatePicker
|
<DatePicker
|
||||||
label="Max Value"
|
label="Max Value"
|
||||||
bind:value={field.constraints.datetime.latest} />
|
bind:value={field.constraints.datetime.latest} />
|
||||||
{:else if field.type === 'number'}
|
{:else if field.value === 'number' && field.constraints}
|
||||||
<NumberBox
|
<NumberBox
|
||||||
label="Min Value"
|
label="Min Value"
|
||||||
bind:value={field.constraints.numericality.greaterThanOrEqualTo} />
|
bind:value={field.constraints.numericality.greaterThanOrEqualTo} />
|
||||||
<NumberBox
|
<NumberBox
|
||||||
label="Max Value"
|
label="Max Value"
|
||||||
bind:value={field.constraints.numericality.lessThanOrEqualTo} />
|
bind:value={field.constraints.numericality.lessThanOrEqualTo} />
|
||||||
{:else if field.type === 'link'}
|
{:else if field.value === 'link'}
|
||||||
<div class="field">
|
<div class="field">
|
||||||
<label>Link</label>
|
<label>Link</label>
|
||||||
<select class="budibase__input" bind:value={field.modelId}>
|
<select class="budibase__input" bind:value={field.modelId}>
|
||||||
|
|
|
@ -3,6 +3,7 @@ export const FIELDS = {
|
||||||
name: "Plain Text",
|
name: "Plain Text",
|
||||||
icon: "ri-text",
|
icon: "ri-text",
|
||||||
type: "string",
|
type: "string",
|
||||||
|
value: "string",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
|
@ -13,16 +14,18 @@ export const FIELDS = {
|
||||||
name: "Number",
|
name: "Number",
|
||||||
icon: "ri-number-1",
|
icon: "ri-number-1",
|
||||||
type: "number",
|
type: "number",
|
||||||
|
value: "number",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "number",
|
type: "number",
|
||||||
presence: { allowEmpty: true },
|
presence: { allowEmpty: true },
|
||||||
numericality: {},
|
numericality: { greaterThanOrEqualTo: "", lessThanOrEqualTo: "" },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
BOOLEAN: {
|
BOOLEAN: {
|
||||||
name: "True/False",
|
name: "True/False",
|
||||||
icon: "ri-toggle-line",
|
icon: "ri-toggle-line",
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
|
value: "boolean",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
presence: { allowEmpty: true },
|
presence: { allowEmpty: true },
|
||||||
|
@ -41,10 +44,15 @@ export const FIELDS = {
|
||||||
name: "Date/Time",
|
name: "Date/Time",
|
||||||
icon: "ri-calendar-event-fill",
|
icon: "ri-calendar-event-fill",
|
||||||
type: "string",
|
type: "string",
|
||||||
|
value: "datetime",
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
presence: { allowEmpty: true },
|
presence: { allowEmpty: true },
|
||||||
|
datetime: {
|
||||||
|
latest: "",
|
||||||
|
earliest: "",
|
||||||
|
},
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
// IMAGE: {
|
// IMAGE: {
|
||||||
|
|
Loading…
Reference in New Issue