diff --git a/package.json b/package.json index a17cea9846..5a7d40fe1c 100644 --- a/package.json +++ b/package.json @@ -11,6 +11,7 @@ "lerna": "3.14.1", "prettier": "^1.19.1", "prettier-plugin-svelte": "^0.7.0", + "rimraf": "^3.0.2", "rollup-plugin-replace": "^2.2.0", "svelte": "^3.28.0" }, @@ -20,6 +21,8 @@ "initialise": "lerna run initialise", "publishdev": "lerna run publishdev", "publishnpm": "yarn build && lerna publish --force-publish", + "restore": "npm run clean && npm run bootstrap && npm run build", + "nuke": "rimraf ~/.budibase && npm run restore", "clean": "lerna clean", "dev": "node ./scripts/symlinkDev.js && lerna run --parallel dev:builder", "test": "lerna run test", diff --git a/packages/builder/src/builderStore/fetchBindableProperties.js b/packages/builder/src/builderStore/fetchBindableProperties.js index 90e2de2041..36c40ee754 100644 --- a/packages/builder/src/builderStore/fetchBindableProperties.js +++ b/packages/builder/src/builderStore/fetchBindableProperties.js @@ -73,36 +73,42 @@ const componentInstanceToBindable = walkResult => i => { const contextToBindables = (tables, walkResult) => context => { const contextParentPath = getParentPath(walkResult, context) - const isTable = context.table?.isTable || typeof context.table === "string" - const tableId = - typeof context.table === "string" ? context.table : context.table.tableId + const tableId = context.table?.tableId ?? context.table const table = tables.find(table => table._id === tableId) + let schema = + context.table?.type === "view" + ? table?.views?.[context.table.name]?.schema + : table?.schema // Avoid crashing whenever no data source has been selected - if (table == null) { + if (!schema) { return [] } - const newBindable = key => ({ - type: "context", - instance: context.instance, - // how the binding expression persists, and is used in the app at runtime - runtimeBinding: `${contextParentPath}data.${key}`, - // how the binding exressions looks to the user of the builder - readableBinding: `${context.instance._instanceName}.${table.name}.${key}`, - // table / view info - table: context.table, - }) - - // see TableViewSelect.svelte for the format of context.table - // ... this allows us to bind to Table schemas, or View schemas - const schema = isTable ? table.schema : table.views[context.table.name].schema + const newBindable = ([key, fieldSchema]) => { + // Replace link bindings with a new property representing the count + let runtimeBoundKey = key + if (fieldSchema.type === "link") { + runtimeBoundKey = `${key}_count` + } + return { + type: "context", + fieldSchema, + instance: context.instance, + // how the binding expression persists, and is used in the app at runtime + runtimeBinding: `${contextParentPath}data.${runtimeBoundKey}`, + // how the binding expressions looks to the user of the builder + readableBinding: `${context.instance._instanceName}.${table.name}.${key}`, + // table / view info + table: context.table, + } + } return ( - Object.keys(schema) + Object.entries(schema) .map(newBindable) // add _id and _rev fields - not part of schema, but always valid - .concat([newBindable("_id"), newBindable("_rev")]) + .concat([newBindable(["_id", "string"]), newBindable(["_rev", "string"])]) ) } diff --git a/packages/builder/src/builderStore/index.js b/packages/builder/src/builderStore/index.js index c040403592..101f875e96 100644 --- a/packages/builder/src/builderStore/index.js +++ b/packages/builder/src/builderStore/index.js @@ -9,7 +9,7 @@ export const automationStore = getAutomationStore() export const initialise = async () => { try { - analytics.activate() + await analytics.activate() analytics.captureEvent("Builder Started") } catch (err) { console.log(err) diff --git a/packages/builder/src/builderStore/store/index.js b/packages/builder/src/builderStore/store/index.js index 6941c74b22..4eeb2e3842 100644 --- a/packages/builder/src/builderStore/store/index.js +++ b/packages/builder/src/builderStore/store/index.js @@ -292,6 +292,11 @@ const addChildComponent = store => (componentToAdd, presetProps = {}) => { ? state.currentComponentInfo : getParent(state.currentPreviewItem.props, state.currentComponentInfo) + // Don't continue if there's no parent + if (!targetParent) { + return state + } + targetParent._children = targetParent._children.concat(newComponent.props) state.currentFrontEndType === "page" diff --git a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js index 20f8f9c13f..bd3dcef252 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js +++ b/packages/builder/src/builderStore/store/screenTemplates/rowListScreen.js @@ -86,7 +86,7 @@ const createScreen = table => ({ }, { _id: "", - _component: "@budibase/standard-components/datatable", + _component: "@budibase/standard-components/datagrid", _styles: { normal: {}, hover: {}, @@ -100,10 +100,6 @@ const createScreen = table => ({ tableId: table._id, isTable: true, }, - stripeColor: "", - borderColor: "", - backgroundColor: "", - color: "", _instanceName: `${table.name} Table`, _children: [], }, diff --git a/packages/builder/src/components/backend/DataTable/TablePagination.svelte b/packages/builder/src/components/backend/DataTable/TablePagination.svelte index 1435148ebc..840b3381e5 100644 --- a/packages/builder/src/components/backend/DataTable/TablePagination.svelte +++ b/packages/builder/src/components/backend/DataTable/TablePagination.svelte @@ -1,11 +1,13 @@