adding search in binding drawer

This commit is contained in:
Martin McKeaveney 2021-02-01 14:29:51 +00:00
parent 2276944f36
commit 214ebf8f3a
4 changed files with 30 additions and 8 deletions

View File

@ -3,6 +3,7 @@
import { import {
TextArea, TextArea,
Label, Label,
Input,
Heading, Heading,
Body, Body,
Spacer, Spacer,
@ -24,6 +25,7 @@
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
let getCaretPosition let getCaretPosition
let validity = true let validity = true
let search = ""
$: categories = Object.entries(groupBy("category", bindings)) $: categories = Object.entries(groupBy("category", bindings))
$: value && checkValid() $: value && checkValid()
@ -50,12 +52,17 @@
<div class="container"> <div class="container">
<div class="bindings"> <div class="bindings">
<Heading small>Available bindings</Heading> <Heading small>Available bindings</Heading>
<Spacer medium />
<Input extraThin placeholder="Search" bind:value={search} />
<Spacer medium />
<div class="bindings__wrapper"> <div class="bindings__wrapper">
<div class="bindings__list"> <div class="bindings__list">
{#each categories as [categoryName, bindings]} {#each categories as [categoryName, bindings]}
<Heading extraSmall>{categoryName}</Heading> <Heading extraSmall>{categoryName}</Heading>
<Spacer extraSmall /> <Spacer extraSmall />
{#each bindings as binding} {#each bindings.filter(binding =>
binding.label.startsWith(search)
) as binding}
<div class="binding" on:click={() => onClickBinding(binding)}> <div class="binding" on:click={() => onClickBinding(binding)}>
<span class="binding__label">{binding.label}</span> <span class="binding__label">{binding.label}</span>
<span class="binding__type">{binding.type}</span> <span class="binding__type">{binding.type}</span>
@ -68,11 +75,15 @@
{/each} {/each}
<Heading extraSmall>Helpers</Heading> <Heading extraSmall>Helpers</Heading>
<Spacer extraSmall /> <Spacer extraSmall />
{#each helpers as helper} {#each helpers.filter(binding =>
binding.label.startsWith(search)
) as helper}
<div class="binding" on:click={() => onClickBinding(helper)}> <div class="binding" on:click={() => onClickBinding(helper)}>
<span class="binding__label">{helper.displayText}</span> <span class="binding__label">{helper.label}</span>
<br /> <br />
<div class="binding__description">{helper.description || ''}</div> <div class="binding__description">
{@html helper.description || ''}
</div>
</div> </div>
{/each} {/each}
</div> </div>

View File

@ -1,6 +1,7 @@
<script> <script>
import api from "builderStore/api" import api from "builderStore/api"
import { Button, Select } from "@budibase/bbui" import { Button, Select } from "@budibase/bbui"
import download from "downloadjs"
const FORMATS = [ const FORMATS = [
{ {

View File

@ -1,6 +1,6 @@
<script> <script>
import groupBy from "lodash/fp/groupBy" import groupBy from "lodash/fp/groupBy"
import { TextArea, Heading, Spacer, Label } from "@budibase/bbui" import { Input, TextArea, Heading, Spacer, Label } from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { isValid } from "@budibase/string-templates" import { isValid } from "@budibase/string-templates"
import { import {
@ -20,6 +20,7 @@
let originalValue = value let originalValue = value
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
let getCaretPosition let getCaretPosition
let search = ""
$: value && checkValid() $: value && checkValid()
$: bindableProperties = getBindableProperties( $: bindableProperties = getBindableProperties(
@ -61,11 +62,15 @@
<div class="drawer-contents"> <div class="drawer-contents">
<div class="container" data-cy="binding-dropdown-modal"> <div class="container" data-cy="binding-dropdown-modal">
<div class="list"> <div class="list">
<Input extraThin placeholder="Search" bind:value={search} />
<Spacer medium />
{#if context} {#if context}
<Heading extraSmall>Columns</Heading> <Heading extraSmall>Columns</Heading>
<Spacer small /> <Spacer small />
<ul> <ul>
{#each context as { readableBinding }} {#each context.filter(context =>
context.readableBinding.startsWith(search)
) as { readableBinding }}
<li on:click={() => addToText(readableBinding)}> <li on:click={() => addToText(readableBinding)}>
{readableBinding} {readableBinding}
</li> </li>
@ -77,7 +82,9 @@
<Heading extraSmall>Components</Heading> <Heading extraSmall>Components</Heading>
<Spacer small /> <Spacer small />
<ul> <ul>
{#each instance as { readableBinding }} {#each instance.filter(instance =>
instance.readableBinding.startsWith(search)
) as { readableBinding }}
<li on:click={() => addToText(readableBinding)}> <li on:click={() => addToText(readableBinding)}>
{readableBinding} {readableBinding}
</li> </li>
@ -88,7 +95,9 @@
<Heading extraSmall>Helpers</Heading> <Heading extraSmall>Helpers</Heading>
<Spacer small /> <Spacer small />
<ul> <ul>
{#each helpers as helper} {#each helpers.filter(helper =>
helper.label.startsWith(search)
) as helper}
<li on:click={() => addToText(helper.text)}> <li on:click={() => addToText(helper.text)}>
<div> <div>
<Label extraSmall>{helper.displayText}</Label> <Label extraSmall>{helper.displayText}</Label>

View File

@ -7,6 +7,7 @@ export function handlebarsCompletions() {
Object.entries(manifest[key]).map(([helperName, helperConfig]) => ({ Object.entries(manifest[key]).map(([helperName, helperConfig]) => ({
text: helperName, text: helperName,
path: helperName, path: helperName,
label: helperName,
displayText: helperName, displayText: helperName,
description: helperConfig.description, description: helperConfig.description,
})) }))