1
0
Fork 0
mirror of synced 2024-09-06 12:41:24 +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 { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
import { import {
FIELDS, FIELDS,
DEV_FIELDS,
RelationshipType, RelationshipType,
ALLOWABLE_STRING_OPTIONS, ALLOWABLE_STRING_OPTIONS,
ALLOWABLE_NUMBER_OPTIONS, ALLOWABLE_NUMBER_OPTIONS,
@ -73,6 +72,30 @@
} }
const typeMapping = {} 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) { $: if (primaryDisplay) {
editableColumn.constraints.presence = { allowEmpty: false } editableColumn.constraints.presence = { allowEmpty: false }
@ -348,33 +371,9 @@
return ALLOWABLE_NUMBER_OPTIONS 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) { if (!external) {
return [ return [
...Object.values(fieldDefinitions), ...Object.values(fieldDefinitions),
...Object.values(devFieldDefinitions),
{ name: "Auto Column", type: AUTO_TYPE }, { name: "Auto Column", type: AUTO_TYPE },
] ]
} else { } else {
@ -393,6 +392,7 @@
if (!external || table.sql) { if (!external || table.sql) {
fields = [...fields, FIELDS.LINK, FIELDS.ARRAY] fields = [...fields, FIELDS.LINK, FIELDS.ARRAY]
} }
// fields = [...fields, ...Object.values(devFieldDefinitions)]
return fields return fields
} }
} }

View file

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