Clean up usages of drawers everywhere
This commit is contained in:
parent
32b0aa34b8
commit
3d96292f26
|
@ -52,11 +52,12 @@
|
||||||
<script>
|
<script>
|
||||||
import Portal from "svelte-portal"
|
import Portal from "svelte-portal"
|
||||||
import Button from "../Button/Button.svelte"
|
import Button from "../Button/Button.svelte"
|
||||||
import { setContext, createEventDispatcher, onDestroy } from "svelte"
|
import { setContext, createEventDispatcher, onMount } from "svelte"
|
||||||
import { generate } from "shortid"
|
import { generate } from "shortid"
|
||||||
import { fade } from "svelte/transition"
|
import { fade } from "svelte/transition"
|
||||||
|
|
||||||
export let title
|
export let title
|
||||||
|
export let forceModal = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
const spacing = 11
|
const spacing = 11
|
||||||
|
@ -89,6 +90,9 @@
|
||||||
if (visible) {
|
if (visible) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
if (forceModal) {
|
||||||
|
modal.set(true)
|
||||||
|
}
|
||||||
observe()
|
observe()
|
||||||
visible = true
|
visible = true
|
||||||
dispatch("drawerShow", drawerId)
|
dispatch("drawerShow", drawerId)
|
||||||
|
@ -112,6 +116,7 @@
|
||||||
hide,
|
hide,
|
||||||
show,
|
show,
|
||||||
modal,
|
modal,
|
||||||
|
forceModal,
|
||||||
})
|
})
|
||||||
|
|
||||||
const easeInOutQuad = x => {
|
const easeInOutQuad = x => {
|
||||||
|
@ -141,9 +146,14 @@
|
||||||
return 1 - lim * 0.1
|
return 1 - lim * 0.1
|
||||||
}
|
}
|
||||||
|
|
||||||
onDestroy(() => {
|
onMount(() => {
|
||||||
if (visible) {
|
if (forceModal) {
|
||||||
hide()
|
modal.set(true)
|
||||||
|
}
|
||||||
|
return () => {
|
||||||
|
if (visible) {
|
||||||
|
hide()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
</script>
|
</script>
|
||||||
|
@ -184,7 +194,7 @@
|
||||||
height: 420px;
|
height: 420px;
|
||||||
background: var(--background);
|
background: var(--background);
|
||||||
border: var(--border-light);
|
border: var(--border-light);
|
||||||
z-index: 3;
|
z-index: 999;
|
||||||
border-radius: 8px;
|
border-radius: 8px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
box-sizing: border-box;
|
box-sizing: border-box;
|
||||||
|
@ -212,7 +222,7 @@
|
||||||
width: 100%;
|
width: 100%;
|
||||||
height: 100%;
|
height: 100%;
|
||||||
transition: opacity 360ms ease-out;
|
transition: opacity 360ms ease-out;
|
||||||
z-index: 3;
|
z-index: 999;
|
||||||
opacity: 0.5;
|
opacity: 0.5;
|
||||||
}
|
}
|
||||||
.overlay {
|
.overlay {
|
||||||
|
|
|
@ -52,11 +52,12 @@
|
||||||
export let testData
|
export let testData
|
||||||
export let schemaProperties
|
export let schemaProperties
|
||||||
export let isTestModal = false
|
export let isTestModal = false
|
||||||
|
|
||||||
let webhookModal
|
let webhookModal
|
||||||
let drawer
|
let drawer
|
||||||
let fillWidth = true
|
|
||||||
let inputData
|
let inputData
|
||||||
let insertAtPos, getCaretPosition
|
let insertAtPos, getCaretPosition
|
||||||
|
|
||||||
$: filters = lookForFilters(schemaProperties) || []
|
$: filters = lookForFilters(schemaProperties) || []
|
||||||
$: tempFilters = filters
|
$: tempFilters = filters
|
||||||
$: stepId = block.stepId
|
$: stepId = block.stepId
|
||||||
|
@ -80,7 +81,6 @@
|
||||||
})
|
})
|
||||||
$: editingJs = codeMode === EditorModes.JS
|
$: editingJs = codeMode === EditorModes.JS
|
||||||
$: requiredProperties = block.schema.inputs.required || []
|
$: requiredProperties = block.schema.inputs.required || []
|
||||||
|
|
||||||
$: stepCompletions =
|
$: stepCompletions =
|
||||||
codeMode === EditorModes.Handlebars
|
codeMode === EditorModes.Handlebars
|
||||||
? [hbAutocomplete([...bindingsToCompletions(bindings, codeMode)])]
|
? [hbAutocomplete([...bindingsToCompletions(bindings, codeMode)])]
|
||||||
|
@ -377,12 +377,13 @@
|
||||||
<div class="fields">
|
<div class="fields">
|
||||||
{#each schemaProperties as [key, value]}
|
{#each schemaProperties as [key, value]}
|
||||||
{#if canShowField(key, value)}
|
{#if canShowField(key, value)}
|
||||||
|
{@const label = getFieldLabel(key, value)}
|
||||||
<div class:block-field={shouldRenderField(value)}>
|
<div class:block-field={shouldRenderField(value)}>
|
||||||
{#if key !== "fields" && value.type !== "boolean" && shouldRenderField(value)}
|
{#if key !== "fields" && value.type !== "boolean" && shouldRenderField(value)}
|
||||||
<Label
|
<Label
|
||||||
tooltip={value.title === "Binding / Value"
|
tooltip={value.title === "Binding / Value"
|
||||||
? "If using the String input type, please use a comma or newline separated string"
|
? "If using the String input type, please use a comma or newline separated string"
|
||||||
: null}>{getFieldLabel(key, value)}</Label
|
: null}>{label}</Label
|
||||||
>
|
>
|
||||||
{/if}
|
{/if}
|
||||||
<div class:field-width={shouldRenderField(value)}>
|
<div class:field-width={shouldRenderField(value)}>
|
||||||
|
@ -415,8 +416,7 @@
|
||||||
</div>
|
</div>
|
||||||
{:else if value.type === "date"}
|
{:else if value.type === "date"}
|
||||||
<DrawerBindableSlot
|
<DrawerBindableSlot
|
||||||
fillWidth
|
title={value.title ?? label}
|
||||||
title={value.title}
|
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={"date"}
|
type={"date"}
|
||||||
value={inputData[key]}
|
value={inputData[key]}
|
||||||
|
@ -439,7 +439,7 @@
|
||||||
/>
|
/>
|
||||||
{:else if value.customType === "filters"}
|
{:else if value.customType === "filters"}
|
||||||
<ActionButton on:click={drawer.show}>Define filters</ActionButton>
|
<ActionButton on:click={drawer.show}>Define filters</ActionButton>
|
||||||
<Drawer bind:this={drawer} {fillWidth} title="Filtering">
|
<Drawer bind:this={drawer} title="Filtering">
|
||||||
<Button cta slot="buttons" on:click={() => saveFilters(key)}>
|
<Button cta slot="buttons" on:click={() => saveFilters(key)}>
|
||||||
Save
|
Save
|
||||||
</Button>
|
</Button>
|
||||||
|
@ -450,7 +450,6 @@
|
||||||
{schemaFields}
|
{schemaFields}
|
||||||
datasource={{ type: "table", tableId }}
|
datasource={{ type: "table", tableId }}
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
fillWidth
|
|
||||||
on:change={e => (tempFilters = e.detail)}
|
on:change={e => (tempFilters = e.detail)}
|
||||||
/>
|
/>
|
||||||
</Drawer>
|
</Drawer>
|
||||||
|
@ -463,19 +462,17 @@
|
||||||
{:else if value.customType === "email"}
|
{:else if value.customType === "email"}
|
||||||
{#if isTestModal}
|
{#if isTestModal}
|
||||||
<ModalBindableInput
|
<ModalBindableInput
|
||||||
title={value.title}
|
title={value.title ?? label}
|
||||||
value={inputData[key]}
|
value={inputData[key]}
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type="email"
|
type="email"
|
||||||
on:change={e => onChange(e, key)}
|
on:change={e => onChange(e, key)}
|
||||||
{bindings}
|
{bindings}
|
||||||
fillWidth
|
|
||||||
updateOnChange={false}
|
updateOnChange={false}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<DrawerBindableInput
|
<DrawerBindableInput
|
||||||
fillWidth
|
title={value.title ?? label}
|
||||||
title={value.title}
|
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type="email"
|
type="email"
|
||||||
value={inputData[key]}
|
value={inputData[key]}
|
||||||
|
@ -609,7 +606,7 @@
|
||||||
{:else if value.type === "string" || value.type === "number" || value.type === "integer"}
|
{:else if value.type === "string" || value.type === "number" || value.type === "integer"}
|
||||||
{#if isTestModal}
|
{#if isTestModal}
|
||||||
<ModalBindableInput
|
<ModalBindableInput
|
||||||
title={value.title}
|
title={value.title || label}
|
||||||
value={inputData[key]}
|
value={inputData[key]}
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={value.customType}
|
type={value.customType}
|
||||||
|
@ -620,8 +617,7 @@
|
||||||
{:else}
|
{:else}
|
||||||
<div class="test">
|
<div class="test">
|
||||||
<DrawerBindableInput
|
<DrawerBindableInput
|
||||||
fillWidth={true}
|
title={value.title ?? label}
|
||||||
title={value.title}
|
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={value.customType}
|
type={value.customType}
|
||||||
value={inputData[key]}
|
value={inputData[key]}
|
||||||
|
|
|
@ -57,7 +57,6 @@
|
||||||
on:change={e => onChange(e, field)}
|
on:change={e => onChange(e, field)}
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
fillWidth={true}
|
|
||||||
updateOnChange={false}
|
updateOnChange={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -52,7 +52,6 @@
|
||||||
on:change={e => onChange(e, field)}
|
on:change={e => onChange(e, field)}
|
||||||
type="string"
|
type="string"
|
||||||
{bindings}
|
{bindings}
|
||||||
fillWidth={true}
|
|
||||||
updateOnChange={false}
|
updateOnChange={false}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
|
|
@ -129,7 +129,6 @@
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
<DrawerBindableSlot
|
<DrawerBindableSlot
|
||||||
fillWidth
|
|
||||||
title={value.title || field}
|
title={value.title || field}
|
||||||
panel={AutomationBindingPanel}
|
panel={AutomationBindingPanel}
|
||||||
type={schema.type}
|
type={schema.type}
|
||||||
|
|
|
@ -85,8 +85,8 @@
|
||||||
on:change={e => onChange(e, field)}
|
on:change={e => onChange(e, field)}
|
||||||
type="string"
|
type="string"
|
||||||
bindings={parsedBindings}
|
bindings={parsedBindings}
|
||||||
fillWidth={true}
|
|
||||||
allowJS={true}
|
allowJS={true}
|
||||||
updateOnChange={false}
|
updateOnChange={false}
|
||||||
|
title={schema.name}
|
||||||
/>
|
/>
|
||||||
{/if}
|
{/if}
|
||||||
|
|
|
@ -213,7 +213,7 @@
|
||||||
<Icon name={tab} size="S" />
|
<Icon name={tab} size="S" />
|
||||||
</ActionButton>
|
</ActionButton>
|
||||||
{/each}
|
{/each}
|
||||||
{#if drawerContext}
|
{#if drawerContext && !drawerContext.forceModal}
|
||||||
<ActionButton
|
<ActionButton
|
||||||
size="M"
|
size="M"
|
||||||
quiet
|
quiet
|
||||||
|
|
|
@ -17,13 +17,12 @@
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let label
|
export let label
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let fillWidth
|
|
||||||
export let allowJS = true
|
export let allowJS = true
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
export let drawerLeft
|
|
||||||
export let key
|
export let key
|
||||||
export let disableBindings = false
|
export let disableBindings = false
|
||||||
|
export let forceModal = false
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -87,10 +86,9 @@
|
||||||
<Drawer
|
<Drawer
|
||||||
on:drawerHide={onDrawerHide}
|
on:drawerHide={onDrawerHide}
|
||||||
on:drawerShow
|
on:drawerShow
|
||||||
{fillWidth}
|
|
||||||
bind:this={bindingDrawer}
|
bind:this={bindingDrawer}
|
||||||
title={title ?? placeholder ?? "Bindings"}
|
title={title ?? placeholder ?? "Bindings"}
|
||||||
left={drawerLeft}
|
{forceModal}
|
||||||
>
|
>
|
||||||
<Button cta slot="buttons" disabled={!valid} on:click={saveBinding}>
|
<Button cta slot="buttons" disabled={!valid} on:click={saveBinding}>
|
||||||
Save
|
Save
|
||||||
|
|
|
@ -16,7 +16,6 @@
|
||||||
export let placeholder
|
export let placeholder
|
||||||
export let label
|
export let label
|
||||||
export let disabled = false
|
export let disabled = false
|
||||||
export let fillWidth
|
|
||||||
export let allowJS = true
|
export let allowJS = true
|
||||||
export let allowHelpers = true
|
export let allowHelpers = true
|
||||||
export let updateOnChange = true
|
export let updateOnChange = true
|
||||||
|
@ -171,7 +170,6 @@
|
||||||
<Drawer
|
<Drawer
|
||||||
on:drawerHide
|
on:drawerHide
|
||||||
on:drawerShow
|
on:drawerShow
|
||||||
{fillWidth}
|
|
||||||
bind:this={bindingDrawer}
|
bind:this={bindingDrawer}
|
||||||
title={title ?? placeholder ?? "Bindings"}
|
title={title ?? placeholder ?? "Bindings"}
|
||||||
left={drawerLeft}
|
left={drawerLeft}
|
||||||
|
|
|
@ -1,113 +1,5 @@
|
||||||
<script>
|
<script>
|
||||||
import { Icon, Input, Modal, Body, ModalContent } from "@budibase/bbui"
|
import DrawerBindableInput from "components/common/bindings/DrawerBindableInput.svelte"
|
||||||
import {
|
|
||||||
readableToRuntimeBinding,
|
|
||||||
runtimeToReadableBinding,
|
|
||||||
} from "dataBinding"
|
|
||||||
import ServerBindingPanel from "components/common/bindings/ServerBindingPanel.svelte"
|
|
||||||
import { createEventDispatcher } from "svelte"
|
|
||||||
import { isJSBinding } from "@budibase/string-templates"
|
|
||||||
|
|
||||||
export let panel = ServerBindingPanel
|
|
||||||
export let value = ""
|
|
||||||
export let bindings = []
|
|
||||||
export let title = "Bindings"
|
|
||||||
export let placeholder
|
|
||||||
export let label
|
|
||||||
export let allowJS = false
|
|
||||||
export let updateOnChange = true
|
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
|
||||||
let bindingModal
|
|
||||||
let valid = true
|
|
||||||
|
|
||||||
$: readableValue = runtimeToReadableBinding(bindings, value)
|
|
||||||
$: tempValue = readableValue
|
|
||||||
$: isJS = isJSBinding(value)
|
|
||||||
|
|
||||||
const saveBinding = () => {
|
|
||||||
onChange(tempValue)
|
|
||||||
bindingModal.hide()
|
|
||||||
}
|
|
||||||
|
|
||||||
const onChange = input => {
|
|
||||||
dispatch("change", readableToRuntimeBinding(bindings, input))
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div class="control">
|
<DrawerBindableInput {...$$props} forceModal />
|
||||||
<Input
|
|
||||||
{label}
|
|
||||||
readonly={isJS}
|
|
||||||
value={isJS ? "(JavaScript function)" : readableValue}
|
|
||||||
on:change={event => onChange(event.detail)}
|
|
||||||
{placeholder}
|
|
||||||
{updateOnChange}
|
|
||||||
/>
|
|
||||||
<div class="icon" on:click={bindingModal.show}>
|
|
||||||
<Icon size="S" name="FlashOn" />
|
|
||||||
</div>
|
|
||||||
</div>
|
|
||||||
<Modal bind:this={bindingModal}>
|
|
||||||
<ModalContent {title} onConfirm={saveBinding} disabled={!valid} size="XL">
|
|
||||||
<Body extraSmall grey>
|
|
||||||
Add the objects on the left to enrich your text.
|
|
||||||
</Body>
|
|
||||||
<div class="panel-wrapper">
|
|
||||||
<svelte:component
|
|
||||||
this={panel}
|
|
||||||
serverSide
|
|
||||||
value={readableValue}
|
|
||||||
bind:valid
|
|
||||||
on:change={e => (tempValue = e.detail)}
|
|
||||||
{bindings}
|
|
||||||
{allowJS}
|
|
||||||
/>
|
|
||||||
</div>
|
|
||||||
</ModalContent>
|
|
||||||
</Modal>
|
|
||||||
|
|
||||||
<style>
|
|
||||||
.control {
|
|
||||||
flex: 1;
|
|
||||||
position: relative;
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon {
|
|
||||||
right: 1px;
|
|
||||||
bottom: 1px;
|
|
||||||
position: absolute;
|
|
||||||
justify-content: center;
|
|
||||||
align-items: center;
|
|
||||||
display: flex;
|
|
||||||
flex-direction: row;
|
|
||||||
box-sizing: border-box;
|
|
||||||
border-left: 1px solid var(--spectrum-alias-border-color);
|
|
||||||
border-top-right-radius: var(--spectrum-alias-border-radius-regular);
|
|
||||||
border-bottom-right-radius: var(--spectrum-alias-border-radius-regular);
|
|
||||||
width: 31px;
|
|
||||||
color: var(--spectrum-alias-text-color);
|
|
||||||
background-color: var(--spectrum-global-color-gray-75);
|
|
||||||
transition: background-color
|
|
||||||
var(--spectrum-global-animation-duration-100, 130ms),
|
|
||||||
box-shadow var(--spectrum-global-animation-duration-100, 130ms),
|
|
||||||
border-color var(--spectrum-global-animation-duration-100, 130ms);
|
|
||||||
height: calc(var(--spectrum-alias-item-height-m) - 2px);
|
|
||||||
}
|
|
||||||
|
|
||||||
.icon:hover {
|
|
||||||
cursor: pointer;
|
|
||||||
color: var(--spectrum-alias-text-color-hover);
|
|
||||||
background-color: var(--spectrum-global-color-gray-50);
|
|
||||||
border-color: var(--spectrum-alias-border-color-hover);
|
|
||||||
}
|
|
||||||
|
|
||||||
.panel-wrapper {
|
|
||||||
border: var(--border-light);
|
|
||||||
border-radius: 4px;
|
|
||||||
}
|
|
||||||
|
|
||||||
.control :global(.spectrum-Textfield-input) {
|
|
||||||
padding-right: 40px;
|
|
||||||
}
|
|
||||||
</style>
|
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
export let bindings = []
|
export let bindings = []
|
||||||
export let panel = ClientBindingPanel
|
export let panel = ClientBindingPanel
|
||||||
export let allowBindings = true
|
export let allowBindings = true
|
||||||
export let fillWidth = false
|
|
||||||
export let datasource
|
export let datasource
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
@ -266,7 +265,6 @@
|
||||||
{panel}
|
{panel}
|
||||||
{bindings}
|
{bindings}
|
||||||
on:change={event => (filter.value = event.detail)}
|
on:change={event => (filter.value = event.detail)}
|
||||||
{fillWidth}
|
|
||||||
/>
|
/>
|
||||||
{:else if ["string", "longform", "number", "bigint", "formula"].includes(filter.type)}
|
{:else if ["string", "longform", "number", "bigint", "formula"].includes(filter.type)}
|
||||||
<Input disabled={filter.noValue} bind:value={filter.value} />
|
<Input disabled={filter.noValue} bind:value={filter.value} />
|
||||||
|
|
|
@ -131,7 +131,6 @@
|
||||||
value={field.value}
|
value={field.value}
|
||||||
allowJS={false}
|
allowJS={false}
|
||||||
{allowHelpers}
|
{allowHelpers}
|
||||||
fillWidth={true}
|
|
||||||
drawerLeft={bindingDrawerLeft}
|
drawerLeft={bindingDrawerLeft}
|
||||||
/>
|
/>
|
||||||
{:else}
|
{:else}
|
||||||
|
|
Loading…
Reference in New Issue