Skip to content

Commit

Permalink
Merge pull request #12078 from Budibase/fix/12068-autocolumn-data-ui-…
Browse files Browse the repository at this point in the history
…fixes

Fix autocolumn addition/editing in data UI
  • Loading branch information
mike12345567 authored Oct 17, 2023
2 parents 8fc4745 + ba04cd5 commit 5bc8905
Show file tree
Hide file tree
Showing 2 changed files with 34 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@
import { FieldType, FieldSubtype, SourceName } from "@budibase/types"
import RelationshipSelector from "components/common/RelationshipSelector.svelte"
const AUTO_TYPE = "auto"
const AUTO_TYPE = FIELDS.AUTO.type
const FORMULA_TYPE = FIELDS.FORMULA.type
const LINK_TYPE = FIELDS.LINK.type
const STRING_TYPE = FIELDS.STRING.type
Expand All @@ -60,8 +60,13 @@
{}
)
function makeFieldId(type, subtype) {
return `${type}${subtype || ""}`.toUpperCase()
function makeFieldId(type, subtype, autocolumn) {
// don't make field IDs for auto types
if (type === AUTO_TYPE || autocolumn) {
return type.toUpperCase()
} else {
return `${type}${subtype || ""}`.toUpperCase()
}
}
let originalName
Expand Down Expand Up @@ -183,7 +188,8 @@
if (!savingColumn) {
editableColumn.fieldId = makeFieldId(
editableColumn.type,
editableColumn.subtype
editableColumn.subtype,
editableColumn.autocolumn
)
allowedTypes = getAllowedTypes().map(t => ({
Expand Down Expand Up @@ -419,7 +425,7 @@
FIELDS.FORMULA,
FIELDS.JSON,
isUsers ? FIELDS.USERS : FIELDS.USER,
{ name: "Auto Column", type: AUTO_TYPE },
FIELDS.AUTO,
]
} else {
let fields = [
Expand Down Expand Up @@ -538,7 +544,7 @@
getOptionValue={field => field.fieldId}
getOptionIcon={field => field.icon}
isOptionEnabled={option => {
if (option.type == AUTO_TYPE) {
if (option.type === AUTO_TYPE) {
return availableAutoColumnKeys?.length > 0
}
return true
Expand Down
38 changes: 22 additions & 16 deletions packages/builder/src/constants/backend/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,21 @@
import { FieldType, FieldSubtype } from "@budibase/types"

export const AUTO_COLUMN_SUB_TYPES = {
AUTO_ID: "autoID",
CREATED_BY: "createdBy",
CREATED_AT: "createdAt",
UPDATED_BY: "updatedBy",
UPDATED_AT: "updatedAt",
}

export const AUTO_COLUMN_DISPLAY_NAMES = {
AUTO_ID: "Auto ID",
CREATED_BY: "Created By",
CREATED_AT: "Created At",
UPDATED_BY: "Updated By",
UPDATED_AT: "Updated At",
}

export const FIELDS = {
STRING: {
name: "Text",
Expand Down Expand Up @@ -107,6 +123,12 @@ export const FIELDS = {
presence: false,
},
},
AUTO: {
name: "Auto Column",
type: FieldType.AUTO,
icon: "MagicWand",
constraints: {},
},
FORMULA: {
name: "Formula",
type: FieldType.FORMULA,
Expand Down Expand Up @@ -139,22 +161,6 @@ export const FIELDS = {
},
}

export const AUTO_COLUMN_SUB_TYPES = {
AUTO_ID: "autoID",
CREATED_BY: "createdBy",
CREATED_AT: "createdAt",
UPDATED_BY: "updatedBy",
UPDATED_AT: "updatedAt",
}

export const AUTO_COLUMN_DISPLAY_NAMES = {
AUTO_ID: "Auto ID",
CREATED_BY: "Created By",
CREATED_AT: "Created At",
UPDATED_BY: "Updated By",
UPDATED_AT: "Updated At",
}

export const FILE_TYPES = {
IMAGE: ["png", "tiff", "gif", "raw", "jpg", "jpeg"],
CODE: ["js", "rs", "py", "java", "rb", "hs", "yml"],
Expand Down

0 comments on commit 5bc8905

Please sign in to comment.