diff --git a/lerna.json b/lerna.json index f2b3975169..c1939719a8 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { - "version": "0.9.190-alpha.11", + "version": "0.9.190-alpha.12", "npmClient": "yarn", "packages": [ "packages/*" diff --git a/packages/auth/package.json b/packages/auth/package.json index 6987c8c88b..2aec96c6f8 100644 --- a/packages/auth/package.json +++ b/packages/auth/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/auth", - "version": "0.9.190-alpha.11", + "version": "0.9.190-alpha.12", "description": "Authentication middlewares for budibase builder and apps", "main": "src/index.js", "author": "Budibase", diff --git a/packages/bbui/package.json b/packages/bbui/package.json index 814a4971bf..b50a3ded2c 100644 --- a/packages/bbui/package.json +++ b/packages/bbui/package.json @@ -1,7 +1,7 @@ { "name": "@budibase/bbui", "description": "A UI solution used in the different Budibase projects.", - "version": "0.9.190-alpha.11", + "version": "0.9.190-alpha.12", "license": "MPL-2.0", "svelte": "src/index.js", "module": "dist/bbui.es.js", diff --git a/packages/builder/package.json b/packages/builder/package.json index 1f7996d1b2..7774dfbffc 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -1,6 +1,6 @@ { "name": "@budibase/builder", - "version": "0.9.190-alpha.11", + "version": "0.9.190-alpha.12", "license": "GPL-3.0", "private": true, "scripts": { @@ -65,10 +65,10 @@ } }, "dependencies": { - "@budibase/bbui": "^0.9.190-alpha.11", - "@budibase/client": "^0.9.190-alpha.11", + "@budibase/bbui": "^0.9.190-alpha.12", + "@budibase/client": "^0.9.190-alpha.12", "@budibase/colorpicker": "1.1.2", - "@budibase/string-templates": "^0.9.190-alpha.11", + "@budibase/string-templates": "^0.9.190-alpha.12", "@sentry/browser": "5.19.1", "@spectrum-css/page": "^3.0.1", "@spectrum-css/vars": "^3.0.1", diff --git a/packages/builder/src/builderStore/schemaGenerator.js b/packages/builder/src/builderStore/schemaGenerator.js new file mode 100644 index 0000000000..33115fc997 --- /dev/null +++ b/packages/builder/src/builderStore/schemaGenerator.js @@ -0,0 +1,56 @@ +import { FIELDS } from "constants/backend" + +function baseConversion(type) { + if (type === "string") { + return { + type: FIELDS.STRING.type, + } + } else if (type === "boolean") { + return { + type: FIELDS.BOOLEAN.type, + } + } else if (type === "number") { + return { + type: FIELDS.NUMBER.type, + } + } +} + +function recurse(schemaLevel = {}, objectLevel) { + if (!objectLevel) { + return null + } + const baseType = typeof objectLevel + if (baseType !== "object") { + return baseConversion(baseType) + } + for (let [key, value] of Object.entries(objectLevel)) { + const type = typeof value + // check array first, since arrays are objects + if (Array.isArray(value)) { + const schema = recurse(schemaLevel[key], value[0]) + if (schema) { + schemaLevel[key] = { + type: FIELDS.ARRAY.type, + schema, + } + } + } else if (type === "object") { + const schema = recurse(schemaLevel[key], objectLevel[key]) + if (schema) { + schemaLevel[key] = schema + } + } else { + schemaLevel[key] = baseConversion(type) + } + } + if (!schemaLevel.type) { + return { type: FIELDS.JSON.type, schema: schemaLevel } + } else { + return schemaLevel + } +} + +export function generate(object) { + return recurse({}, object).schema +} diff --git a/packages/builder/src/builderStore/store/frontend.js b/packages/builder/src/builderStore/store/frontend.js index 1f1fb035a4..c94c759792 100644 --- a/packages/builder/src/builderStore/store/frontend.js +++ b/packages/builder/src/builderStore/store/frontend.js @@ -524,7 +524,7 @@ export const getFrontendStore = () => { } } }, - paste: async (targetComponent, mode) => { + paste: async (targetComponent, mode, preserveBindings = false) => { let promises = [] store.update(state => { // Stop if we have nothing to paste @@ -536,7 +536,7 @@ export const getFrontendStore = () => { const cut = state.componentToPaste.isCut // immediately need to remove bindings, currently these aren't valid when pasted - if (!cut) { + if (!cut && !preserveBindings) { state.componentToPaste = removeBindings(state.componentToPaste) } diff --git a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte index 25ad67b52e..0d9ca3644b 100644 --- a/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte +++ b/packages/builder/src/components/backend/DataTable/RowFieldControl.svelte @@ -6,16 +6,20 @@ Toggle, TextArea, Multiselect, + Label, } from "@budibase/bbui" import Dropzone from "components/common/Dropzone.svelte" import { capitalise } from "helpers" import LinkedRowSelector from "components/common/LinkedRowSelector.svelte" + import Editor from "../../integration/QueryEditor.svelte" export let defaultValue export let meta export let value = defaultValue || (meta.type === "boolean" ? false : "") export let readonly + $: stringVal = + typeof value === "object" ? JSON.stringify(value, null, 2) : value $: type = meta?.type $: label = meta.name ? capitalise(meta.name) : "" @@ -40,6 +44,14 @@ {:else if type === "longform"}