Fix initialisation of simple types
This commit is contained in:
parent
f215f69067
commit
58a22ccde8
|
@ -51,12 +51,14 @@
|
||||||
export let field
|
export let field
|
||||||
|
|
||||||
let mounted = false
|
let mounted = false
|
||||||
const fieldDefinitions = Object.values(FIELDS).reduce((acc, field) => {
|
const fieldDefinitions = Object.values(FIELDS).reduce(
|
||||||
const fieldId = makeFieldId(field.type, field.subtype)
|
// Storing the fields by complex field id
|
||||||
|
(acc, field) => ({
|
||||||
acc[fieldId] = { ...field, fieldId }
|
...acc,
|
||||||
return acc
|
[makeFieldId(field.type, field.subtype)]: field,
|
||||||
}, {})
|
}),
|
||||||
|
{}
|
||||||
|
)
|
||||||
|
|
||||||
function makeFieldId(type, subtype) {
|
function makeFieldId(type, subtype) {
|
||||||
return `${type}${subtype || ""}`.toUpperCase()
|
return `${type}${subtype || ""}`.toUpperCase()
|
||||||
|
@ -81,8 +83,8 @@
|
||||||
let jsonSchemaModal
|
let jsonSchemaModal
|
||||||
let allowedTypes = []
|
let allowedTypes = []
|
||||||
let editableColumn = {
|
let editableColumn = {
|
||||||
type: fieldDefinitions.STRING.type,
|
type: FIELDS.STRING.type,
|
||||||
constraints: fieldDefinitions.STRING.constraints,
|
constraints: FIELDS.STRING.constraints,
|
||||||
// Initial value for column name in other table for linked records
|
// Initial value for column name in other table for linked records
|
||||||
fieldName: $tables.selected.name,
|
fieldName: $tables.selected.name,
|
||||||
}
|
}
|
||||||
|
@ -148,11 +150,6 @@
|
||||||
$tables.selected.primaryDisplay == null ||
|
$tables.selected.primaryDisplay == null ||
|
||||||
$tables.selected.primaryDisplay === editableColumn.name
|
$tables.selected.primaryDisplay === editableColumn.name
|
||||||
|
|
||||||
editableColumn.fieldId = makeFieldId(
|
|
||||||
editableColumn.type,
|
|
||||||
editableColumn.subtype
|
|
||||||
)
|
|
||||||
|
|
||||||
// Here we are setting the relationship values based on the editableColumn
|
// Here we are setting the relationship values based on the editableColumn
|
||||||
// This part of the code is used when viewing an existing field hence the check
|
// This part of the code is used when viewing an existing field hence the check
|
||||||
// for the tableId
|
// for the tableId
|
||||||
|
@ -181,15 +178,18 @@
|
||||||
} else {
|
} else {
|
||||||
editableColumn.name = "Column 01"
|
editableColumn.name = "Column 01"
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!savingColumn) {
|
||||||
editableColumn.fieldId = makeFieldId(
|
editableColumn.fieldId = makeFieldId(
|
||||||
editableColumn.type,
|
editableColumn.type,
|
||||||
editableColumn.subtype
|
editableColumn.subtype
|
||||||
)
|
)
|
||||||
}
|
|
||||||
|
|
||||||
if (!savingColumn) {
|
allowedTypes = getAllowedTypes().map(t => ({
|
||||||
allowedTypes = getAllowedTypes()
|
fieldId: makeFieldId(t.type, t.subtype),
|
||||||
|
...t,
|
||||||
|
}))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -399,50 +399,44 @@
|
||||||
return ALLOWABLE_NUMBER_OPTIONS
|
return ALLOWABLE_NUMBER_OPTIONS
|
||||||
}
|
}
|
||||||
|
|
||||||
const userFieldDefinition =
|
const isUsers =
|
||||||
fieldDefinitions[
|
editableColumn.type === FieldType.BB_REFERENCE &&
|
||||||
makeFieldId(
|
editableColumn.subtype === FieldSubtype.USERS
|
||||||
FieldType.BB_REFERENCE,
|
|
||||||
editableColumn.type === FieldType.BB_REFERENCE
|
|
||||||
? editableColumn.subtype
|
|
||||||
: FieldSubtype.USER
|
|
||||||
)
|
|
||||||
]
|
|
||||||
|
|
||||||
if (!external) {
|
if (!external) {
|
||||||
return [
|
return [
|
||||||
fieldDefinitions.STRING,
|
FIELDS.STRING,
|
||||||
fieldDefinitions.BARCODEQR,
|
FIELDS.BARCODEQR,
|
||||||
fieldDefinitions.LONGFORM,
|
FIELDS.LONGFORM,
|
||||||
fieldDefinitions.OPTIONS,
|
FIELDS.OPTIONS,
|
||||||
fieldDefinitions.ARRAY,
|
FIELDS.ARRAY,
|
||||||
fieldDefinitions.NUMBER,
|
FIELDS.NUMBER,
|
||||||
fieldDefinitions.BIGINT,
|
FIELDS.BIGINT,
|
||||||
fieldDefinitions.BOOLEAN,
|
FIELDS.BOOLEAN,
|
||||||
fieldDefinitions.DATETIME,
|
FIELDS.DATETIME,
|
||||||
fieldDefinitions.ATTACHMENT,
|
FIELDS.ATTACHMENT,
|
||||||
fieldDefinitions.LINK,
|
FIELDS.LINK,
|
||||||
fieldDefinitions.FORMULA,
|
FIELDS.FORMULA,
|
||||||
fieldDefinitions.JSON,
|
FIELDS.JSON,
|
||||||
userFieldDefinition,
|
isUsers ? FIELDS.USERS : FIELDS.USER,
|
||||||
{ name: "Auto Column", type: AUTO_TYPE },
|
{ name: "Auto Column", type: AUTO_TYPE },
|
||||||
]
|
]
|
||||||
} else {
|
} else {
|
||||||
let fields = [
|
let fields = [
|
||||||
fieldDefinitions.STRING,
|
FIELDS.STRING,
|
||||||
fieldDefinitions.BARCODEQR,
|
FIELDS.BARCODEQR,
|
||||||
fieldDefinitions.LONGFORM,
|
FIELDS.LONGFORM,
|
||||||
fieldDefinitions.OPTIONS,
|
FIELDS.OPTIONS,
|
||||||
fieldDefinitions.DATETIME,
|
FIELDS.DATETIME,
|
||||||
fieldDefinitions.NUMBER,
|
FIELDS.NUMBER,
|
||||||
fieldDefinitions.BOOLEAN,
|
FIELDS.BOOLEAN,
|
||||||
fieldDefinitions.FORMULA,
|
FIELDS.FORMULA,
|
||||||
fieldDefinitions.BIGINT,
|
FIELDS.BIGINT,
|
||||||
userFieldDefinition,
|
isUsers ? FIELDS.USERS : FIELDS.USER,
|
||||||
]
|
]
|
||||||
// no-sql or a spreadsheet
|
// no-sql or a spreadsheet
|
||||||
if (!external || table.sql) {
|
if (!external || table.sql) {
|
||||||
fields = [...fields, fieldDefinitions.LINK, fieldDefinitions.ARRAY]
|
fields = [...fields, FIELDS.LINK, FIELDS.ARRAY]
|
||||||
}
|
}
|
||||||
return fields
|
return fields
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue