1
0
Fork 0
mirror of synced 2024-07-05 22:40:39 +12:00

Rename FieldType.ATTACHMENT to FieldType.ATTACHMENTS

This commit is contained in:
Adria Navarro 2024-04-03 10:44:35 +02:00
parent 1992fbc5d2
commit a8c3011071
19 changed files with 30 additions and 30 deletions

View file

@ -9,7 +9,7 @@ const MAX_DEPTH = 1
const TYPES_TO_SKIP = [ const TYPES_TO_SKIP = [
FieldType.FORMULA, FieldType.FORMULA,
FieldType.LONGFORM, FieldType.LONGFORM,
FieldType.ATTACHMENT, FieldType.ATTACHMENTS,
//https://github.com/Budibase/budibase/issues/3030 //https://github.com/Budibase/budibase/issues/3030
FieldType.INTERNAL, FieldType.INTERNAL,
] ]

View file

@ -41,7 +41,7 @@ export const FieldTypeToComponentMap = {
[FieldType.BOOLEAN]: "booleanfield", [FieldType.BOOLEAN]: "booleanfield",
[FieldType.LONGFORM]: "longformfield", [FieldType.LONGFORM]: "longformfield",
[FieldType.DATETIME]: "datetimefield", [FieldType.DATETIME]: "datetimefield",
[FieldType.ATTACHMENT]: "attachmentfield", [FieldType.ATTACHMENTS]: "attachmentfield",
[FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield", [FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield",
[FieldType.LINK]: "relationshipfield", [FieldType.LINK]: "relationshipfield",
[FieldType.JSON]: "jsonfield", [FieldType.JSON]: "jsonfield",

View file

@ -109,7 +109,7 @@ export const FIELDS = {
}, },
ATTACHMENT: { ATTACHMENT: {
name: "Attachment List", name: "Attachment List",
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
icon: "Folder", icon: "Folder",
constraints: { constraints: {
type: "array", type: "array",
@ -299,7 +299,7 @@ export const PaginationLocations = [
export const BannedSearchTypes = [ export const BannedSearchTypes = [
FieldType.LINK, FieldType.LINK,
FieldType.ATTACHMENT, FieldType.ATTACHMENTS,
FieldType.FORMULA, FieldType.FORMULA,
FieldType.JSON, FieldType.JSON,
"jsonarray", "jsonarray",

View file

@ -15,7 +15,7 @@
[FieldType.BOOLEAN]: "booleanfield", [FieldType.BOOLEAN]: "booleanfield",
[FieldType.LONGFORM]: "longformfield", [FieldType.LONGFORM]: "longformfield",
[FieldType.DATETIME]: "datetimefield", [FieldType.DATETIME]: "datetimefield",
[FieldType.ATTACHMENT]: "attachmentfield", [FieldType.ATTACHMENTS]: "attachmentfield",
[FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield", [FieldType.ATTACHMENT_SINGLE]: "attachmentsinglefield",
[FieldType.LINK]: "relationshipfield", [FieldType.LINK]: "relationshipfield",
[FieldType.JSON]: "jsonfield", [FieldType.JSON]: "jsonfield",
@ -61,7 +61,7 @@
function getPropsByType(field) { function getPropsByType(field) {
const propsMapByType = { const propsMapByType = {
[FieldType.ATTACHMENT]: (_field, schema) => { [FieldType.ATTACHMENTS]: (_field, schema) => {
return { return {
maximum: schema?.constraints?.length?.maximum, maximum: schema?.constraints?.length?.maximum,
} }

View file

@ -15,7 +15,7 @@
export let maximum = undefined export let maximum = undefined
export let span export let span
export let helpText = null export let helpText = null
export let type = FieldType.ATTACHMENT export let type = FieldType.ATTACHMENTS
export let fieldApiMapper = { export let fieldApiMapper = {
get: value => value, get: value => value,
set: value => value, set: value => value,

View file

@ -23,7 +23,7 @@ const TypeComponentMap = {
[FieldType.ARRAY]: MultiSelectCell, [FieldType.ARRAY]: MultiSelectCell,
[FieldType.NUMBER]: NumberCell, [FieldType.NUMBER]: NumberCell,
[FieldType.BOOLEAN]: BooleanCell, [FieldType.BOOLEAN]: BooleanCell,
[FieldType.ATTACHMENT]: AttachmentCell, [FieldType.ATTACHMENTS]: AttachmentCell,
[FieldType.ATTACHMENT_SINGLE]: AttachmentSingleCell, [FieldType.ATTACHMENT_SINGLE]: AttachmentSingleCell,
[FieldType.LINK]: RelationshipCell, [FieldType.LINK]: RelationshipCell,
[FieldType.FORMULA]: FormulaCell, [FieldType.FORMULA]: FormulaCell,

View file

@ -95,7 +95,7 @@ export async function checkForColumnUpdates(
updatedTable.schema updatedTable.schema
).filter( ).filter(
(column): column is AttachmentFieldMetadata => (column): column is AttachmentFieldMetadata =>
column.type === FieldType.ATTACHMENT && column.type === FieldType.ATTACHMENTS &&
column.subtype !== oldTable?.schema[column.name]?.subtype column.subtype !== oldTable?.schema[column.name]?.subtype
) )
for (const attachmentColumn of changedAttachmentSubtypeColumns) { for (const attachmentColumn of changedAttachmentSubtypeColumns) {

View file

@ -232,7 +232,7 @@ describe.each([
constraints: { type: "string", presence: false }, constraints: { type: "string", presence: false },
} }
const attachment: FieldSchema = { const attachment: FieldSchema = {
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
name: "attachment", name: "attachment",
constraints: { type: "array", presence: false }, constraints: { type: "array", presence: false },
} }
@ -791,7 +791,7 @@ describe.each([
defaultTable({ defaultTable({
schema: { schema: {
attachment: { attachment: {
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
name: "attachment", name: "attachment",
constraints: { type: "array", presence: false }, constraints: { type: "array", presence: false },
}, },

View file

@ -299,7 +299,7 @@ export const DEFAULT_EMPLOYEE_TABLE_SCHEMA: Table = {
sortable: false, sortable: false,
}, },
"Badge Photo": { "Badge Photo": {
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
constraints: { constraints: {
type: FieldType.ARRAY, type: FieldType.ARRAY,
presence: false, presence: false,
@ -607,7 +607,7 @@ export const DEFAULT_EXPENSES_TABLE_SCHEMA: Table = {
ignoreTimezones: true, ignoreTimezones: true,
}, },
Attachment: { Attachment: {
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
constraints: { constraints: {
type: FieldType.ARRAY, type: FieldType.ARRAY,
presence: false, presence: false,

View file

@ -30,7 +30,7 @@ export async function getRowsWithAttachments(appId: string, table: Table) {
const db = dbCore.getDB(appId) const db = dbCore.getDB(appId)
const attachmentCols: string[] = [] const attachmentCols: string[] = []
for (let [key, column] of Object.entries(table.schema)) { for (let [key, column] of Object.entries(table.schema)) {
if (column.type === FieldType.ATTACHMENT) { if (column.type === FieldType.ATTACHMENTS) {
attachmentCols.push(key) attachmentCols.push(key)
} }
} }

View file

@ -175,13 +175,13 @@ export async function validate({
errors[fieldName] = [`${fieldName} is required`] errors[fieldName] = [`${fieldName} is required`]
} }
} else if ( } else if (
(type === FieldType.ATTACHMENT || type === FieldType.JSON) && (type === FieldType.ATTACHMENTS || type === FieldType.JSON) &&
typeof row[fieldName] === "string" typeof row[fieldName] === "string"
) { ) {
// this should only happen if there is an error // this should only happen if there is an error
try { try {
const json = JSON.parse(row[fieldName]) const json = JSON.parse(row[fieldName])
if (type === FieldType.ATTACHMENT) { if (type === FieldType.ATTACHMENTS) {
if (Array.isArray(json)) { if (Array.isArray(json)) {
row[fieldName] = json row[fieldName] = json
} else { } else {

View file

@ -34,7 +34,7 @@ export class AttachmentCleanup {
let files: string[] = [] let files: string[] = []
const tableSchema = opts.oldTable?.schema || table.schema const tableSchema = opts.oldTable?.schema || table.schema
for (let [key, schema] of Object.entries(tableSchema)) { for (let [key, schema] of Object.entries(tableSchema)) {
if (schema.type !== FieldType.ATTACHMENT) { if (schema.type !== FieldType.ATTACHMENTS) {
continue continue
} }
const columnRemoved = opts.oldTable && !table.schema[key] const columnRemoved = opts.oldTable && !table.schema[key]
@ -68,7 +68,7 @@ export class AttachmentCleanup {
return AttachmentCleanup.coreCleanup(() => { return AttachmentCleanup.coreCleanup(() => {
let files: string[] = [] let files: string[] = []
for (let [key, schema] of Object.entries(table.schema)) { for (let [key, schema] of Object.entries(table.schema)) {
if (schema.type !== FieldType.ATTACHMENT) { if (schema.type !== FieldType.ATTACHMENTS) {
continue continue
} }
rows.forEach(row => { rows.forEach(row => {
@ -88,7 +88,7 @@ export class AttachmentCleanup {
return AttachmentCleanup.coreCleanup(() => { return AttachmentCleanup.coreCleanup(() => {
let files: string[] = [] let files: string[] = []
for (let [key, schema] of Object.entries(table.schema)) { for (let [key, schema] of Object.entries(table.schema)) {
if (schema.type !== FieldType.ATTACHMENT) { if (schema.type !== FieldType.ATTACHMENTS) {
continue continue
} }
const oldKeys = const oldKeys =

View file

@ -148,7 +148,7 @@ export async function inputProcessing(
} }
// remove any attachment urls, they are generated on read // remove any attachment urls, they are generated on read
if (field.type === FieldType.ATTACHMENT) { if (field.type === FieldType.ATTACHMENTS) {
const attachments = clonedRow[key] const attachments = clonedRow[key]
if (attachments?.length) { if (attachments?.length) {
attachments.forEach((attachment: RowAttachment) => { attachments.forEach((attachment: RowAttachment) => {
@ -216,7 +216,7 @@ export async function outputProcessing<T extends Row[] | Row>(
// process complex types: attachements, bb references... // process complex types: attachements, bb references...
for (let [property, column] of Object.entries(table.schema)) { for (let [property, column] of Object.entries(table.schema)) {
if (column.type === FieldType.ATTACHMENT) { if (column.type === FieldType.ATTACHMENTS) {
for (let row of enriched) { for (let row of enriched) {
if (row[property] == null || !Array.isArray(row[property])) { if (row[property] == null || !Array.isArray(row[property])) {
continue continue

View file

@ -106,7 +106,7 @@ export const TYPE_TRANSFORM_MAP: any = {
return date return date
}, },
}, },
[FieldType.ATTACHMENT]: { [FieldType.ATTACHMENTS]: {
//@ts-ignore //@ts-ignore
[null]: [], [null]: [],
//@ts-ignore //@ts-ignore

View file

@ -34,7 +34,7 @@ function table(): Table {
schema: { schema: {
attach: { attach: {
name: "attach", name: "attach",
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
constraints: {}, constraints: {},
}, },
}, },

View file

@ -82,7 +82,7 @@ describe("rowProcessor - outputProcessing", () => {
sourceType: TableSourceType.INTERNAL, sourceType: TableSourceType.INTERNAL,
schema: { schema: {
attach: { attach: {
type: FieldType.ATTACHMENT, type: FieldType.ATTACHMENTS,
name: "attach", name: "attach",
constraints: {}, constraints: {},
}, },

View file

@ -13,7 +13,7 @@ const allowDisplayColumnByType: Record<FieldType, boolean> = {
[FieldType.BIGINT]: true, [FieldType.BIGINT]: true,
[FieldType.BOOLEAN]: false, [FieldType.BOOLEAN]: false,
[FieldType.ARRAY]: false, [FieldType.ARRAY]: false,
[FieldType.ATTACHMENT]: false, [FieldType.ATTACHMENTS]: false,
[FieldType.ATTACHMENT_SINGLE]: false, [FieldType.ATTACHMENT_SINGLE]: false,
[FieldType.LINK]: false, [FieldType.LINK]: false,
[FieldType.JSON]: false, [FieldType.JSON]: false,
@ -34,7 +34,7 @@ const allowSortColumnByType: Record<FieldType, boolean> = {
[FieldType.JSON]: true, [FieldType.JSON]: true,
[FieldType.FORMULA]: false, [FieldType.FORMULA]: false,
[FieldType.ATTACHMENT]: false, [FieldType.ATTACHMENTS]: false,
[FieldType.ATTACHMENT_SINGLE]: false, [FieldType.ATTACHMENT_SINGLE]: false,
[FieldType.ARRAY]: false, [FieldType.ARRAY]: false,
[FieldType.LINK]: false, [FieldType.LINK]: false,

View file

@ -8,7 +8,7 @@ export enum FieldType {
BOOLEAN = "boolean", BOOLEAN = "boolean",
ARRAY = "array", ARRAY = "array",
DATETIME = "datetime", DATETIME = "datetime",
ATTACHMENT = "attachment", ATTACHMENTS = "attachment",
ATTACHMENT_SINGLE = "attachment_single", ATTACHMENT_SINGLE = "attachment_single",
LINK = "link", LINK = "link",
FORMULA = "formula", FORMULA = "formula",

View file

@ -114,7 +114,7 @@ export interface BBReferenceFieldMetadata
export interface AttachmentFieldMetadata export interface AttachmentFieldMetadata
extends Omit<BaseFieldSchema, "subtype"> { extends Omit<BaseFieldSchema, "subtype"> {
type: FieldType.ATTACHMENT type: FieldType.ATTACHMENTS
subtype?: FieldSubtype.SINGLE subtype?: FieldSubtype.SINGLE
} }
@ -164,7 +164,7 @@ interface OtherFieldMetadata extends BaseFieldSchema {
| FieldType.NUMBER | FieldType.NUMBER
| FieldType.LONGFORM | FieldType.LONGFORM
| FieldType.BB_REFERENCE | FieldType.BB_REFERENCE
| FieldType.ATTACHMENT | FieldType.ATTACHMENTS
> >
} }
@ -217,5 +217,5 @@ export function isBBReferenceField(
export function isAttachmentField( export function isAttachmentField(
field: FieldSchema field: FieldSchema
): field is AttachmentFieldMetadata { ): field is AttachmentFieldMetadata {
return field.type === FieldType.ATTACHMENT return field.type === FieldType.ATTACHMENTS
} }