Initial UI.
This commit is contained in:
parent
083b595d50
commit
aaaf173295
|
@ -133,7 +133,9 @@
|
||||||
}
|
}
|
||||||
$: initialiseField(field, savingColumn)
|
$: initialiseField(field, savingColumn)
|
||||||
$: checkConstraints(editableColumn)
|
$: checkConstraints(editableColumn)
|
||||||
$: required = !!editableColumn?.constraints?.presence || primaryDisplay
|
$: required = hasDefault
|
||||||
|
? false
|
||||||
|
: !!editableColumn?.constraints?.presence || primaryDisplay
|
||||||
$: uneditable =
|
$: uneditable =
|
||||||
$tables.selected?._id === TableNames.USERS &&
|
$tables.selected?._id === TableNames.USERS &&
|
||||||
UNEDITABLE_USER_FIELDS.includes(editableColumn.name)
|
UNEDITABLE_USER_FIELDS.includes(editableColumn.name)
|
||||||
|
@ -165,11 +167,19 @@
|
||||||
editableColumn?.type !== AUTO_TYPE &&
|
editableColumn?.type !== AUTO_TYPE &&
|
||||||
editableColumn?.type !== JSON_TYPE &&
|
editableColumn?.type !== JSON_TYPE &&
|
||||||
!editableColumn.autocolumn
|
!editableColumn.autocolumn
|
||||||
|
$: canHaveDefault =
|
||||||
|
editableColumn?.type === FieldType.NUMBER ||
|
||||||
|
editableColumn?.type === FieldType.JSON ||
|
||||||
|
editableColumn?.type === FieldType.DATETIME ||
|
||||||
|
editableColumn?.type === FieldType.LONGFORM ||
|
||||||
|
editableColumn?.type === FieldType.STRING
|
||||||
$: canBeRequired =
|
$: canBeRequired =
|
||||||
editableColumn?.type !== LINK_TYPE &&
|
editableColumn?.type !== LINK_TYPE &&
|
||||||
!uneditable &&
|
!uneditable &&
|
||||||
editableColumn?.type !== AUTO_TYPE &&
|
editableColumn?.type !== AUTO_TYPE &&
|
||||||
!editableColumn.autocolumn
|
!editableColumn.autocolumn
|
||||||
|
$: hasDefault =
|
||||||
|
editableColumn?.default != null && editableColumn?.default !== ""
|
||||||
$: externalTable = table.sourceType === DB_TYPE_EXTERNAL
|
$: externalTable = table.sourceType === DB_TYPE_EXTERNAL
|
||||||
// in the case of internal tables the sourceId will just be undefined
|
// in the case of internal tables the sourceId will just be undefined
|
||||||
$: tableOptions = $tables.list.filter(
|
$: tableOptions = $tables.list.filter(
|
||||||
|
@ -349,12 +359,15 @@
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function onChangeRequired(e) {
|
function setRequired(req) {
|
||||||
const req = e.detail
|
|
||||||
editableColumn.constraints.presence = req ? { allowEmpty: false } : false
|
editableColumn.constraints.presence = req ? { allowEmpty: false } : false
|
||||||
required = req
|
required = req
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function onChangeRequired(e) {
|
||||||
|
setRequired(e.detail)
|
||||||
|
}
|
||||||
|
|
||||||
function openJsonSchemaEditor() {
|
function openJsonSchemaEditor() {
|
||||||
jsonSchemaModal.show()
|
jsonSchemaModal.show()
|
||||||
}
|
}
|
||||||
|
@ -748,13 +761,37 @@
|
||||||
<Toggle
|
<Toggle
|
||||||
value={required}
|
value={required}
|
||||||
on:change={onChangeRequired}
|
on:change={onChangeRequired}
|
||||||
disabled={primaryDisplay}
|
disabled={primaryDisplay || hasDefault}
|
||||||
thin
|
thin
|
||||||
text="Required"
|
text="Required"
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
{/if}
|
{/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>
|
</Layout>
|
||||||
|
|
||||||
<div class="action-buttons">
|
<div class="action-buttons">
|
||||||
|
|
|
@ -114,7 +114,6 @@ export interface FormulaFieldMetadata extends BaseFieldSchema {
|
||||||
type: FieldType.FORMULA
|
type: FieldType.FORMULA
|
||||||
formula: string
|
formula: string
|
||||||
formulaType?: FormulaType
|
formulaType?: FormulaType
|
||||||
default?: string
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface BBReferenceFieldMetadata
|
export interface BBReferenceFieldMetadata
|
||||||
|
|
Loading…
Reference in New Issue