Initial UI.

This commit is contained in:
Sam Rose 2024-07-17 11:02:47 +01:00
parent 083b595d50
commit aaaf173295
No known key found for this signature in database
2 changed files with 41 additions and 5 deletions

View File

@ -133,7 +133,9 @@
}
$: initialiseField(field, savingColumn)
$: checkConstraints(editableColumn)
$: required = !!editableColumn?.constraints?.presence || primaryDisplay
$: required = hasDefault
? false
: !!editableColumn?.constraints?.presence || primaryDisplay
$: uneditable =
$tables.selected?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(editableColumn.name)
@ -165,11 +167,19 @@
editableColumn?.type !== AUTO_TYPE &&
editableColumn?.type !== JSON_TYPE &&
!editableColumn.autocolumn
$: canHaveDefault =
editableColumn?.type === FieldType.NUMBER ||
editableColumn?.type === FieldType.JSON ||
editableColumn?.type === FieldType.DATETIME ||
editableColumn?.type === FieldType.LONGFORM ||
editableColumn?.type === FieldType.STRING
$: canBeRequired =
editableColumn?.type !== LINK_TYPE &&
!uneditable &&
editableColumn?.type !== AUTO_TYPE &&
!editableColumn.autocolumn
$: hasDefault =
editableColumn?.default != null && editableColumn?.default !== ""
$: externalTable = table.sourceType === DB_TYPE_EXTERNAL
// in the case of internal tables the sourceId will just be undefined
$: tableOptions = $tables.list.filter(
@ -349,12 +359,15 @@
}
}
function onChangeRequired(e) {
const req = e.detail
function setRequired(req) {
editableColumn.constraints.presence = req ? { allowEmpty: false } : false
required = req
}
function onChangeRequired(e) {
setRequired(e.detail)
}
function openJsonSchemaEditor() {
jsonSchemaModal.show()
}
@ -748,13 +761,37 @@
<Toggle
value={required}
on:change={onChangeRequired}
disabled={primaryDisplay}
disabled={primaryDisplay || hasDefault}
thin
text="Required"
/>
{/if}
</div>
{/if}
{#if canHaveDefault}
<div>
<ModalBindableInput
panel={ServerBindingPanel}
title="Default"
label="Default"
value={editableColumn.default}
on:change={e => {
editableColumn = {
...editableColumn,
default: e.detail,
}
if (e.detail) {
setRequired(false)
}
}}
bindings={getBindings({ table })}
allowJS
context={rowGoldenSample}
/>
</div>
{/if}
</Layout>
<div class="action-buttons">

View File

@ -114,7 +114,6 @@ export interface FormulaFieldMetadata extends BaseFieldSchema {
type: FieldType.FORMULA
formula: string
formulaType?: FormulaType
default?: string
}
export interface BBReferenceFieldMetadata