1
0
Fork 0
mirror of synced 2024-06-30 03:50:37 +12:00

Formatting.

This commit is contained in:
mike12345567 2021-03-10 17:56:16 +00:00
parent d9217b1148
commit 3947044014
10 changed files with 263 additions and 223 deletions

View file

@ -1,190 +1,186 @@
<script> <script>
import groupBy from "lodash/fp/groupBy" import groupBy from "lodash/fp/groupBy"
import { Input, 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 { handlebarsCompletions } from "constants/completions" import { handlebarsCompletions } from "constants/completions"
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
export let value = "" export let value = ""
export let bindingDrawer export let bindingDrawer
export let bindableProperties = [] export let bindableProperties = []
let originalValue = value let originalValue = value
let helpers = handlebarsCompletions() let helpers = handlebarsCompletions()
let getCaretPosition let getCaretPosition
let search = "" let search = ""
let validity = true let validity = true
$: categories = Object.entries(groupBy("category", bindableProperties)) $: categories = Object.entries(groupBy("category", bindableProperties))
$: value && checkValid() $: value && checkValid()
$: dispatch("update", value) $: dispatch("update", value)
$: searchRgx = new RegExp(search, "ig") $: searchRgx = new RegExp(search, "ig")
function checkValid() { function checkValid() {
validity = isValid(value) validity = isValid(value)
} }
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() {
dispatch("update", originalValue)
bindingDrawer.close()
} }
}
export function cancel() {
dispatch("update", originalValue)
bindingDrawer.close()
}
</script> </script>
<div class="container"> <div class="container">
<div class="list"> <div class="list">
<Heading small>Available bindings</Heading> <Heading small>Available bindings</Heading>
<Spacer medium /> <Spacer medium />
<Input extraThin placeholder="Search" bind:value={search} /> <Input extraThin placeholder="Search" bind:value={search} />
<Spacer medium /> <Spacer medium />
{#each categories as [categoryName, bindings]} {#each categories as [categoryName, bindings]}
<Heading extraSmall>{categoryName}</Heading> <Heading extraSmall>{categoryName}</Heading>
<Spacer extraSmall /> <Spacer extraSmall />
{#each bindableProperties.filter(binding => {#each bindableProperties.filter(binding =>
binding.label.match(searchRgx) binding.label.match(searchRgx)
) as binding} ) as binding}
<div class="binding" on:click={() => addToText(binding)}> <div class="binding" on:click={() => addToText(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>
<br /> <br />
<div class="binding__description"> <div class="binding__description">{binding.description || ''}</div>
{binding.description || ''} </div>
</div> {/each}
</div> {/each}
{/each} <Heading extraSmall>Helpers</Heading>
{/each} <Spacer extraSmall />
<Heading extraSmall>Helpers</Heading> {#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper}
<Spacer extraSmall /> <div class="binding" on:click={() => addToText(helper)}>
{#each helpers.filter(helper => helper.label.match(searchRgx) || helper.description.match(searchRgx)) as helper} <span class="binding__label">{helper.label}</span>
<div class="binding" on:click={() => addToText(helper)}> <br />
<span class="binding__label">{helper.label}</span> <div class="binding__description">
<br /> {@html helper.description || ''}
<div class="binding__description"> </div>
{@html helper.description || ''} <pre>{helper.example || ''}</pre>
</div> </div>
<pre>{helper.example || ''}</pre> {/each}
</div> </div>
{/each} <div class="text">
</div> <TextArea
<div class="text"> bind:getCaretPosition
<TextArea thin
bind:getCaretPosition bind:value
thin placeholder="Add text, or click the objects on the left to add them to the textbox." />
bind:value {#if !validity}
placeholder="Add text, or click the objects on the left to add them to the textbox." /> <p class="syntax-error">
{#if !validity} Current Handlebars syntax is invalid, please check the guide
<p class="syntax-error"> <a href="https://handlebarsjs.com/guide/">here</a>
Current Handlebars syntax is invalid, please check the guide for more details.
<a href="https://handlebarsjs.com/guide/">here</a> </p>
for more details. {/if}
</p> </div>
{/if}
</div>
</div> </div>
<style> <style>
.container { .container {
height: 40vh; height: 40vh;
overflow-y: auto; overflow-y: auto;
display: grid; display: grid;
grid-template-columns: 280px 1fr; grid-template-columns: 280px 1fr;
} }
.list {
border-right: var(--border-light);
padding: var(--spacing-l);
overflow: auto;
}
.list {
border-right: var(--border-light);
padding: var(--spacing-l);
overflow: auto;
}
.list::-webkit-scrollbar { .list {
display: none; border-right: var(--border-light);
} padding: var(--spacing-l);
overflow: auto;
}
.list {
border-right: var(--border-light);
padding: var(--spacing-l);
overflow: auto;
}
.text { .list::-webkit-scrollbar {
padding: var(--spacing-l); display: none;
font-family: var(--font-sans); }
}
.text :global(textarea) { .text {
min-height: 100px; padding: var(--spacing-l);
} font-family: var(--font-sans);
.text :global(p) { }
margin: 0; .text :global(textarea) {
} min-height: 100px;
}
.binding { .text :global(p) {
font-size: 12px; margin: 0;
padding: var(--spacing-s); }
border-radius: var(--border-radius-m);
} .binding {
.binding:hover { font-size: 12px;
background-color: var(--grey-2); padding: var(--spacing-s);
cursor: pointer; border-radius: var(--border-radius-m);
} }
.binding__label { .binding:hover {
font-weight: 500; background-color: var(--grey-2);
text-transform: capitalize; cursor: pointer;
} }
.binding__description { .binding__label {
color: var(--grey-8); font-weight: 500;
margin-top: 2px; text-transform: capitalize;
white-space: normal; }
} .binding__description {
color: var(--grey-8);
pre { margin-top: 2px;
white-space: normal; white-space: normal;
} }
.binding__type { pre {
font-family: monospace; white-space: normal;
background-color: var(--grey-2); }
border-radius: var(--border-radius-m);
padding: 2px; .binding__type {
margin-left: 2px; font-family: monospace;
font-weight: 500; background-color: var(--grey-2);
} border-radius: var(--border-radius-m);
padding: 2px;
.editor { margin-left: 2px;
padding-left: var(--spacing-l); font-weight: 500;
} }
.editor :global(textarea) {
min-height: 60px; .editor {
} padding-left: var(--spacing-l);
}
.controls { .editor :global(textarea) {
display: grid; min-height: 60px;
grid-template-columns: 1fr auto; }
grid-gap: var(--spacing-l);
align-items: center; .controls {
margin-top: var(--spacing-m); display: grid;
} grid-template-columns: 1fr auto;
grid-gap: var(--spacing-l);
.syntax-error { align-items: center;
color: var(--red); margin-top: var(--spacing-m);
font-size: 12px; }
}
.syntax-error {
.syntax-error a { color: var(--red);
color: var(--red); font-size: 12px;
text-decoration: underline; }
}
</style> .syntax-error a {
color: var(--red);
text-decoration: underline;
}
</style>

View file

@ -6,7 +6,7 @@
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import WebhookDisplay from "../Shared/WebhookDisplay.svelte" import WebhookDisplay from "../Shared/WebhookDisplay.svelte"
import DrawerBindableInput from "../../common/DrawerBindableInput.svelte" import DrawerBindableInput from "../../common/DrawerBindableInput.svelte"
import AutomationBindingPanel from './AutomationBindingPanel.svelte' import AutomationBindingPanel from "./AutomationBindingPanel.svelte"
export let block export let block
export let webhookModal export let webhookModal
@ -70,7 +70,7 @@
type={'email'} type={'email'}
extraThin extraThin
value={block.inputs[key]} value={block.inputs[key]}
on:change={e => block.inputs[key] = e.detail} on:change={e => (block.inputs[key] = e.detail)}
{bindings} /> {bindings} />
{:else if value.customType === 'table'} {:else if value.customType === 'table'}
<TableSelector bind:value={block.inputs[key]} /> <TableSelector bind:value={block.inputs[key]} />
@ -86,7 +86,7 @@
type={value.customType} type={value.customType}
extraThin extraThin
value={block.inputs[key]} value={block.inputs[key]}
on:change={e => block.inputs[key] = e.detail} on:change={e => (block.inputs[key] = e.detail)}
{bindings} /> {bindings} />
{/if} {/if}
</div> </div>

View file

@ -2,7 +2,7 @@
import { backendUiStore } from "builderStore" import { backendUiStore } from "builderStore"
import { Select } from "@budibase/bbui" import { Select } from "@budibase/bbui"
import DrawerBindableInput from "../../common/DrawerBindableInput.svelte" import DrawerBindableInput from "../../common/DrawerBindableInput.svelte"
import AutomationBindingPanel from './AutomationBindingPanel.svelte' import AutomationBindingPanel from "./AutomationBindingPanel.svelte"
export let value export let value
export let bindings export let bindings
@ -44,7 +44,7 @@
panel={AutomationBindingPanel} panel={AutomationBindingPanel}
extraThin extraThin
value={value[field]} value={value[field]}
on:change={e => value[field] = e.detail} on:change={e => (value[field] = e.detail)}
label={field} label={field}
type="string" type="string"
{bindings} /> {bindings} />

View file

@ -25,10 +25,14 @@
] ]
const transitions = [ const transitions = [
'none', 'fade', 'blur', 'fly', 'scale' // slide is hidden because it does not seem to result in any effect "none",
"fade",
"blur",
"fly",
"scale", // slide is hidden because it does not seem to result in any effect
] ]
const capitalize = ([first,...rest]) => first.toUpperCase() + rest.join(''); const capitalize = ([first, ...rest]) => first.toUpperCase() + rest.join("")
$: groups = componentDefinition?.styleable ? Object.keys(allStyles) : [] $: groups = componentDefinition?.styleable ? Object.keys(allStyles) : []
</script> </script>
@ -72,13 +76,19 @@
</div> </div>
</div> </div>
{#if componentDefinition?.transitionable} {#if componentDefinition?.transitionable}
<div class="transitions"> <div class="transitions">
<Select value={componentInstance._transition} on:change={event => onUpdateTransition(event.target.value)} name="transition" label="Transition" secondary thin> <Select
{#each transitions as transition} value={componentInstance._transition}
<option value={transition}>{capitalize(transition)}</option> on:change={event => onUpdateTransition(event.target.value)}
{/each} name="transition"
</Select> label="Transition"
</div> secondary
thin>
{#each transitions as transition}
<option value={transition}>{capitalize(transition)}</option>
{/each}
</Select>
</div>
{/if} {/if}
</div> </div>

View file

@ -1,10 +1,10 @@
<script> <script>
import {flip} from "svelte/animate"; import { flip } from "svelte/animate"
import {dndzone} from "svelte-dnd-action"; import { dndzone } from "svelte-dnd-action"
import { Button, DropdownMenu, Spacer } from "@budibase/bbui" import { Button, DropdownMenu, Spacer } from "@budibase/bbui"
import actionTypes from "./actions" import actionTypes from "./actions"
const flipDurationMs = 150; const flipDurationMs = 150
const EVENT_TYPE_KEY = "##eventHandlerType" const EVENT_TYPE_KEY = "##eventHandlerType"
@ -13,7 +13,7 @@
// dndzone needs an id on the array items, so this adds some temporary ones. // dndzone needs an id on the array items, so this adds some temporary ones.
if (actions) { if (actions) {
actions = actions.map((action, i) => { actions = actions.map((action, i) => {
return {...action, id: i} return { ...action, id: i }
}) })
} }
@ -41,7 +41,7 @@
const newAction = { const newAction = {
parameters: {}, parameters: {},
[EVENT_TYPE_KEY]: actionType.name, [EVENT_TYPE_KEY]: actionType.name,
id: actions ? actions.length + 1 : 0 id: actions ? actions.length + 1 : 0,
} }
if (!actions) { if (!actions) {
actions = [] actions = []
@ -56,11 +56,11 @@
} }
function handleDndConsider(e) { function handleDndConsider(e) {
actions = e.detail.items; actions = e.detail.items
} }
function handleDndFinalize(e) { function handleDndFinalize(e) {
actions = e.detail.items; actions = e.detail.items
} }
</script> </script>
<div class="actions-container"> <div class="actions-container">
@ -87,9 +87,15 @@
</div> </div>
{#if actions && actions.length > 0} {#if actions && actions.length > 0}
<div class="action-dnd-container" use:dndzone={{items: actions, flipDurationMs, dropTargetStyle: { outline: 'none'}}} on:consider={handleDndConsider} on:finalize={handleDndFinalize}> <div
class="action-dnd-container"
use:dndzone={{ items: actions, flipDurationMs, dropTargetStyle: { outline: 'none' } }}
on:consider={handleDndConsider}
on:finalize={handleDndFinalize}>
{#each actions as action, index (action.id)} {#each actions as action, index (action.id)}
<div class="action-container" animate:flip={{duration: flipDurationMs}}> <div
class="action-container"
animate:flip={{ duration: flipDurationMs }}>
<div <div
class="action-header" class="action-header"
class:selected={action === selectedAction} class:selected={action === selectedAction}

View file

@ -162,7 +162,7 @@
{#if componentDefinition?.component?.endsWith('/fieldgroup')} {#if componentDefinition?.component?.endsWith('/fieldgroup')}
<Button secondary wide on:click={() => confirmResetFieldsDialog?.show()}> <Button secondary wide on:click={() => confirmResetFieldsDialog?.show()}>
Update Form Fields Update Form Fields
</Button> </Button>
{/if} {/if}
</div> </div>

View file

@ -43,7 +43,7 @@
.topnavitemright:hover i { .topnavitemright:hover i {
color: var(--ink); color: var(--ink);
} }
.content { .content {
padding: var(--spacing-xl); padding: var(--spacing-xl);
} }

View file

@ -41,7 +41,7 @@
id, id,
children: children.length, children: children.length,
styles: { ...styles, id }, styles: { ...styles, id },
transition transition,
}) })
// Gets the component constructor for the specified component // Gets the component constructor for the specified component

View file

@ -8,55 +8,81 @@
</script> </script>
{#if type === 'div'} {#if type === 'div'}
<div in:transition={{type: $component.transition}} use:styleable={$component.styles}> <div
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</div> </div>
{:else if type === 'header'} {:else if type === 'header'}
<header in:transition={{type: $component.transition}} use:styleable={$component.styles}> <header
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</header> </header>
{:else if type === 'main'} {:else if type === 'main'}
<main in:transition={{type: $component.transition}} use:styleable={$component.styles}> <main
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</main> </main>
{:else if type === 'footer'} {:else if type === 'footer'}
<footer in:transition={{type: $component.transition}} use:styleable={$component.styles}> <footer
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</footer> </footer>
{:else if type === 'aside'} {:else if type === 'aside'}
<aside in:transition={{type: $component.transition}} use:styleable={$component.styles}> <aside
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</aside> </aside>
{:else if type === 'summary'} {:else if type === 'summary'}
<summary in:transition={{type: $component.transition}} use:styleable={$component.styles}> <summary
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</summary> </summary>
{:else if type === 'details'} {:else if type === 'details'}
<details in:transition={{type: $component.transition}} use:styleable={$component.styles}> <details
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</details> </details>
{:else if type === 'article'} {:else if type === 'article'}
<article in:transition={{type: $component.transition}} use:styleable={$component.styles}> <article
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</article> </article>
{:else if type === 'nav'} {:else if type === 'nav'}
<nav in:transition={{type: $component.transition}} use:styleable={$component.styles}> <nav
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</nav> </nav>
{:else if type === 'mark'} {:else if type === 'mark'}
<mark in:transition={{type: $component.transition}} use:styleable={$component.styles}> <mark
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</mark> </mark>
{:else if type === 'figure'} {:else if type === 'figure'}
<figure in:transition={{type: $component.transition}} use:styleable={$component.styles}> <figure
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</figure> </figure>
{:else if type === 'figcaption'} {:else if type === 'figcaption'}
<figcaption in:transition={{type: $component.transition}} use:styleable={$component.styles}> <figcaption
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</figcaption> </figcaption>
{:else if type === 'paragraph'} {:else if type === 'paragraph'}
<p in:transition={{type: $component.transition}} use:styleable={$component.styles}> <p
in:transition={{ type: $component.transition }}
use:styleable={$component.styles}>
<slot /> <slot />
</p> </p>
{/if} {/if}

View file

@ -152,7 +152,9 @@
{#if selectedRows.length > 0} {#if selectedRows.length > 0}
<DeleteButton text small on:click={modal.show()}> <DeleteButton text small on:click={modal.show()}>
<Icon name="addrow" /> <Icon name="addrow" />
Delete {selectedRows.length} row(s) Delete
{selectedRows.length}
row(s)
</DeleteButton> </DeleteButton>
{/if} {/if}
</div> </div>