Ensure field type is preserved if it contains a slash. Some additional refactoring
This commit is contained in:
parent
cbdf7c8bd1
commit
6809bd72ed
|
@ -24,16 +24,16 @@
|
||||||
|
|
||||||
const getOptions = (schema, type) => {
|
const getOptions = (schema, type) => {
|
||||||
let entries = Object.entries(schema ?? {})
|
let entries = Object.entries(schema ?? {})
|
||||||
|
|
||||||
let types = []
|
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
|
// allow options to be used on both options and string fields
|
||||||
types = [type, "field/string"]
|
types = [type, "field/string"]
|
||||||
} else {
|
} else {
|
||||||
types = [type]
|
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))
|
entries = entries.filter(entry => types.includes(entry[1].type))
|
||||||
return entries.map(entry => entry[0])
|
return entries.map(entry => entry[0])
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,13 +2,12 @@
|
||||||
import { ModalContent, Modal, Icon, ActionButton } from "@budibase/bbui"
|
import { ModalContent, Modal, Icon, ActionButton } from "@budibase/bbui"
|
||||||
import { Input, Button, StatusLight } from "@budibase/bbui"
|
import { Input, Button, StatusLight } from "@budibase/bbui"
|
||||||
import { Html5Qrcode } from "html5-qrcode"
|
import { Html5Qrcode } from "html5-qrcode"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
export let value
|
export let value
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let allowManualEntry = false
|
export let allowManualEntry = false
|
||||||
export let scanButtonText = "Scan code"
|
export let scanButtonText = "Scan code"
|
||||||
|
|
||||||
import { createEventDispatcher } from "svelte"
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
let videoEle
|
let videoEle
|
||||||
|
|
|
@ -41,7 +41,7 @@
|
||||||
on:change={handleUpdate}
|
on:change={handleUpdate}
|
||||||
disabled={fieldState.disabled}
|
disabled={fieldState.disabled}
|
||||||
{allowManualEntry}
|
{allowManualEntry}
|
||||||
{scanText}
|
scanButtonText={scanText}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
</Field>
|
</Field>
|
||||||
|
|
Loading…
Reference in New Issue