From a81b44ccafc7f17b883a2112e6d0ae263cf9cb56 Mon Sep 17 00:00:00 2001 From: mike12345567 Date: Mon, 22 Feb 2021 11:40:24 +0000 Subject: [PATCH] Formatting. --- .../DataTable/modals/CreateEditColumn.svelte | 31 ++++++++++++------- .../common/LinkedRowSelector.svelte | 11 +++++-- .../components/integration/QueryViewer.svelte | 2 ++ .../src/forms/RelationshipField.svelte | 26 ++++++++-------- 4 files changed, 43 insertions(+), 27 deletions(-) diff --git a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte index 1e3f820d69..ae19489575 100644 --- a/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte +++ b/packages/builder/src/components/backend/DataTable/modals/CreateEditColumn.svelte @@ -7,7 +7,6 @@ Select, Toggle, Radio, - } from "@budibase/bbui" import { cloneDeep } from "lodash/fp" import { backendUiStore } from "builderStore" @@ -38,12 +37,14 @@ $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',} + { 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 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 selectedRelationshipType = + relationshipTypes.find(type => type.value === field.relationshipType) + ?.text || "Many to many (N:N)" let indexes = [...($backendUiStore.selectedTable.indexes || [])] let confirmDeleteDialog @@ -68,10 +69,12 @@ 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 - } + // 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( @@ -228,11 +231,15 @@ label="Max Value" bind:value={field.constraints.numericality.lessThanOrEqualTo} /> {:else if field.type === 'link'} -
+
{#each types as type} - + {/each} @@ -282,7 +289,7 @@ .radio-buttons { display: flex; gap: var(--spacing-m); - font-size: var(--font-size-xs) + font-size: var(--font-size-xs); } .actions { display: grid; diff --git a/packages/builder/src/components/common/LinkedRowSelector.svelte b/packages/builder/src/components/common/LinkedRowSelector.svelte index a0f5af052d..ac660d4a71 100644 --- a/packages/builder/src/components/common/LinkedRowSelector.svelte +++ b/packages/builder/src/components/common/LinkedRowSelector.svelte @@ -42,10 +42,17 @@ {:else} {#if schema.relationshipType === 'one-to-many'} - (linkedRows = [e.target.value])} + name={label} + {label}> {#each rows as row} - + {/each} {:else} diff --git a/packages/builder/src/components/integration/QueryViewer.svelte b/packages/builder/src/components/integration/QueryViewer.svelte index 0c3e687328..646f12f529 100644 --- a/packages/builder/src/components/integration/QueryViewer.svelte +++ b/packages/builder/src/components/integration/QueryViewer.svelte @@ -202,10 +202,12 @@ + Please run your query to fetch some data. + {:else} {JSON.stringify(data[0], undefined, 2)} {/if} diff --git a/packages/standard-components/src/forms/RelationshipField.svelte b/packages/standard-components/src/forms/RelationshipField.svelte index 5c4c7f4bc9..f4f5244fd1 100644 --- a/packages/standard-components/src/forms/RelationshipField.svelte +++ b/packages/standard-components/src/forms/RelationshipField.svelte @@ -18,25 +18,25 @@ let options = [] let tableDefinition let fieldText = "" - - const setFieldText = (value) => { - if (fieldSchema?.relationshipType === 'one-to-many') { + + const setFieldText = value => { + if (fieldSchema?.relationshipType === "one-to-many") { if (value?.length && options?.length) { const row = options.find(row => row._id === value[0]) return row.name } else { - return placeholder || 'Choose an option' - } + return placeholder || "Choose an option" + } } else { if (value?.length) { return `${value?.length ?? 0} selected rows` } else { - return placeholder || 'Choose some options' - } + return placeholder || "Choose some options" + } } } - $: options, fieldText = setFieldText($fieldState?.value) + $: options, (fieldText = setFieldText($fieldState?.value)) $: valueLookupMap = getValueLookupMap($fieldState?.value) $: isOptionSelected = option => valueLookupMap[option] === true $: linkedTableId = fieldSchema?.tableId @@ -74,14 +74,14 @@ } const toggleOption = option => { - if (fieldSchema.type === 'one-to-many') { + if (fieldSchema.type === "one-to-many") { fieldApi.setValue([option]) } else { if ($fieldState.value.includes(option)) { - fieldApi.setValue($fieldState.value.filter(x => x !== option)) - } else { - fieldApi.setValue([...$fieldState.value, option]) - } + fieldApi.setValue($fieldState.value.filter(x => x !== option)) + } else { + fieldApi.setValue([...$fieldState.value, option]) + } } }