diff --git a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentListPanel.svelte b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentListPanel.svelte
index 5b86d4da29..1bb4e3d9cd 100644
--- a/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentListPanel.svelte
+++ b/packages/builder/src/pages/builder/app/[application]/design/[screenId]/components/[componentId]/_components/navigation/ComponentListPanel.svelte
@@ -9,6 +9,7 @@
import { setContext } from "svelte"
import DNDPositionIndicator from "./DNDPositionIndicator.svelte"
import { DropPosition } from "./dndStore"
+ import { notifications } from "@budibase/bbui"
let scrollRef
@@ -55,6 +56,15 @@
})
}
+ const onDrop = async () => {
+ try {
+ await dndStore.actions.drop()
+ } catch (error) {
+ console.error(error)
+ notifications.error("Error saving component")
+ }
+ }
+
// Set scroll context so components can invoke scrolling when selected
setContext("scroll", {
scrollTo,
@@ -83,6 +93,7 @@
opened
scrollable
icon="WebPage"
+ on:drop={onDrop}
>
diff --git a/packages/client/src/components/app/blocks/CardsBlock.svelte b/packages/client/src/components/app/blocks/CardsBlock.svelte
index f6aed54760..a13364833a 100644
--- a/packages/client/src/components/app/blocks/CardsBlock.svelte
+++ b/packages/client/src/components/app/blocks/CardsBlock.svelte
@@ -4,6 +4,7 @@
import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui"
import { makePropSafe as safe } from "@budibase/string-templates"
+ import { enrichSearchColumns, enrichFilter } from "utils/blocks.js"
export let title
export let dataSource
@@ -33,14 +34,6 @@
const { fetchDatasourceSchema, styleable } = getContext("sdk")
const context = getContext("context")
const component = getContext("component")
- const schemaComponentMap = {
- string: "stringfield",
- options: "optionsfield",
- number: "numberfield",
- datetime: "datetimefield",
- boolean: "booleanfield",
- formula: "stringfield",
- }
let formId
let dataProviderId
@@ -68,39 +61,6 @@
},
]
- // Enrich the default filter with the specified search fields
- const enrichFilter = (filter, columns, formId) => {
- let enrichedFilter = [...(filter || [])]
- columns?.forEach(column => {
- const safePath = column.name.split(".").map(safe).join(".")
- enrichedFilter.push({
- field: column.name,
- operator: column.type === "string" ? "string" : "equal",
- type: column.type,
- valueType: "Binding",
- value: `{{ ${safe(formId)}.${safePath} }}`,
- })
- })
- return enrichedFilter
- }
-
- // Determine data types for search fields and only use those that are valid
- const enrichSearchColumns = (searchColumns, schema) => {
- let enrichedColumns = []
- searchColumns?.forEach(column => {
- const schemaType = schema?.[column]?.type
- const componentType = schemaComponentMap[schemaType]
- if (componentType) {
- enrichedColumns.push({
- name: column,
- componentType,
- type: schemaType,
- })
- }
- })
- return enrichedColumns.slice(0, 5)
- }
-
// Builds a full details page URL for the card title
const buildFullCardUrl = (link, url, repeaterId, linkColumn) => {
if (!link || !url || !repeaterId) {
diff --git a/packages/client/src/components/app/blocks/TableBlock.svelte b/packages/client/src/components/app/blocks/TableBlock.svelte
index 4ae169ca72..e67124fc4f 100644
--- a/packages/client/src/components/app/blocks/TableBlock.svelte
+++ b/packages/client/src/components/app/blocks/TableBlock.svelte
@@ -4,6 +4,7 @@
import BlockComponent from "components/BlockComponent.svelte"
import { Heading } from "@budibase/bbui"
import { makePropSafe as safe } from "@budibase/string-templates"
+ import { enrichSearchColumns, enrichFilter } from "utils/blocks.js"
export let title
export let dataSource
@@ -31,14 +32,6 @@
const { fetchDatasourceSchema, styleable } = getContext("sdk")
const context = getContext("context")
const component = getContext("component")
- const schemaComponentMap = {
- string: "stringfield",
- options: "optionsfield",
- number: "numberfield",
- datetime: "datetimefield",
- boolean: "booleanfield",
- formula: "stringfield",
- }
let formId
let dataProviderId
@@ -58,40 +51,6 @@
},
]
- // Enrich the default filter with the specified search fields
- const enrichFilter = (filter, columns, formId) => {
- let enrichedFilter = [...(filter || [])]
- columns?.forEach(column => {
- const safePath = column.name.split(".").map(safe).join(".")
- const stringType = column.type === "string" || column.type === "formula"
- enrichedFilter.push({
- field: column.name,
- type: column.type,
- operator: stringType ? "string" : "equal",
- valueType: "Binding",
- value: `{{ ${safe(formId)}.${safePath} }}`,
- })
- })
- return enrichedFilter
- }
-
- // Determine data types for search fields and only use those that are valid
- const enrichSearchColumns = (searchColumns, schema) => {
- let enrichedColumns = []
- searchColumns?.forEach(column => {
- const schemaType = schema?.[column]?.type
- const componentType = schemaComponentMap[schemaType]
- if (componentType) {
- enrichedColumns.push({
- name: column,
- componentType,
- type: schemaType,
- })
- }
- })
- return enrichedColumns.slice(0, 5)
- }
-
// Load the datasource schema so we can determine column types
const fetchSchema = async dataSource => {
if (dataSource) {
@@ -109,7 +68,7 @@
{#if title || enrichedSearchColumns?.length || showTitleButton}