Set inputs to readonly when displaying the javascript function helper label to prevent accidentally setting explicit text

This commit is contained in:
Andrew Kingston 2021-11-23 16:41:09 +00:00
parent 24a700f391
commit 19d74d3fb6
3 changed files with 7 additions and 1 deletions

View File

@ -55,6 +55,7 @@
<Combobox <Combobox
{label} {label}
{disabled} {disabled}
readonly={isJS}
value={isJS ? "(JavaScript function)" : readableValue} value={isJS ? "(JavaScript function)" : readableValue}
on:type={e => onChange(e.detail, false)} on:type={e => onChange(e.detail, false)}
on:pick={e => onChange(e.detail, true)} on:pick={e => onChange(e.detail, true)}

View File

@ -40,6 +40,7 @@
<Input <Input
{label} {label}
{disabled} {disabled}
readonly={isJS}
value={isJS ? "(JavaScript function)" : readableValue} value={isJS ? "(JavaScript function)" : readableValue}
on:change={event => onChange(event.detail)} on:change={event => onChange(event.detail)}
{placeholder} {placeholder}

View File

@ -6,6 +6,7 @@
} from "builderStore/dataBinding" } from "builderStore/dataBinding"
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte" import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { isJSBinding } from "@budibase/string-templates"
export let panel = ServerBindingPanel export let panel = ServerBindingPanel
export let value = "" export let value = ""
@ -18,8 +19,10 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
let bindingModal let bindingModal
let valid = true let valid = true
$: readableValue = runtimeToReadableBinding(bindings, value) $: readableValue = runtimeToReadableBinding(bindings, value)
$: tempValue = readableValue $: tempValue = readableValue
$: isJS = isJSBinding(value)
const saveBinding = () => { const saveBinding = () => {
onChange(tempValue) onChange(tempValue)
@ -34,7 +37,8 @@
<div class="control"> <div class="control">
<Input <Input
{label} {label}
value={readableValue} readonly={isJS}
value={isJS ? "(JavaScript function)" : readableValue}
on:change={event => onChange(event.detail)} on:change={event => onChange(event.detail)}
{placeholder} {placeholder}
/> />