Remove composite key

This commit is contained in:
Adria Navarro 2023-10-04 14:06:46 +02:00
parent e77cc3dac8
commit e01600d1bb
2 changed files with 23 additions and 7 deletions

View File

@ -43,7 +43,6 @@
const NUMBER_TYPE = FIELDS.NUMBER.type
const JSON_TYPE = FIELDS.JSON.type
const DATE_TYPE = FIELDS.DATETIME.type
const USER_REFRENCE_TYPE = FIELDS.BB_REFERENCE_USER.compositeType
const dispatch = createEventDispatcher()
const PROHIBITED_COLUMN_NAMES = ["type", "_id", "_rev", "tableId"]
@ -52,7 +51,14 @@
export let field
let mounted = false
let fieldDefinitions = cloneDeep(FIELDS)
let fieldDefinitions = Object.entries(FIELDS).reduce(
(acc, [fieldName, field]) => {
acc[field.compositeType?.toUpperCase() || fieldName] = field
return acc
},
{}
)
let originalName
let linkEditDisabled
let primaryDisplay
@ -334,6 +340,9 @@
editableColumn.constraints = definition.constraints
}
editableColumn.type = definition.type
editableColumn.subtype = definition.subtype
// Default relationships many to many
if (editableColumn.type === LINK_TYPE) {
editableColumn.relationshipType = RelationshipType.MANY_TO_MANY
@ -394,7 +403,7 @@
FIELDS.LINK,
FIELDS.FORMULA,
FIELDS.JSON,
FIELDS.BB_REFERENCE_USER,
FIELDS.USER,
{ name: "Auto Column", type: AUTO_TYPE },
]
} else {
@ -500,7 +509,7 @@
{/if}
<Select
disabled={!typeEnabled}
bind:value={editableColumn.type}
value={editableColumn.type}
on:change={handleTypeChange}
options={allowedTypes}
getOptionLabel={field => field.name}
@ -670,7 +679,7 @@
<Button primary text on:click={openJsonSchemaEditor}
>Open schema editor</Button
>
{:else if editableColumn.type === USER_REFRENCE_TYPE}
{:else if editableColumn.type === FieldType.BB_REFERENCE && [FieldSubtype.USER, FieldSubtype.USERS].includes(editableColumn.subtype)}
<Toggle
value={editableColumn.subtype === FieldSubtype.USERS}
on:change={e =>

View File

@ -122,12 +122,19 @@ export const FIELDS = {
presence: false,
},
},
BB_REFERENCE_USER: {
USER: {
name: "User",
type: FieldType.BB_REFERENCE,
subtype: FieldSubtype.USER,
compositeType: `${FieldType.BB_REFERENCE}_${FieldSubtype.USER}`, // Used for working with the subtype on CreateEditColumn as is it was a primary type
icon: "User",
compositeType: `${FieldType.BB_REFERENCE}_${FieldSubtype.USER}`, // Used for working with the subtype on CreateEditColumn as is it was a primary type
},
USERS: {
name: "Users",
type: FieldType.BB_REFERENCE,
subtype: FieldSubtype.USERS,
icon: "User",
compositeType: `${FieldType.BB_REFERENCE}_${FieldSubtype.USERS}`,
},
}