adds panel interface
This commit is contained in:
parent
069e5bd638
commit
deb303e381
|
@ -1,17 +1,48 @@
|
||||||
<script>
|
<script>
|
||||||
export let value = "Something is wrong"
|
import { TextArea } from "@budibase/bbui"
|
||||||
|
import { createEventDispatcher } from "svelte"
|
||||||
|
|
||||||
|
const dispatch = createEventDispatcher()
|
||||||
|
export let bindableProperties
|
||||||
|
export let value = ""
|
||||||
|
|
||||||
|
function addToText(readableBinding) {
|
||||||
|
value = value + `{{ ${readableBinding} }}`
|
||||||
|
}
|
||||||
|
|
||||||
|
$: dispatch("update", value)
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="container">{value}</div>
|
<div class="container">
|
||||||
<button on:click>Get stuff!</button>
|
<div class="text">
|
||||||
<ul>
|
<TextArea
|
||||||
<li>1</li>
|
bind:value
|
||||||
<li>2</li>
|
placeholder="Enter your name"
|
||||||
<li>3</li>
|
label="Construct your text" />
|
||||||
<li>4</li>
|
</div>
|
||||||
</ul>
|
<div class="list">
|
||||||
|
<ul>
|
||||||
|
{#each bindableProperties as { readableBinding }}
|
||||||
|
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
|
||||||
|
{/each}
|
||||||
|
</ul>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
.container {
|
||||||
|
grid-gap: 20px;
|
||||||
|
padding: 20px;
|
||||||
|
display: grid;
|
||||||
|
grid-template-columns: auto auto;
|
||||||
|
}
|
||||||
|
.text {
|
||||||
|
width: 600px;
|
||||||
|
display: grid;
|
||||||
|
}
|
||||||
|
.list {
|
||||||
|
width: 150px;
|
||||||
|
}
|
||||||
ul {
|
ul {
|
||||||
list-style: none;
|
list-style: none;
|
||||||
padding-left: 0;
|
padding-left: 0;
|
||||||
|
|
|
@ -35,14 +35,15 @@
|
||||||
const boundValues = val.match(/{{([^}]+)}}/g)
|
const boundValues = val.match(/{{([^}]+)}}/g)
|
||||||
|
|
||||||
// Replace with names:
|
// Replace with names:
|
||||||
boundValues.forEach(v => {
|
boundValues &&
|
||||||
const binding = bindableProperties.find(({ readableBinding }) => {
|
boundValues.forEach(v => {
|
||||||
return v === `{{ ${readableBinding} }}`
|
const binding = bindableProperties.find(({ readableBinding }) => {
|
||||||
|
return v === `{{ ${readableBinding} }}`
|
||||||
|
})
|
||||||
|
if (binding) {
|
||||||
|
val = val.replace(v, `{{ ${binding.runtimeBinding} }}`)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
if (binding) {
|
|
||||||
val = val.replace(v, `{{ ${binding.runtimeBinding} }}`)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
onChange(key, val)
|
onChange(key, val)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -61,7 +62,7 @@
|
||||||
const safeValue = () => {
|
const safeValue = () => {
|
||||||
getBindableProperties()
|
getBindableProperties()
|
||||||
let temp = value
|
let temp = value
|
||||||
const boundValues = value.match(/{{([^}]+)}}/g) || []
|
const boundValues = (value && value.match(/{{([^}]+)}}/g)) || []
|
||||||
console.log(boundValues)
|
console.log(boundValues)
|
||||||
|
|
||||||
// Replace with names:
|
// Replace with names:
|
||||||
|
@ -100,7 +101,10 @@
|
||||||
<button on:click={dropdown.show}>O</button>
|
<button on:click={dropdown.show}>O</button>
|
||||||
</div>
|
</div>
|
||||||
<DropdownMenu bind:this={dropdown} {anchor} align="right">
|
<DropdownMenu bind:this={dropdown} {anchor} align="right">
|
||||||
<BindingDropdown />
|
<BindingDropdown
|
||||||
|
{...handlevalueKey(value)}
|
||||||
|
on:update={e => handleChange(key, e.detail)}
|
||||||
|
{bindableProperties} />
|
||||||
</DropdownMenu>
|
</DropdownMenu>
|
||||||
|
|
||||||
<style>
|
<style>
|
||||||
|
|
Loading…
Reference in New Issue