2020-08-12 17:30:20 +02:00
|
|
|
<script>
|
2020-08-31 10:12:06 +02:00
|
|
|
import groupBy from "lodash/fp/groupBy"
|
2020-09-26 01:45:56 +02:00
|
|
|
import {
|
|
|
|
Button,
|
|
|
|
TextArea,
|
|
|
|
Label,
|
|
|
|
Body,
|
|
|
|
Heading,
|
|
|
|
Spacer,
|
|
|
|
} from "@budibase/bbui"
|
2020-08-25 10:15:51 +02:00
|
|
|
import { createEventDispatcher } from "svelte"
|
|
|
|
|
|
|
|
const dispatch = createEventDispatcher()
|
|
|
|
export let bindableProperties
|
2020-08-28 14:43:28 +02:00
|
|
|
console.log("Bindable Props: ", bindableProperties)
|
2020-08-25 10:15:51 +02:00
|
|
|
export let value = ""
|
2020-08-28 15:40:43 +02:00
|
|
|
export let close
|
2020-08-25 10:15:51 +02:00
|
|
|
|
|
|
|
function addToText(readableBinding) {
|
|
|
|
value = value + `{{ ${readableBinding} }}`
|
|
|
|
}
|
2020-08-28 15:40:43 +02:00
|
|
|
let originalValue = value
|
2020-08-25 10:15:51 +02:00
|
|
|
|
|
|
|
$: dispatch("update", value)
|
2020-08-28 15:40:43 +02:00
|
|
|
|
|
|
|
function cancel() {
|
|
|
|
dispatch("update", originalValue)
|
|
|
|
close()
|
|
|
|
}
|
2020-08-31 10:12:06 +02:00
|
|
|
|
|
|
|
$: ({ instance, context } = groupBy("type", bindableProperties))
|
2020-08-12 17:30:20 +02:00
|
|
|
</script>
|
|
|
|
|
2020-09-01 11:16:41 +02:00
|
|
|
<div class="container" data-cy="binding-dropdown-modal">
|
2020-08-25 10:15:51 +02:00
|
|
|
<div class="list">
|
2020-09-26 01:45:56 +02:00
|
|
|
<Heading extraSmall>Objects</Heading>
|
2020-08-31 10:12:06 +02:00
|
|
|
{#if context}
|
2020-09-26 01:45:56 +02:00
|
|
|
<Heading extraSmall>Tables</Heading>
|
2020-08-31 10:12:06 +02:00
|
|
|
<ul>
|
|
|
|
{#each context as { readableBinding }}
|
|
|
|
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
|
|
|
{/if}
|
|
|
|
{#if instance}
|
2020-09-26 01:45:56 +02:00
|
|
|
<Heading extraSmall>Components</Heading>
|
2020-08-31 10:12:06 +02:00
|
|
|
<ul>
|
|
|
|
{#each instance as { readableBinding }}
|
|
|
|
<li on:click={() => addToText(readableBinding)}>{readableBinding}</li>
|
|
|
|
{/each}
|
|
|
|
</ul>
|
|
|
|
{/if}
|
2020-08-25 10:15:51 +02:00
|
|
|
</div>
|
2020-08-28 14:43:28 +02:00
|
|
|
<div class="text">
|
2020-09-26 01:45:56 +02:00
|
|
|
<Heading extraSmall>Data binding</Heading>
|
|
|
|
<Spacer small />
|
|
|
|
<Body extraSmall lh>
|
2020-08-28 15:40:43 +02:00
|
|
|
Binding connects one piece of data to another and makes it dynamic. Click
|
|
|
|
the objects on the left, to add them to the textbox.
|
|
|
|
</Body>
|
2020-09-26 01:45:56 +02:00
|
|
|
<Spacer large />
|
2020-08-28 14:43:28 +02:00
|
|
|
<TextArea bind:value placeholder="" />
|
|
|
|
<div class="controls">
|
2020-09-26 01:45:56 +02:00
|
|
|
<a href="https://docs.budibase.com">
|
|
|
|
<Body small grey>Learn more about binding</Body>
|
2020-08-28 14:43:28 +02:00
|
|
|
</a>
|
2020-08-28 15:40:43 +02:00
|
|
|
<Button on:click={cancel} secondary>Cancel</Button>
|
|
|
|
<Button on:click={close} primary>Done</Button>
|
2020-08-28 14:43:28 +02:00
|
|
|
</div>
|
|
|
|
</div>
|
2020-08-25 10:15:51 +02:00
|
|
|
</div>
|
2020-08-12 17:30:20 +02:00
|
|
|
|
|
|
|
<style>
|
2020-08-25 10:15:51 +02:00
|
|
|
.container {
|
|
|
|
display: grid;
|
|
|
|
grid-template-columns: auto auto;
|
|
|
|
}
|
2020-08-28 14:43:28 +02:00
|
|
|
.list,
|
2020-08-25 10:15:51 +02:00
|
|
|
.text {
|
2020-08-28 14:43:28 +02:00
|
|
|
padding: var(--spacing-m);
|
2020-08-25 10:15:51 +02:00
|
|
|
}
|
2020-08-28 15:40:43 +02:00
|
|
|
.controls {
|
|
|
|
margin-top: var(--spacing-m);
|
|
|
|
display: grid;
|
2020-09-26 01:45:56 +02:00
|
|
|
align-items: baseline;
|
2020-08-28 15:40:43 +02:00
|
|
|
grid-gap: var(--spacing-l);
|
|
|
|
grid-template-columns: 1fr auto auto;
|
|
|
|
}
|
2020-08-25 10:15:51 +02:00
|
|
|
.list {
|
|
|
|
width: 150px;
|
2020-08-31 10:21:08 +02:00
|
|
|
border-right: 1.5px solid var(--grey-4);
|
2020-09-26 01:45:56 +02:00
|
|
|
padding: var(--spacing-xl);
|
2020-08-28 14:43:28 +02:00
|
|
|
}
|
|
|
|
.text {
|
|
|
|
width: 600px;
|
2020-09-26 01:45:56 +02:00
|
|
|
padding: var(--spacing-xl);
|
|
|
|
font-family: var(--font-sans);
|
2020-08-25 10:15:51 +02:00
|
|
|
}
|
2020-08-28 15:40:43 +02:00
|
|
|
.text :global(p) {
|
|
|
|
margin: 0;
|
|
|
|
}
|
2020-08-12 17:30:20 +02:00
|
|
|
ul {
|
|
|
|
list-style: none;
|
|
|
|
padding-left: 0;
|
|
|
|
margin: 0;
|
2020-08-25 11:40:48 +02:00
|
|
|
padding: 0;
|
2020-08-12 17:30:20 +02:00
|
|
|
}
|
2020-08-25 11:40:48 +02:00
|
|
|
|
2020-08-12 17:30:20 +02:00
|
|
|
li {
|
|
|
|
display: flex;
|
|
|
|
font-family: var(--font-sans);
|
|
|
|
font-size: var(--font-size-xs);
|
|
|
|
color: var(--ink);
|
|
|
|
padding: var(--spacing-s) var(--spacing-m);
|
|
|
|
margin: auto 0px;
|
|
|
|
align-items: center;
|
|
|
|
cursor: pointer;
|
|
|
|
}
|
2020-08-25 11:40:48 +02:00
|
|
|
|
|
|
|
li:hover {
|
|
|
|
background-color: var(--grey-2);
|
|
|
|
}
|
|
|
|
|
|
|
|
li:active {
|
|
|
|
color: var(--blue);
|
|
|
|
}
|
2020-08-12 17:30:20 +02:00
|
|
|
</style>
|