diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js
index 4c127fbe0b..ee7a4da0fd 100644
--- a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js
+++ b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js
@@ -179,6 +179,10 @@ export function makeDatasourceFormComponents(datasource) {
let fields = Object.keys(schema || {})
fields.forEach(field => {
const fieldSchema = schema[field]
+ // skip autocolumns
+ if (fieldSchema.autocolumn) {
+ return
+ }
const fieldType =
typeof fieldSchema === "object" ? fieldSchema.type : fieldSchema
const componentType = fieldTypeToComponentMap[fieldType]
diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte
index bc18b7559c..0045d2261c 100644
--- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte
+++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte
@@ -10,12 +10,13 @@
import { cloneDeep } from "lodash/fp"
import { backendUiStore } from "builderStore"
import { TableNames, UNEDITABLE_USER_FIELDS } from "constants"
- import { FIELDS } from "constants/backend"
+ import { FIELDS, getAutoColumnInformation, buildAutoColumn, AUTO_COLUMN_SUB_TYPES } from "constants/backend"
import { notifier } from "builderStore/store/notifications"
import ValuesList from "components/common/ValuesList.svelte"
import DatePicker from "components/common/DatePicker.svelte"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
+ const AUTO_COL = "auto"
let fieldDefinitions = cloneDeep(FIELDS)
export let onClosed
@@ -43,7 +44,17 @@
$backendUiStore.selectedTable?._id === TableNames.USERS &&
UNEDITABLE_USER_FIELDS.includes(field.name)
+ // used to select what different options can be displayed for column type
+ $: canBeSearched = field.type !== 'link' &&
+ field.subtype !== AUTO_COLUMN_SUB_TYPES.CREATED_BY &&
+ field.subtype !== AUTO_COLUMN_SUB_TYPES.UPDATED_BY
+ $: canBeDisplay = field.type !== 'link' && field.type !== AUTO_COL
+ $: canBeRequired = field.type !== 'link' && !uneditable && field.type !== AUTO_COL
+
async function saveColumn() {
+ if (field.type === AUTO_COL) {
+ field = buildAutoColumn($backendUiStore.draftTable.name, field.name, field.subtype)
+ }
backendUiStore.update(state => {
backendUiStore.actions.tables.saveField({
originalName,
@@ -67,11 +78,14 @@
}
function handleFieldConstraints(event) {
- const { type, constraints } = fieldDefinitions[
+ const definition = fieldDefinitions[
event.target.value.toUpperCase()
]
- field.type = type
- field.constraints = constraints
+ if (!definition) {
+ return
+ }
+ field.type = definition.type
+ field.constraints = definition.constraints
}
function onChangeRequired(e) {
@@ -124,9 +138,10 @@
{#each Object.values(fieldDefinitions) as field}
{/each}
+
- {#if field.type !== 'link' && !uneditable}
+ {#if canBeRequired}
{/if}
- {#if field.type !== 'link'}
+ {#if canBeDisplay}
+ {/if}
+ {#if canBeSearched}
+ {:else if field.type === AUTO_COL}
+
{/if}