1
0
Fork 0
mirror of synced 2024-07-21 06:05:52 +12:00

Merge dev fields to fields

This commit is contained in:
Adria Navarro 2023-09-14 16:49:41 +02:00
parent ca5f7cba09
commit 00d2adccec
2 changed files with 25 additions and 28 deletions

View file

@ -20,7 +20,6 @@
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
import {
FIELDS,
DEV_FIELDS,
RelationshipType,
ALLOWABLE_STRING_OPTIONS,
ALLOWABLE_NUMBER_OPTIONS,
@ -73,6 +72,30 @@
}
const typeMapping = {}
if (!$admin.isDev) {
delete fieldDefinitions.USER
}
// Handling fields with subtypes
fieldDefinitions = Object.entries(fieldDefinitions).reduce(
(p, [key, field]) => {
if (field.subtype) {
const composedType = `${field.type}_${field.subtype}`
p[key] = {
...field,
type: composedType,
}
typeMapping[composedType] = {
type: field.type,
subtype: field.subtype,
}
} else {
p[key] = field
}
return p
},
{}
)
$: if (primaryDisplay) {
editableColumn.constraints.presence = { allowEmpty: false }
@ -348,33 +371,9 @@
return ALLOWABLE_NUMBER_OPTIONS
}
let devFieldDefinitions = {}
if ($admin.isDev) {
devFieldDefinitions = Object.entries(DEV_FIELDS).reduce(
(p, [key, field]) => {
if (field.subtype) {
const composedType = `${field.type}_${field.subtype}`
p[key] = {
...field,
type: composedType,
}
typeMapping[composedType] = {
type: field.type,
subtype: field.subtype,
}
} else {
p[key] = field
}
return p
},
{}
)
}
if (!external) {
return [
...Object.values(fieldDefinitions),
...Object.values(devFieldDefinitions),
{ name: "Auto Column", type: AUTO_TYPE },
]
} else {
@ -393,6 +392,7 @@
if (!external || table.sql) {
fields = [...fields, FIELDS.LINK, FIELDS.ARRAY]
}
// fields = [...fields, ...Object.values(devFieldDefinitions)]
return fields
}
}

View file

@ -120,9 +120,6 @@ export const FIELDS = {
presence: false,
},
},
}
export const DEV_FIELDS = {
USER: {
name: "User",
type: "internal",