add multiselect / date / boolean types to automations

This commit is contained in:
Peter Clement 2021-09-20 16:23:33 +01:00
parent f5edc45570
commit 053ea4e499
4 changed files with 52 additions and 21 deletions

View File

@ -1,9 +1,8 @@
<script> <script>
import { automationStore } from "builderStore" import { automationStore } from "builderStore"
import ConfirmDialog from "components/common/ConfirmDialog.svelte"
import FlowItem from "./FlowItem.svelte" import FlowItem from "./FlowItem.svelte"
import TestDataModal from "./TestDataModal.svelte" import TestDataModal from "./TestDataModal.svelte"
import { flip } from "svelte/animate" import { flip } from "svelte/animate"
import { fade, fly } from "svelte/transition" import { fade, fly } from "svelte/transition"
import { import {
@ -13,13 +12,12 @@
notifications, notifications,
Modal, Modal,
} from "@budibase/bbui" } from "@budibase/bbui"
import { database } from "stores/backend"
export let automation export let automation
export let onSelect export let onSelect
let testDataModal let testDataModal
let blocks let blocks
$: instanceId = $database._id let confirmDeleteDialog
$: { $: {
blocks = [] blocks = []
@ -35,6 +33,7 @@
await automationStore.actions.delete( await automationStore.actions.delete(
$automationStore.selectedAutomation?.automation $automationStore.selectedAutomation?.automation
) )
notifications.success("Automation deleted.")
} }
async function testAutomation() { async function testAutomation() {
@ -63,8 +62,8 @@
style="display:flex; style="display:flex;
color: var(--spectrum-global-color-gray-400);" color: var(--spectrum-global-color-gray-400);"
> >
<span on:click={() => deleteAutomation()} class="iconPadding"> <span on:click={confirmDeleteDialog.show} class="iconPadding">
<Icon name="DeleteOutline" /> <div class="icon"><Icon name="DeleteOutline" /></div>
</span> </span>
<ActionButton <ActionButton
on:click={() => { on:click={() => {
@ -92,6 +91,17 @@
</div> </div>
{/each} {/each}
</div> </div>
<ConfirmDialog
bind:this={confirmDeleteDialog}
okText="Delete Automation"
onOk={deleteAutomation}
title="Confirm Deletion"
>
Are you sure you wish to delete the automation
<i>{automation.name}?</i>
This action cannot be undone.
</ConfirmDialog>
<Modal bind:this={testDataModal} width="30%"> <Modal bind:this={testDataModal} width="30%">
<TestDataModal {testAutomation} /> <TestDataModal {testAutomation} />
</Modal> </Modal>
@ -139,9 +149,14 @@
justify-content: space-between; justify-content: space-between;
} }
.iconPadding { .icon {
cursor: pointer; cursor: pointer;
display: flex; display: flex;
padding-right: var(--spacing-m); padding-right: var(--spacing-m);
} }
.icon:hover {
cursor: pointer;
color: var(--spectrum-alias-text-color-hover);
}
</style> </style>

View File

@ -20,7 +20,6 @@
import QueryParamSelector from "./QueryParamSelector.svelte" import QueryParamSelector from "./QueryParamSelector.svelte"
import CronBuilder from "./CronBuilder.svelte" import CronBuilder from "./CronBuilder.svelte"
import Editor from "components/integration/QueryEditor.svelte" import Editor from "components/integration/QueryEditor.svelte"
import { database } from "stores/backend"
import { debounce } from "lodash" import { debounce } from "lodash"
import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte" import ModalBindableInput from "components/common/bindings/ModalBindableInput.svelte"
import FilterDrawer from "components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte" import FilterDrawer from "components/design/PropertiesPanel/PropertyControls/FilterEditor/FilterDrawer.svelte"
@ -35,13 +34,11 @@
let drawer let drawer
let tempFilters = lookForFilters(schemaProperties) || [] let tempFilters = lookForFilters(schemaProperties) || []
let fillWidth = true let fillWidth = true
$: stepId = block.stepId $: stepId = block.stepId
$: bindings = getAvailableBindings( $: bindings = getAvailableBindings(
block || $automationStore.selectedBlock, block || $automationStore.selectedBlock,
$automationStore.selectedAutomation?.automation?.definition $automationStore.selectedAutomation?.automation?.definition
) )
$: instanceId = $database._id
$: inputData = testData ? testData : block.inputs $: inputData = testData ? testData : block.inputs
$: tableId = inputData ? inputData.tableId : null $: tableId = inputData ? inputData.tableId : null
@ -210,7 +207,7 @@
{:else if value.customType === "webhookUrl"} {:else if value.customType === "webhookUrl"}
<WebhookDisplay value={inputData[key]} /> <WebhookDisplay value={inputData[key]} />
{:else if value.customType === "triggerSchema"} {:else if value.customType === "triggerSchema"}
<SchemaSetup on:change={e => onChange(e, key)} value={value[key]} /> <SchemaSetup on:change={e => onChange(e, key)} value={inputData[key]} />
{:else if value.customType === "code"} {:else if value.customType === "code"}
<CodeEditorModal> <CodeEditorModal>
<pre>{JSON.stringify(bindings, null, 2)}</pre> <pre>{JSON.stringify(bindings, null, 2)}</pre>

View File

@ -1,6 +1,6 @@
<script> <script>
import { tables } from "stores/backend" import { tables } from "stores/backend"
import { Select } from "@budibase/bbui" import { Select, Toggle, DatePicker, Multiselect } from "@budibase/bbui"
import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte" import DrawerBindableInput from "../../common/bindings/DrawerBindableInput.svelte"
import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte" import AutomationBindingPanel from "../../common/bindings/ServerBindingPanel.svelte"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
@ -44,13 +44,31 @@
<div class="schema-fields"> <div class="schema-fields">
{#each schemaFields as [field, schema]} {#each schemaFields as [field, schema]}
{#if !schema.autocolumn} {#if !schema.autocolumn}
{#if schemaHasOptions(schema)} {#if schemaHasOptions(schema) && schema.type !== "array"}
<Select <Select
on:change={e => onChange(e, field)} on:change={e => onChange(e, field)}
label={field} label={field}
value={value[field]} value={value[field]}
options={schema.constraints.inclusion} options={schema.constraints.inclusion}
/> />
{:else if schema.type === "datetime"}
<DatePicker
label={field}
value={value[field]}
on:change={e => onChange(e, field)}
/>
{:else if schema.type === "boolean"}
<Toggle
text={field}
value={value[field]}
on:change={e => onChange(e, field)}
/>
{:else if schema.type === "array"}
<Multiselect
bind:value={value[field]}
label={field}
options={schema.constraints.inclusion}
/>
{:else if schema.type === "string" || schema.type === "number"} {:else if schema.type === "string" || schema.type === "number"}
{#if $automationStore.selectedAutomation.automation.testData} {#if $automationStore.selectedAutomation.automation.testData}
<ModalBindableInput <ModalBindableInput

View File

@ -5,10 +5,14 @@
const dispatch = createEventDispatcher() const dispatch = createEventDispatcher()
export let value = {} export let value = {}
$: fieldsArray = Object.entries(value).map(([name, type]) => ({
$: fieldsArray = value
? Object.entries(value).map(([name, type]) => ({
name, name,
type, type,
})) }))
: []
const typeOptions = [ const typeOptions = [
{ {
label: "Text", label: "Text",
@ -73,7 +77,7 @@
<Select <Select
value={field.type} value={field.type}
on:change={e => { on:change={e => {
value[field.name] = e.target.value value[field.name] = e.detail
dispatch("change", value) dispatch("change", value)
}} }}
options={typeOptions} options={typeOptions}
@ -88,9 +92,7 @@
<style> <style>
.root { .root {
position: relative;
max-width: 100%; max-width: 100%;
overflow-x: auto;
/* so we can show the "+" button beside the "fields" label*/ /* so we can show the "+" button beside the "fields" label*/
top: -26px; top: -26px;
} }
@ -110,7 +112,6 @@
/*grid-template-rows: auto auto; /*grid-template-rows: auto auto;
grid-template-columns: auto;*/ grid-template-columns: auto;*/
position: relative; position: relative;
overflow: hidden;
} }
.field :global(select) { .field :global(select) {