Rename FieldType.ATTACHMENT to FieldType.ATTACHMENTS
This commit is contained in:
parent
1992fbc5d2
commit
a8c3011071
|
@ -9,7 +9,7 @@ const MAX_DEPTH = 1
|
|||
const TYPES_TO_SKIP = [
|
||||
FieldType.FORMULA,
|
||||
FieldType.LONGFORM,
|
||||
FieldType.ATTACHMENT,
|
||||
FieldType.ATTACHMENTS,
|
||||
//https://github.com/Budibase/budibase/issues/3030
|
||||
FieldType.INTERNAL,
|
||||
]
|
||||
|
|
|
@ -41,7 +41,7 @@ export const FieldTypeToComponentMap = {
|
|||
[FieldType.BOOLEAN]: "booleanfield",
|
||||
[FieldType.LONGFORM]: "longformfield",
|
||||
[FieldType.DATETIME]: "datetimefield",
|
||||
[FieldType.ATTACHMENT]: "attachmentfield",
|
||||
[FieldType.ATTACHMENTS]: "attachmentfield",
|
||||
[FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield",
|
||||
[FieldType.LINK]: "relationshipfield",
|
||||
[FieldType.JSON]: "jsonfield",
|
||||
|
|
|
@ -109,7 +109,7 @@ export const FIELDS = {
|
|||
},
|
||||
ATTACHMENT: {
|
||||
name: "Attachment List",
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
icon: "Folder",
|
||||
constraints: {
|
||||
type: "array",
|
||||
|
@ -299,7 +299,7 @@ export const PaginationLocations = [
|
|||
|
||||
export const BannedSearchTypes = [
|
||||
FieldType.LINK,
|
||||
FieldType.ATTACHMENT,
|
||||
FieldType.ATTACHMENTS,
|
||||
FieldType.FORMULA,
|
||||
FieldType.JSON,
|
||||
"jsonarray",
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
[FieldType.BOOLEAN]: "booleanfield",
|
||||
[FieldType.LONGFORM]: "longformfield",
|
||||
[FieldType.DATETIME]: "datetimefield",
|
||||
[FieldType.ATTACHMENT]: "attachmentfield",
|
||||
[FieldType.ATTACHMENTS]: "attachmentfield",
|
||||
[FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield",
|
||||
[FieldType.LINK]: "relationshipfield",
|
||||
[FieldType.JSON]: "jsonfield",
|
||||
|
@ -61,7 +61,7 @@
|
|||
|
||||
function getPropsByType(field) {
|
||||
const propsMapByType = {
|
||||
[FieldType.ATTACHMENT]: (_field, schema) => {
|
||||
[FieldType.ATTACHMENTS]: (_field, schema) => {
|
||||
return {
|
||||
maximum: schema?.constraints?.length?.maximum,
|
||||
}
|
||||
|
|
|
@ -15,7 +15,7 @@
|
|||
export let maximum = undefined
|
||||
export let span
|
||||
export let helpText = null
|
||||
export let type = FieldType.ATTACHMENT
|
||||
export let type = FieldType.ATTACHMENTS
|
||||
export let fieldApiMapper = {
|
||||
get: value => value,
|
||||
set: value => value,
|
||||
|
|
|
@ -23,7 +23,7 @@ const TypeComponentMap = {
|
|||
[FieldType.ARRAY]: MultiSelectCell,
|
||||
[FieldType.NUMBER]: NumberCell,
|
||||
[FieldType.BOOLEAN]: BooleanCell,
|
||||
[FieldType.ATTACHMENT]: AttachmentCell,
|
||||
[FieldType.ATTACHMENTS]: AttachmentCell,
|
||||
[FieldType.ATTACHMENT_SINGLE]: AttachmentSingleCell,
|
||||
[FieldType.LINK]: RelationshipCell,
|
||||
[FieldType.FORMULA]: FormulaCell,
|
||||
|
|
|
@ -95,7 +95,7 @@ export async function checkForColumnUpdates(
|
|||
updatedTable.schema
|
||||
).filter(
|
||||
(column): column is AttachmentFieldMetadata =>
|
||||
column.type === FieldType.ATTACHMENT &&
|
||||
column.type === FieldType.ATTACHMENTS &&
|
||||
column.subtype !== oldTable?.schema[column.name]?.subtype
|
||||
)
|
||||
for (const attachmentColumn of changedAttachmentSubtypeColumns) {
|
||||
|
|
|
@ -232,7 +232,7 @@ describe.each([
|
|||
constraints: { type: "string", presence: false },
|
||||
}
|
||||
const attachment: FieldSchema = {
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
name: "attachment",
|
||||
constraints: { type: "array", presence: false },
|
||||
}
|
||||
|
@ -791,7 +791,7 @@ describe.each([
|
|||
defaultTable({
|
||||
schema: {
|
||||
attachment: {
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
name: "attachment",
|
||||
constraints: { type: "array", presence: false },
|
||||
},
|
||||
|
|
|
@ -299,7 +299,7 @@ export const DEFAULT_EMPLOYEE_TABLE_SCHEMA: Table = {
|
|||
sortable: false,
|
||||
},
|
||||
"Badge Photo": {
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
presence: false,
|
||||
|
@ -607,7 +607,7 @@ export const DEFAULT_EXPENSES_TABLE_SCHEMA: Table = {
|
|||
ignoreTimezones: true,
|
||||
},
|
||||
Attachment: {
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
constraints: {
|
||||
type: FieldType.ARRAY,
|
||||
presence: false,
|
||||
|
|
|
@ -30,7 +30,7 @@ export async function getRowsWithAttachments(appId: string, table: Table) {
|
|||
const db = dbCore.getDB(appId)
|
||||
const attachmentCols: string[] = []
|
||||
for (let [key, column] of Object.entries(table.schema)) {
|
||||
if (column.type === FieldType.ATTACHMENT) {
|
||||
if (column.type === FieldType.ATTACHMENTS) {
|
||||
attachmentCols.push(key)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -175,13 +175,13 @@ export async function validate({
|
|||
errors[fieldName] = [`${fieldName} is required`]
|
||||
}
|
||||
} else if (
|
||||
(type === FieldType.ATTACHMENT || type === FieldType.JSON) &&
|
||||
(type === FieldType.ATTACHMENTS || type === FieldType.JSON) &&
|
||||
typeof row[fieldName] === "string"
|
||||
) {
|
||||
// this should only happen if there is an error
|
||||
try {
|
||||
const json = JSON.parse(row[fieldName])
|
||||
if (type === FieldType.ATTACHMENT) {
|
||||
if (type === FieldType.ATTACHMENTS) {
|
||||
if (Array.isArray(json)) {
|
||||
row[fieldName] = json
|
||||
} else {
|
||||
|
|
|
@ -34,7 +34,7 @@ export class AttachmentCleanup {
|
|||
let files: string[] = []
|
||||
const tableSchema = opts.oldTable?.schema || table.schema
|
||||
for (let [key, schema] of Object.entries(tableSchema)) {
|
||||
if (schema.type !== FieldType.ATTACHMENT) {
|
||||
if (schema.type !== FieldType.ATTACHMENTS) {
|
||||
continue
|
||||
}
|
||||
const columnRemoved = opts.oldTable && !table.schema[key]
|
||||
|
@ -68,7 +68,7 @@ export class AttachmentCleanup {
|
|||
return AttachmentCleanup.coreCleanup(() => {
|
||||
let files: string[] = []
|
||||
for (let [key, schema] of Object.entries(table.schema)) {
|
||||
if (schema.type !== FieldType.ATTACHMENT) {
|
||||
if (schema.type !== FieldType.ATTACHMENTS) {
|
||||
continue
|
||||
}
|
||||
rows.forEach(row => {
|
||||
|
@ -88,7 +88,7 @@ export class AttachmentCleanup {
|
|||
return AttachmentCleanup.coreCleanup(() => {
|
||||
let files: string[] = []
|
||||
for (let [key, schema] of Object.entries(table.schema)) {
|
||||
if (schema.type !== FieldType.ATTACHMENT) {
|
||||
if (schema.type !== FieldType.ATTACHMENTS) {
|
||||
continue
|
||||
}
|
||||
const oldKeys =
|
||||
|
|
|
@ -148,7 +148,7 @@ export async function inputProcessing(
|
|||
}
|
||||
|
||||
// remove any attachment urls, they are generated on read
|
||||
if (field.type === FieldType.ATTACHMENT) {
|
||||
if (field.type === FieldType.ATTACHMENTS) {
|
||||
const attachments = clonedRow[key]
|
||||
if (attachments?.length) {
|
||||
attachments.forEach((attachment: RowAttachment) => {
|
||||
|
@ -216,7 +216,7 @@ export async function outputProcessing<T extends Row[] | Row>(
|
|||
|
||||
// process complex types: attachements, bb references...
|
||||
for (let [property, column] of Object.entries(table.schema)) {
|
||||
if (column.type === FieldType.ATTACHMENT) {
|
||||
if (column.type === FieldType.ATTACHMENTS) {
|
||||
for (let row of enriched) {
|
||||
if (row[property] == null || !Array.isArray(row[property])) {
|
||||
continue
|
||||
|
|
|
@ -106,7 +106,7 @@ export const TYPE_TRANSFORM_MAP: any = {
|
|||
return date
|
||||
},
|
||||
},
|
||||
[FieldType.ATTACHMENT]: {
|
||||
[FieldType.ATTACHMENTS]: {
|
||||
//@ts-ignore
|
||||
[null]: [],
|
||||
//@ts-ignore
|
||||
|
|
|
@ -34,7 +34,7 @@ function table(): Table {
|
|||
schema: {
|
||||
attach: {
|
||||
name: "attach",
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
constraints: {},
|
||||
},
|
||||
},
|
||||
|
|
|
@ -82,7 +82,7 @@ describe("rowProcessor - outputProcessing", () => {
|
|||
sourceType: TableSourceType.INTERNAL,
|
||||
schema: {
|
||||
attach: {
|
||||
type: FieldType.ATTACHMENT,
|
||||
type: FieldType.ATTACHMENTS,
|
||||
name: "attach",
|
||||
constraints: {},
|
||||
},
|
||||
|
|
|
@ -13,7 +13,7 @@ const allowDisplayColumnByType: Record<FieldType, boolean> = {
|
|||
[FieldType.BIGINT]: true,
|
||||
[FieldType.BOOLEAN]: false,
|
||||
[FieldType.ARRAY]: false,
|
||||
[FieldType.ATTACHMENT]: false,
|
||||
[FieldType.ATTACHMENTS]: false,
|
||||
[FieldType.ATTACHMENT_SINGLE]: false,
|
||||
[FieldType.LINK]: false,
|
||||
[FieldType.JSON]: false,
|
||||
|
@ -34,7 +34,7 @@ const allowSortColumnByType: Record<FieldType, boolean> = {
|
|||
[FieldType.JSON]: true,
|
||||
|
||||
[FieldType.FORMULA]: false,
|
||||
[FieldType.ATTACHMENT]: false,
|
||||
[FieldType.ATTACHMENTS]: false,
|
||||
[FieldType.ATTACHMENT_SINGLE]: false,
|
||||
[FieldType.ARRAY]: false,
|
||||
[FieldType.LINK]: false,
|
||||
|
|
|
@ -8,7 +8,7 @@ export enum FieldType {
|
|||
BOOLEAN = "boolean",
|
||||
ARRAY = "array",
|
||||
DATETIME = "datetime",
|
||||
ATTACHMENT = "attachment",
|
||||
ATTACHMENTS = "attachment",
|
||||
ATTACHMENT_SINGLE = "attachment_single",
|
||||
LINK = "link",
|
||||
FORMULA = "formula",
|
||||
|
|
|
@ -114,7 +114,7 @@ export interface BBReferenceFieldMetadata
|
|||
|
||||
export interface AttachmentFieldMetadata
|
||||
extends Omit<BaseFieldSchema, "subtype"> {
|
||||
type: FieldType.ATTACHMENT
|
||||
type: FieldType.ATTACHMENTS
|
||||
subtype?: FieldSubtype.SINGLE
|
||||
}
|
||||
|
||||
|
@ -164,7 +164,7 @@ interface OtherFieldMetadata extends BaseFieldSchema {
|
|||
| FieldType.NUMBER
|
||||
| FieldType.LONGFORM
|
||||
| FieldType.BB_REFERENCE
|
||||
| FieldType.ATTACHMENT
|
||||
| FieldType.ATTACHMENTS
|
||||
>
|
||||
}
|
||||
|
||||
|
@ -217,5 +217,5 @@ export function isBBReferenceField(
|
|||
export function isAttachmentField(
|
||||
field: FieldSchema
|
||||
): field is AttachmentFieldMetadata {
|
||||
return field.type === FieldType.ATTACHMENT
|
||||
return field.type === FieldType.ATTACHMENTS
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue