Some fixes for creation/editing of table columns.

This commit is contained in:
mike12345567 2021-04-16 13:47:30 +01:00
parent 5993ae6242
commit 9f22ab0a1a
1 changed files with 12 additions and 7 deletions

View File

@ -51,12 +51,14 @@
)
$: required = !!field?.constraints?.presence || primaryDisplay
$: uneditable =
$backendUiStore.selectedTable?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(field.name)
($backendUiStore.selectedTable?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(field.name)) ||
(originalName && field.type === LINK_TYPE)
$: invalid =
(field.type === LINK_TYPE && !field.tableId) ||
Object.keys($backendUiStore.draftTable.schema).some(
key => key === field.name
key => key === field.name && key !== originalName
)
// used to select what different options can be displayed for column type
@ -162,19 +164,22 @@
if (!linkTable) {
return null
}
const thisName = truncate(table.name, { length: 15 }),
linkName = truncate(linkTable.name, { length: 15 })
const thisName = truncate(table.name, { length: 14 }),
linkName = truncate(linkTable.name, { length: 14 })
return [
{
name: `Many ${thisName} rows → many ${linkName} rows`,
alt: `Many ${table.name} rows → many ${linkTable.name} rows`,
value: RelationshipTypes.MANY_TO_MANY,
},
{
name: `One ${linkName} row → many ${thisName} rows`,
alt: `One ${linkTable.name} rows → many ${table.name} rows`,
value: RelationshipTypes.ONE_TO_MANY,
},
{
name: `One ${thisName} row → many ${linkName} rows`,
alt: `One ${table.name} rows → many ${linkTable.name} rows`,
value: RelationshipTypes.MANY_TO_ONE,
},
]
@ -267,13 +272,13 @@
<div>
<Label grey extraSmall>Define the relationship</Label>
<div class="radio-buttons">
{#each relationshipOptions as { value, name }}
{#each relationshipOptions as { value, name, alt }}
<Radio
disabled={originalName}
name="Relationship type"
{value}
bind:group={field.relationshipType}>
<div class="radio-button-labels">
<div class="radio-button-labels" title={alt}>
<label for={value}>{name.split('→')[0]}</label>
<label class="rel-type-center" for={value}>→</label>
<label for={value}>{name.split('→')[1]}</label>