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