Merge branch 'master' into revert-13398-revert-13356-BUDI-8122/single-attachment-column-type
This commit is contained in:
commit
b4063fae01
|
@ -34,7 +34,7 @@
|
||||||
$selectedScreen,
|
$selectedScreen,
|
||||||
datasource
|
datasource
|
||||||
)?.table?.primaryDisplay
|
)?.table?.primaryDisplay
|
||||||
$: schema = getSchema(selectedScreen, datasource)
|
$: schema = getSchema($selectedScreen, datasource)
|
||||||
$: columns = getColumns({
|
$: columns = getColumns({
|
||||||
columns: value,
|
columns: value,
|
||||||
schema,
|
schema,
|
||||||
|
|
|
@ -5,6 +5,9 @@ import {
|
||||||
AutoFieldSubType,
|
AutoFieldSubType,
|
||||||
Hosting,
|
Hosting,
|
||||||
} from "@budibase/types"
|
} from "@budibase/types"
|
||||||
|
import { Constants } from "@budibase/frontend-core"
|
||||||
|
|
||||||
|
const { TypeIconMap } = Constants
|
||||||
|
|
||||||
export { RelationshipType } from "@budibase/types"
|
export { RelationshipType } from "@budibase/types"
|
||||||
|
|
||||||
|
@ -22,7 +25,7 @@ export const FIELDS = {
|
||||||
STRING: {
|
STRING: {
|
||||||
name: "Text",
|
name: "Text",
|
||||||
type: FieldType.STRING,
|
type: FieldType.STRING,
|
||||||
icon: "Text",
|
icon: TypeIconMap[FieldType.STRING],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
|
@ -32,7 +35,7 @@ export const FIELDS = {
|
||||||
BARCODEQR: {
|
BARCODEQR: {
|
||||||
name: "Barcode/QR",
|
name: "Barcode/QR",
|
||||||
type: FieldType.BARCODEQR,
|
type: FieldType.BARCODEQR,
|
||||||
icon: "Camera",
|
icon: TypeIconMap[FieldType.BARCODEQR],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
|
@ -42,7 +45,7 @@ export const FIELDS = {
|
||||||
LONGFORM: {
|
LONGFORM: {
|
||||||
name: "Long Form Text",
|
name: "Long Form Text",
|
||||||
type: FieldType.LONGFORM,
|
type: FieldType.LONGFORM,
|
||||||
icon: "TextAlignLeft",
|
icon: TypeIconMap[FieldType.LONGFORM],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
|
@ -52,7 +55,7 @@ export const FIELDS = {
|
||||||
OPTIONS: {
|
OPTIONS: {
|
||||||
name: "Options",
|
name: "Options",
|
||||||
type: FieldType.OPTIONS,
|
type: FieldType.OPTIONS,
|
||||||
icon: "Dropdown",
|
icon: TypeIconMap[FieldType.OPTIONS],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -62,7 +65,7 @@ export const FIELDS = {
|
||||||
ARRAY: {
|
ARRAY: {
|
||||||
name: "Multi-select",
|
name: "Multi-select",
|
||||||
type: FieldType.ARRAY,
|
type: FieldType.ARRAY,
|
||||||
icon: "Duplicate",
|
icon: TypeIconMap[FieldType.ARRAY],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -72,7 +75,7 @@ export const FIELDS = {
|
||||||
NUMBER: {
|
NUMBER: {
|
||||||
name: "Number",
|
name: "Number",
|
||||||
type: FieldType.NUMBER,
|
type: FieldType.NUMBER,
|
||||||
icon: "123",
|
icon: TypeIconMap[FieldType.NUMBER],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "number",
|
type: "number",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -82,12 +85,12 @@ export const FIELDS = {
|
||||||
BIGINT: {
|
BIGINT: {
|
||||||
name: "BigInt",
|
name: "BigInt",
|
||||||
type: FieldType.BIGINT,
|
type: FieldType.BIGINT,
|
||||||
icon: "TagBold",
|
icon: TypeIconMap[FieldType.BIGINT],
|
||||||
},
|
},
|
||||||
BOOLEAN: {
|
BOOLEAN: {
|
||||||
name: "Boolean",
|
name: "Boolean",
|
||||||
type: FieldType.BOOLEAN,
|
type: FieldType.BOOLEAN,
|
||||||
icon: "Boolean",
|
icon: TypeIconMap[FieldType.BOOLEAN],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "boolean",
|
type: "boolean",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -96,7 +99,7 @@ export const FIELDS = {
|
||||||
DATETIME: {
|
DATETIME: {
|
||||||
name: "Date/Time",
|
name: "Date/Time",
|
||||||
type: FieldType.DATETIME,
|
type: FieldType.DATETIME,
|
||||||
icon: "Calendar",
|
icon: TypeIconMap[FieldType.DATETIME],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "string",
|
type: "string",
|
||||||
length: {},
|
length: {},
|
||||||
|
@ -110,7 +113,7 @@ export const FIELDS = {
|
||||||
ATTACHMENT_SINGLE: {
|
ATTACHMENT_SINGLE: {
|
||||||
name: "Attachment",
|
name: "Attachment",
|
||||||
type: FieldType.ATTACHMENT_SINGLE,
|
type: FieldType.ATTACHMENT_SINGLE,
|
||||||
icon: "Document",
|
icon: TypeIconMap[FieldType.ATTACHMENT_SINGLE],
|
||||||
constraints: {
|
constraints: {
|
||||||
presence: false,
|
presence: false,
|
||||||
},
|
},
|
||||||
|
@ -118,7 +121,7 @@ export const FIELDS = {
|
||||||
ATTACHMENTS: {
|
ATTACHMENTS: {
|
||||||
name: "Attachment List",
|
name: "Attachment List",
|
||||||
type: FieldType.ATTACHMENTS,
|
type: FieldType.ATTACHMENTS,
|
||||||
icon: "AppleFiles",
|
icon: TypeIconMap[FieldType.ATTACHMENTS],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -127,7 +130,7 @@ export const FIELDS = {
|
||||||
LINK: {
|
LINK: {
|
||||||
name: "Relationship",
|
name: "Relationship",
|
||||||
type: FieldType.LINK,
|
type: FieldType.LINK,
|
||||||
icon: "Link",
|
icon: TypeIconMap[FieldType.LINK],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -136,19 +139,19 @@ export const FIELDS = {
|
||||||
AUTO: {
|
AUTO: {
|
||||||
name: "Auto Column",
|
name: "Auto Column",
|
||||||
type: FieldType.AUTO,
|
type: FieldType.AUTO,
|
||||||
icon: "MagicWand",
|
icon: TypeIconMap[FieldType.AUTO],
|
||||||
constraints: {},
|
constraints: {},
|
||||||
},
|
},
|
||||||
FORMULA: {
|
FORMULA: {
|
||||||
name: "Formula",
|
name: "Formula",
|
||||||
type: FieldType.FORMULA,
|
type: FieldType.FORMULA,
|
||||||
icon: "Calculator",
|
icon: TypeIconMap[FieldType.FORMULA],
|
||||||
constraints: {},
|
constraints: {},
|
||||||
},
|
},
|
||||||
JSON: {
|
JSON: {
|
||||||
name: "JSON",
|
name: "JSON",
|
||||||
type: FieldType.JSON,
|
type: FieldType.JSON,
|
||||||
icon: "Brackets",
|
icon: TypeIconMap[FieldType.JSON],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "object",
|
type: "object",
|
||||||
presence: false,
|
presence: false,
|
||||||
|
@ -158,13 +161,13 @@ export const FIELDS = {
|
||||||
name: "User",
|
name: "User",
|
||||||
type: FieldType.BB_REFERENCE,
|
type: FieldType.BB_REFERENCE,
|
||||||
subtype: FieldSubtype.USER,
|
subtype: FieldSubtype.USER,
|
||||||
icon: "User",
|
icon: TypeIconMap[FieldType.USER],
|
||||||
},
|
},
|
||||||
USERS: {
|
USERS: {
|
||||||
name: "Users",
|
name: "Users",
|
||||||
type: FieldType.BB_REFERENCE,
|
type: FieldType.BB_REFERENCE,
|
||||||
subtype: FieldSubtype.USERS,
|
subtype: FieldSubtype.USERS,
|
||||||
icon: "User",
|
icon: TypeIconMap[FieldType.USERS],
|
||||||
constraints: {
|
constraints: {
|
||||||
type: "array",
|
type: "array",
|
||||||
},
|
},
|
||||||
|
|
|
@ -6,7 +6,10 @@ import { derived } from "svelte/store"
|
||||||
import { integrations } from "stores/builder/integrations"
|
import { integrations } from "stores/builder/integrations"
|
||||||
|
|
||||||
vi.mock("svelte/store", () => ({
|
vi.mock("svelte/store", () => ({
|
||||||
derived: vi.fn(() => {}),
|
derived: vi.fn(),
|
||||||
|
writable: vi.fn(() => ({
|
||||||
|
subscribe: vi.fn(),
|
||||||
|
})),
|
||||||
}))
|
}))
|
||||||
|
|
||||||
vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() }))
|
vi.mock("stores/builder/integrations", () => ({ integrations: vi.fn() }))
|
||||||
|
|
|
@ -6102,7 +6102,7 @@
|
||||||
"block": true,
|
"block": true,
|
||||||
"name": "Repeater Block",
|
"name": "Repeater Block",
|
||||||
"icon": "ViewList",
|
"icon": "ViewList",
|
||||||
"illegalChildren": ["section"],
|
"illegalChildren": ["section", "rowexplorer"],
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
"size": {
|
"size": {
|
||||||
"width": 400,
|
"width": 400,
|
||||||
|
|
|
@ -147,7 +147,8 @@
|
||||||
border: 1px solid var(--spectrum-global-color-gray-300);
|
border: 1px solid var(--spectrum-global-color-gray-300);
|
||||||
border-radius: 4px;
|
border-radius: 4px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
min-height: 410px;
|
min-height: 230px;
|
||||||
|
height: 410px;
|
||||||
}
|
}
|
||||||
div.in-builder :global(*) {
|
div.in-builder :global(*) {
|
||||||
pointer-events: none;
|
pointer-events: none;
|
||||||
|
|
|
@ -1,4 +1,4 @@
|
||||||
import { FieldType, FieldTypeSubtypes } from "@budibase/types"
|
import { TypeIconMap } from "../../../constants"
|
||||||
|
|
||||||
export const getColor = (idx, opacity = 0.3) => {
|
export const getColor = (idx, opacity = 0.3) => {
|
||||||
if (idx == null || idx === -1) {
|
if (idx == null || idx === -1) {
|
||||||
|
@ -7,27 +7,6 @@ export const getColor = (idx, opacity = 0.3) => {
|
||||||
return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})`
|
return `hsla(${((idx + 1) * 222) % 360}, 90%, 75%, ${opacity})`
|
||||||
}
|
}
|
||||||
|
|
||||||
const TypeIconMap = {
|
|
||||||
[FieldType.STRING]: "Text",
|
|
||||||
[FieldType.OPTIONS]: "Dropdown",
|
|
||||||
[FieldType.DATETIME]: "Date",
|
|
||||||
[FieldType.BARCODEQR]: "Camera",
|
|
||||||
[FieldType.LONGFORM]: "TextAlignLeft",
|
|
||||||
[FieldType.ARRAY]: "Dropdown",
|
|
||||||
[FieldType.NUMBER]: "123",
|
|
||||||
[FieldType.BOOLEAN]: "Boolean",
|
|
||||||
[FieldType.ATTACHMENTS]: "AppleFiles",
|
|
||||||
[FieldType.ATTACHMENT_SINGLE]: "Document",
|
|
||||||
[FieldType.LINK]: "DataCorrelated",
|
|
||||||
[FieldType.FORMULA]: "Calculator",
|
|
||||||
[FieldType.JSON]: "Brackets",
|
|
||||||
[FieldType.BIGINT]: "TagBold",
|
|
||||||
[FieldType.BB_REFERENCE]: {
|
|
||||||
[FieldTypeSubtypes.BB_REFERENCE.USER]: "User",
|
|
||||||
[FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup",
|
|
||||||
},
|
|
||||||
}
|
|
||||||
|
|
||||||
export const getColumnIcon = column => {
|
export const getColumnIcon = column => {
|
||||||
if (column.schema.autocolumn) {
|
if (column.schema.autocolumn) {
|
||||||
return "MagicWand"
|
return "MagicWand"
|
||||||
|
|
|
@ -4,6 +4,7 @@
|
||||||
export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core"
|
export { OperatorOptions, SqlNumberTypeRangeMap } from "@budibase/shared-core"
|
||||||
export { Feature as Features } from "@budibase/types"
|
export { Feature as Features } from "@budibase/types"
|
||||||
import { BpmCorrelationKey } from "@budibase/shared-core"
|
import { BpmCorrelationKey } from "@budibase/shared-core"
|
||||||
|
import { FieldType, FieldTypeSubtypes } from "@budibase/types"
|
||||||
|
|
||||||
// Cookie names
|
// Cookie names
|
||||||
export const Cookies = {
|
export const Cookies = {
|
||||||
|
@ -113,3 +114,27 @@ export const ContextScopes = {
|
||||||
Local: "local",
|
Local: "local",
|
||||||
Global: "global",
|
Global: "global",
|
||||||
}
|
}
|
||||||
|
|
||||||
|
export const TypeIconMap = {
|
||||||
|
[FieldType.STRING]: "Text",
|
||||||
|
[FieldType.OPTIONS]: "Dropdown",
|
||||||
|
[FieldType.DATETIME]: "Calendar",
|
||||||
|
[FieldType.BARCODEQR]: "Camera",
|
||||||
|
[FieldType.LONGFORM]: "TextAlignLeft",
|
||||||
|
[FieldType.ARRAY]: "Duplicate",
|
||||||
|
[FieldType.NUMBER]: "123",
|
||||||
|
[FieldType.BOOLEAN]: "Boolean",
|
||||||
|
[FieldType.ATTACHMENTS]: "AppleFiles",
|
||||||
|
[FieldType.ATTACHMENT_SINGLE]: "Document",
|
||||||
|
[FieldType.LINK]: "DataCorrelated",
|
||||||
|
[FieldType.FORMULA]: "Calculator",
|
||||||
|
[FieldType.JSON]: "Brackets",
|
||||||
|
[FieldType.BIGINT]: "TagBold",
|
||||||
|
[FieldType.AUTO]: "MagicWand",
|
||||||
|
[FieldType.USER]: "User",
|
||||||
|
[FieldType.USERS]: "UserGroup",
|
||||||
|
[FieldType.BB_REFERENCE]: {
|
||||||
|
[FieldTypeSubtypes.BB_REFERENCE.USER]: "User",
|
||||||
|
[FieldTypeSubtypes.BB_REFERENCE.USERS]: "UserGroup",
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
|
@ -2,7 +2,7 @@ import { tableForDatasource } from "../../../tests/utilities/structures"
|
||||||
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
import { DatabaseName, getDatasource } from "../../../integrations/tests/utils"
|
||||||
|
|
||||||
import * as setup from "./utilities"
|
import * as setup from "./utilities"
|
||||||
import { Datasource, FieldType, Table } from "@budibase/types"
|
import { Datasource, FieldType, SearchFilters, Table } from "@budibase/types"
|
||||||
|
|
||||||
jest.unmock("mssql")
|
jest.unmock("mssql")
|
||||||
|
|
||||||
|
@ -53,22 +53,38 @@ describe.each([
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it("should return rows", async () => {
|
describe("strings", () => {
|
||||||
const rows = await Promise.all([
|
const rows = [{ name: "foo" }, { name: "bar" }]
|
||||||
config.api.row.save(table._id!, { name: "foo" }),
|
|
||||||
config.api.row.save(table._id!, { name: "bar" }),
|
|
||||||
])
|
|
||||||
|
|
||||||
const result = await config.api.row.search(table._id!, {
|
interface StringSearchTest {
|
||||||
|
query: SearchFilters
|
||||||
|
expected: (typeof rows)[number][]
|
||||||
|
}
|
||||||
|
|
||||||
|
const stringSearchTests: StringSearchTest[] = [
|
||||||
|
{ query: {}, expected: rows },
|
||||||
|
{ query: { string: { name: "foo" } }, expected: [rows[0]] },
|
||||||
|
{ query: { fuzzy: { name: "oo" } }, expected: [rows[0]] },
|
||||||
|
{ query: { equal: { name: "foo" } }, expected: [rows[0]] },
|
||||||
|
{ query: { notEqual: { name: "foo" } }, expected: [rows[1]] },
|
||||||
|
{ query: { oneOf: { name: ["foo"] } }, expected: [rows[0]] },
|
||||||
|
// { query: { contains: { name: "f" } }, expected: [0] },
|
||||||
|
// { query: { notContains: { name: ["f"] } }, expected: [1] },
|
||||||
|
// { query: { containsAny: { name: ["f"] } }, expected: [0] },
|
||||||
|
]
|
||||||
|
|
||||||
|
it.each(stringSearchTests)(
|
||||||
|
`should be able to run query: $query`,
|
||||||
|
async ({ query, expected }) => {
|
||||||
|
await Promise.all(rows.map(r => config.api.row.save(table._id!, r)))
|
||||||
|
const { rows: foundRows } = await config.api.row.search(table._id!, {
|
||||||
tableId: table._id!,
|
tableId: table._id!,
|
||||||
query: {},
|
query,
|
||||||
})
|
})
|
||||||
|
expect(foundRows).toEqual(
|
||||||
expect(result.rows).toEqual(
|
expect.arrayContaining(expected.map(r => expect.objectContaining(r)))
|
||||||
expect.arrayContaining([
|
)
|
||||||
expect.objectContaining({ _id: rows[0]._id }),
|
}
|
||||||
expect.objectContaining({ _id: rows[1]._id }),
|
|
||||||
])
|
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue