From 299122324e4673eea0c0d23450b964b28e8e78a0 Mon Sep 17 00:00:00 2001 From: Dean Date: Mon, 10 Oct 2022 14:20:06 +0100 Subject: [PATCH] Ensure field type is preserved if it contains a slash. Some additional refactoring --- .../design/settings/controls/FormFieldSelect.svelte | 6 +++--- packages/client/src/components/app/forms/CodeScanner.svelte | 3 +-- .../client/src/components/app/forms/CodeScannerField.svelte | 2 +- 3 files changed, 5 insertions(+), 6 deletions(-) diff --git a/packages/builder/src/components/design/settings/controls/FormFieldSelect.svelte b/packages/builder/src/components/design/settings/controls/FormFieldSelect.svelte index c00079420a..a02ea41099 100644 --- a/packages/builder/src/components/design/settings/controls/FormFieldSelect.svelte +++ b/packages/builder/src/components/design/settings/controls/FormFieldSelect.svelte @@ -24,16 +24,16 @@ const getOptions = (schema, type) => { let entries = Object.entries(schema ?? {}) - let types = [] - if ((type === "field/options", type === "field/barcode/qr")) { + if (type === "field/options" || type === "field/barcode/qr") { // allow options to be used on both options and string fields types = [type, "field/string"] } else { types = [type] } - types = types.map(type => type.split("/")[1]) + types = types.map(type => type.slice(type.indexOf("/") + 1)) + entries = entries.filter(entry => types.includes(entry[1].type)) return entries.map(entry => entry[0]) } diff --git a/packages/client/src/components/app/forms/CodeScanner.svelte b/packages/client/src/components/app/forms/CodeScanner.svelte index 8728e707dd..5dff3a96fa 100644 --- a/packages/client/src/components/app/forms/CodeScanner.svelte +++ b/packages/client/src/components/app/forms/CodeScanner.svelte @@ -2,13 +2,12 @@ import { ModalContent, Modal, Icon, ActionButton } from "@budibase/bbui" import { Input, Button, StatusLight } from "@budibase/bbui" import { Html5Qrcode } from "html5-qrcode" + import { createEventDispatcher } from "svelte" export let value export let disabled = false export let allowManualEntry = false export let scanButtonText = "Scan code" - - import { createEventDispatcher } from "svelte" const dispatch = createEventDispatcher() let videoEle diff --git a/packages/client/src/components/app/forms/CodeScannerField.svelte b/packages/client/src/components/app/forms/CodeScannerField.svelte index 4f4a84bfbc..7e020aa9c7 100644 --- a/packages/client/src/components/app/forms/CodeScannerField.svelte +++ b/packages/client/src/components/app/forms/CodeScannerField.svelte @@ -41,7 +41,7 @@ on:change={handleUpdate} disabled={fieldState.disabled} {allowManualEntry} - {scanText} + scanButtonText={scanText} /> {/if}