diff --git a/packages/builder/package.json b/packages/builder/package.json index 94ef8dc3c4..bf4c4b4a89 100644 --- a/packages/builder/package.json +++ b/packages/builder/package.json @@ -63,7 +63,7 @@ } }, "dependencies": { - "@budibase/bbui": "^1.58.8", + "@budibase/bbui": "^1.58.12", "@budibase/client": "^0.7.8", "@budibase/colorpicker": "1.0.1", "@budibase/string-templates": "^0.7.8", diff --git a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js index ee7a4da0fd..1634556c8d 100644 --- a/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js +++ b/packages/builder/src/builderStore/store/screenTemplates/utils/commonComponents.js @@ -198,6 +198,13 @@ export function makeDatasourceFormComponents(datasource) { if (fieldType === "options") { component.customProps({ placeholder: "Choose an option " }) } + if (fieldType === "link") { + let placeholder = + fieldSchema.relationshipType === "one-to-many" + ? "Choose an option" + : "Choose some options" + component.customProps({ placeholder }) + } if (fieldType === "boolean") { component.customProps({ text: field, label: "" }) } diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index f041d02113..1e3f820d69 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -6,6 +6,8 @@ TextButton, Select, Toggle, + Radio, + } from "@budibase/bbui" import { cloneDeep } from "lodash/fp" import { backendUiStore } from "builderStore" @@ -34,6 +36,15 @@ let primaryDisplay = $backendUiStore.selectedTable.primaryDisplay == null || $backendUiStore.selectedTable.primaryDisplay === field.name + + let relationshipTypes = [ + {text: 'Many to many (N:N)', value: 'many-to-many',}, + {text: 'One to many (1:N)', value: 'one-to-many',} + ] + let types = ['Many to many (N:N)', 'One to many (1:N)'] + + let selectedRelationshipType = relationshipTypes.find(type => type.value === field.relationshipType)?.text || 'Many to many (N:N)' + let indexes = [...($backendUiStore.selectedTable.indexes || [])] let confirmDeleteDialog let deletion @@ -57,6 +68,11 @@ field.type !== LINK_TYPE && !uneditable && field.type !== AUTO_COL async function saveColumn() { + // Set relationship type if it's + if (field.type === 'link') { + field.relationshipType = relationshipTypes.find(type => type.text === selectedRelationshipType).value + } + if (field.type === AUTO_COL) { field = buildAutoColumn( $backendUiStore.draftTable.name, @@ -212,6 +228,16 @@ label="Max Value" bind:value={field.constraints.numericality.lessThanOrEqualTo} /> {:else if field.type === 'link'} +