Merge pull request #8886 from Budibase/bug/sev3/query-bindings-drawer

Query bindings drawer fixes
This commit is contained in:
melohagan 2022-12-07 11:06:19 +00:00 committed by GitHub
commit bf01631cdc
6 changed files with 19 additions and 2 deletions

View File

@ -39,6 +39,7 @@
export let value = "" export let value = ""
export let valid export let valid
export let allowJS = false export let allowJS = false
export let allowHelpers = true
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
let getCaretPosition let getCaretPosition
@ -85,7 +86,7 @@
return helper.label.match(searchRgx) || helper.description.match(searchRgx) return helper.label.match(searchRgx) || helper.description.match(searchRgx)
}) })
$: categoryNames = [...categories.map(cat => cat[0]), "Helpers"] $: categoryNames = getCategoryNames(categories)
$: codeMirrorHints = bindings?.map(x => `$("${x.readableBinding}")`) $: codeMirrorHints = bindings?.map(x => `$("${x.readableBinding}")`)
@ -96,6 +97,14 @@
} }
} }
const getCategoryNames = categories => {
let names = [...categories.map(cat => cat[0])]
if (allowHelpers) {
names.push("Helpers")
}
return names
}
// Adds a JS/HBS helper to the expression // Adds a JS/HBS helper to the expression
const addHelper = (helper, js) => { const addHelper = (helper, js) => {
let tempVal let tempVal
@ -343,7 +352,7 @@
for more details. for more details.
</p> </p>
{/if} {/if}
{#if $admin.isDev} {#if $admin.isDev && allowJS}
<div class="convert"> <div class="convert">
<Button secondary on:click={convert}>Convert to JS</Button> <Button secondary on:click={convert}>Convert to JS</Button>
</div> </div>

View File

@ -5,6 +5,7 @@
export let valid export let valid
export let value = "" export let value = ""
export let allowJS = false export let allowJS = false
export let allowHelpers = true
$: enrichedBindings = enrichBindings(bindings) $: enrichedBindings = enrichBindings(bindings)
@ -25,5 +26,6 @@
bindings={enrichedBindings} bindings={enrichedBindings}
{value} {value}
{allowJS} {allowJS}
{allowHelpers}
on:change on:change
/> />

View File

@ -17,6 +17,7 @@
export let disabled = false export let disabled = false
export let fillWidth export let fillWidth
export let allowJS = true export let allowJS = true
export let allowHelpers = true
export let updateOnChange = true export let updateOnChange = true
export let drawerLeft export let drawerLeft
@ -77,6 +78,7 @@
on:change={event => (tempValue = event.detail)} on:change={event => (tempValue = event.detail)}
{bindings} {bindings}
{allowJS} {allowJS}
{allowHelpers}
/> />
</Drawer> </Drawer>

View File

@ -33,6 +33,7 @@
export let showMenu = false export let showMenu = false
export let bindings = [] export let bindings = []
export let bindingDrawerLeft export let bindingDrawerLeft
export let allowHelpers = true
let fields = Object.entries(object || {}).map(([name, value]) => ({ let fields = Object.entries(object || {}).map(([name, value]) => ({
name, name,
@ -122,6 +123,7 @@
disabled={readOnly} disabled={readOnly}
value={field.value} value={field.value}
allowJS={false} allowJS={false}
{allowHelpers}
fillWidth={true} fillWidth={true}
drawerLeft={bindingDrawerLeft} drawerLeft={bindingDrawerLeft}
/> />

View File

@ -223,6 +223,7 @@
.config { .config {
display: grid; display: grid;
grid-gap: var(--spacing-s); grid-gap: var(--spacing-s);
z-index: 1;
} }
.config-field { .config-field {

View File

@ -37,6 +37,7 @@
valuePlaceholder="Default" valuePlaceholder="Default"
bindings={[...userBindings]} bindings={[...userBindings]}
bindingDrawerLeft="260px" bindingDrawerLeft="260px"
allowHelpers={false}
on:change on:change
/> />
</div> </div>