bindings now show up correctly in the drawer

This commit is contained in:
Keviin Åberg Kultalahti 2021-02-26 14:53:51 +01:00
parent f0ffd5f695
commit 2f764bad9b
4 changed files with 25 additions and 16 deletions

View File

@ -12,9 +12,12 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
export let bindableProperties
export let value = "" export let value = ""
export let bindingDrawer export let bindingDrawer
export let valid = true
export let bindings = [] export let bindings = []
$: console.log('Bindings in Drawer: ', bindings)
let originalValue = value let originalValue = value
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
@ -24,7 +27,10 @@
$: categories = Object.entries(groupBy("category", bindings)) $: categories = Object.entries(groupBy("category", bindings))
$: value && checkValid() $: value && checkValid()
$: bindableProperties = getBindableProperties(
$currentAsset,
$store.selectedComponentId
)
$: console.log(value) $: console.log(value)
$: dispatch("update", value) $: dispatch("update", value)
$: searchRgx = new RegExp(search, "ig") $: searchRgx = new RegExp(search, "ig")
@ -35,16 +41,16 @@
} }
function addToText(binding) { function addToText(binding) {
const position = getCaretPosition() const position = getCaretPosition()
const toAdd = `{{ ${binding.path} }}` const toAdd = `{{ ${binding.path} }}`
if (position.start) { if (position.start) {
value = value =
value.substring(0, position.start) + value.substring(0, position.start) +
toAdd + toAdd +
value.substring(position.end, value.length) value.substring(position.end, value.length)
} else { } else {
value += toAdd value += toAdd
} }
} }
export function cancel() { export function cancel() {
dispatch("update", originalValue) dispatch("update", originalValue)

View File

@ -47,6 +47,8 @@
} }
return bindings return bindings
} }
$: console.log('Bindings in Block Setup: ', bindings)
</script> </script>
<div class="block-label">{block.name}</div> <div class="block-label">{block.name}</div>

View File

@ -7,6 +7,8 @@
export let value export let value
export let bindings export let bindings
$: console.log('Bindings in Row Selector: ', bindings)
$: table = $backendUiStore.tables.find(table => table._id === value?.tableId) $: table = $backendUiStore.tables.find(table => table._id === value?.tableId)
$: schemaFields = Object.entries(table?.schema ?? {}) $: schemaFields = Object.entries(table?.schema ?? {})

View File

@ -8,18 +8,16 @@
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
export let panel = BindingPanel
export let value = "" export let value = ""
export let bindings = [] export let bindings = []
export let label
export let thin = true export let thin = true
export let title = "Bindings" export let title = "Bindings"
export let placeholder export let placeholder
export let panel = BindingPanel
let bindingDrawer let bindingDrawer
$: tempValue = value $: tempValue = value
$: console.log('Value: ', tempValue)
$: readableValue = runtimeToReadableBinding(bindings, value) $: readableValue = runtimeToReadableBinding(bindings, value)
const handleClose = () => { const handleClose = () => {
@ -35,7 +33,6 @@
<div class="control"> <div class="control">
<Input <Input
{thin} {thin}
{label}
value={readableValue} value={readableValue}
on:change={event => onChange(event.target.value)} on:change={event => onChange(event.target.value)}
{placeholder} /> {placeholder} />
@ -53,11 +50,13 @@
<Button thin blue on:click={handleClose}>Save</Button> <Button thin blue on:click={handleClose}>Save</Button>
</heading> </heading>
<div slot="body"> <div slot="body">
<svelte:component this={panel} <svelte:component
this={panel}
value={readableValue} value={readableValue}
close={handleClose} close={handleClose}
on:update={event => (tempValue = event.detail)} on:update={event => (tempValue = event.detail)}
bindableProperties={bindings} /> bindableProperties={bindings}
{bindings} />
</div> </div>
</Drawer> </Drawer>