1
0
Fork 0
mirror of synced 2024-09-11 06:56:23 +12:00

Remove helpers and convert to JS query bindings

This commit is contained in:
Mel O'Hagan 2022-12-01 10:29:06 +00:00
parent c01d8f3cfe
commit 002c1e7201
5 changed files with 19 additions and 2 deletions

View file

@ -39,6 +39,7 @@
export let value = ""
export let valid
export let allowJS = false
export let allowHelpers = true
let helpers = handlebarsCompletions()
let getCaretPosition
@ -54,6 +55,7 @@
let popoverAnchor
let hoverTarget
$: console.log("HELPERS ", allowHelpers)
$: usingJS = mode === "JavaScript"
$: searchRgx = new RegExp(search, "ig")
$: categories = Object.entries(groupBy("category", bindings))
@ -85,7 +87,7 @@
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}")`)
@ -96,6 +98,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
const addHelper = (helper, js) => {
let tempVal
@ -343,7 +353,7 @@
for more details.
</p>
{/if}
{#if $admin.isDev}
{#if $admin.isDev && allowJS}
<div class="convert">
<Button secondary on:click={convert}>Convert to JS</Button>
</div>

View file

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

View file

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

View file

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

View file

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