Single attachment subtype
This commit is contained in:
parent
23ac11ad6b
commit
59a7d8052a
|
@ -34,7 +34,12 @@
|
||||||
import { getBindings } from "components/backend/DataTable/formula"
|
import { getBindings } from "components/backend/DataTable/formula"
|
||||||
import JSONSchemaModal from "./JSONSchemaModal.svelte"
|
import JSONSchemaModal from "./JSONSchemaModal.svelte"
|
||||||
import { ValidColumnNameRegex } from "@budibase/shared-core"
|
import { ValidColumnNameRegex } from "@budibase/shared-core"
|
||||||
import { FieldType, FieldSubtype, SourceName } from "@budibase/types"
|
import {
|
||||||
|
FieldType,
|
||||||
|
FieldSubtype,
|
||||||
|
SourceName,
|
||||||
|
FieldTypeSubtypes,
|
||||||
|
} from "@budibase/types"
|
||||||
import RelationshipSelector from "components/common/RelationshipSelector.svelte"
|
import RelationshipSelector from "components/common/RelationshipSelector.svelte"
|
||||||
import { RowUtils } from "@budibase/frontend-core"
|
import { RowUtils } from "@budibase/frontend-core"
|
||||||
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
||||||
|
@ -191,8 +196,10 @@
|
||||||
// don't make field IDs for auto types
|
// don't make field IDs for auto types
|
||||||
if (type === AUTO_TYPE || autocolumn) {
|
if (type === AUTO_TYPE || autocolumn) {
|
||||||
return type.toUpperCase()
|
return type.toUpperCase()
|
||||||
} else {
|
} else if (type === FieldType.BB_REFERENCE) {
|
||||||
return `${type}${subtype || ""}`.toUpperCase()
|
return `${type}${subtype || ""}`.toUpperCase()
|
||||||
|
} else {
|
||||||
|
return type.toUpperCase()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -705,17 +712,12 @@
|
||||||
/>
|
/>
|
||||||
{:else if editableColumn.type === FieldType.ATTACHMENT}
|
{:else if editableColumn.type === FieldType.ATTACHMENT}
|
||||||
<Toggle
|
<Toggle
|
||||||
value={editableColumn.constraints?.length?.maximum !== 1}
|
value={editableColumn.subtype !== FieldTypeSubtypes.ATTACHMENT.SINGLE}
|
||||||
on:change={e => {
|
on:change={e => {
|
||||||
if (!e.detail) {
|
if (!e.detail) {
|
||||||
editableColumn.constraints ??= { length: {} }
|
editableColumn.subtype = FieldTypeSubtypes.ATTACHMENT.SINGLE
|
||||||
editableColumn.constraints.length ??= {}
|
|
||||||
editableColumn.constraints.length.maximum = 1
|
|
||||||
editableColumn.constraints.length.message =
|
|
||||||
"cannot contain multiple files"
|
|
||||||
} else {
|
} else {
|
||||||
delete editableColumn.constraints?.length?.maximum
|
delete editableColumn.subtype
|
||||||
delete editableColumn.constraints?.length?.message
|
|
||||||
}
|
}
|
||||||
}}
|
}}
|
||||||
thin
|
thin
|
||||||
|
|
|
@ -30,6 +30,7 @@ import {
|
||||||
View,
|
View,
|
||||||
RelationshipFieldMetadata,
|
RelationshipFieldMetadata,
|
||||||
FieldType,
|
FieldType,
|
||||||
|
FieldTypeSubtypes,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
|
||||||
export async function clearColumns(table: Table, columnNames: string[]) {
|
export async function clearColumns(table: Table, columnNames: string[]) {
|
||||||
|
@ -88,6 +89,24 @@ export async function checkForColumnUpdates(
|
||||||
// Update views
|
// Update views
|
||||||
await checkForViewUpdates(updatedTable, deletedColumns, columnRename)
|
await checkForViewUpdates(updatedTable, deletedColumns, columnRename)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
for (const attachmentColumn of Object.values(updatedTable.schema).filter(
|
||||||
|
column =>
|
||||||
|
column.type === FieldType.ATTACHMENT &&
|
||||||
|
column.subtype !== oldTable?.schema[column.name]?.subtype
|
||||||
|
)) {
|
||||||
|
if (attachmentColumn.subtype === FieldTypeSubtypes.ATTACHMENT.SINGLE) {
|
||||||
|
attachmentColumn.constraints ??= { length: {} }
|
||||||
|
attachmentColumn.constraints.length ??= {}
|
||||||
|
attachmentColumn.constraints.length.maximum = 1
|
||||||
|
attachmentColumn.constraints.length.message =
|
||||||
|
"cannot contain multiple files"
|
||||||
|
} else {
|
||||||
|
delete attachmentColumn.constraints?.length?.maximum
|
||||||
|
delete attachmentColumn.constraints?.length?.message
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return { rows: updatedRows, table: updatedTable }
|
return { rows: updatedRows, table: updatedTable }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -119,6 +119,7 @@ export interface FieldConstraints {
|
||||||
length?: {
|
length?: {
|
||||||
minimum?: string | number | null
|
minimum?: string | number | null
|
||||||
maximum?: string | number | null
|
maximum?: string | number | null
|
||||||
|
message?: string
|
||||||
}
|
}
|
||||||
numericality?: {
|
numericality?: {
|
||||||
greaterThanOrEqualTo: string | null
|
greaterThanOrEqualTo: string | null
|
||||||
|
|
Loading…
Reference in New Issue