Query page tidy up

Props aligned in a row within the header.
Add params popover UI tidied (labels removed, etc)
Query name made an input, and the old query name input removed.
Query type is not an input anymore.
Provided a height for the query editor
Aligned run/save query buttons with the preview panel.
This commit is contained in:
Joe 2021-01-22 16:49:22 +00:00
parent fcb1c082cb
commit 6db127384e
7 changed files with 99 additions and 86 deletions

View File

@ -22,13 +22,12 @@
<div on:click|stopPropagation bind:this={anchor}> <div on:click|stopPropagation bind:this={anchor}>
<TextButton <TextButton
text text
small
on:click={dropdown.show} on:click={dropdown.show}
active={true}> active={false}>
<Icon name="plus" /> <Icon name="add" />
Add Parameters Add Parameters
</TextButton> </TextButton>
<DropdownMenu align="left" {anchor} bind:this={dropdown}> <DropdownMenu align="right" {anchor} bind:this={dropdown}>
<div class="wrapper"> <div class="wrapper">
<ParameterBuilder bind:parameters {bindable} /> <ParameterBuilder bind:parameters {bindable} />
</div> </div>
@ -38,5 +37,6 @@
<style> <style>
.wrapper { .wrapper {
padding: var(--spacing-xl); padding: var(--spacing-xl);
min-width: 600px;
} }
</style> </style>

View File

@ -155,8 +155,9 @@
} }
:global(.CodeMirror) { :global(.CodeMirror) {
height: auto !important; height: 500px !important;
border-radius: var(--border-radius-m); border-radius: var(--border-radius-s);
font-family: var(--font-sans) !important; font-family: monospace !important;
line-height: 1.3;
} }
</style> </style>

View File

@ -24,18 +24,18 @@
</script> </script>
<form on:submit|preventDefault> <form on:submit|preventDefault>
<div class="field">
{#each schemaKeys as field} {#each schemaKeys as field}
<Label extraSmall grey>{field}</Label>
<div class="field">
<Input <Input
placeholder="Enter {field} name"
outline
disabled={!editable} disabled={!editable}
type={schema.fields[field]?.type} type={schema.fields[field]?.type}
required={schema.fields[field]?.required} required={schema.fields[field]?.required}
bind:value={fields[field]} /> bind:value={fields[field]} />
</div>
{/each} {/each}
</div>
</form> </form>
<Label extraSmall grey>Data</Label>
{#if schema.customisable} {#if schema.customisable}
<Editor <Editor
label="Query" label="Query"
@ -49,7 +49,7 @@
.field { .field {
margin-bottom: var(--spacing-m); margin-bottom: var(--spacing-m);
display: grid; display: grid;
grid-template-columns: 1fr 2%; grid-template-columns: 1fr 1fr;
grid-gap: var(--spacing-m); grid-gap: var(--spacing-m);
align-items: center; align-items: center;
} }

View File

@ -1,5 +1,12 @@
<script> <script>
import { Button, TextArea, Label, Input, Heading } from "@budibase/bbui" import {
Button,
TextArea,
Label,
Input,
Heading,
Spacer,
} from "@budibase/bbui"
import BindableInput from "components/userInterface/BindableInput.svelte" import BindableInput from "components/userInterface/BindableInput.svelte"
import { import {
readableToRuntimeBinding, readableToRuntimeBinding,
@ -31,19 +38,22 @@
<section> <section>
<Heading extraSmall black>Parameters</Heading> <Heading extraSmall black>Parameters</Heading>
<Spacer large />
<div class="parameters" class:bindable> <div class="parameters" class:bindable>
<Label extraSmall grey>Parameter Name</Label>
<Label extraSmall grey>Default</Label>
{#if bindable}
<Label extraSmall grey>Value</Label>
{:else}
<div />
{/if}
{#each parameters as parameter, idx} {#each parameters as parameter, idx}
<Input thin disabled={bindable} bind:value={parameter.name} /> <Input
<Input thin disabled={bindable} bind:value={parameter.default} /> placeholder="Parameter Name"
thin
disabled={bindable}
bind:value={parameter.name} />
<Input
placeholder="Default"
thin
disabled={bindable}
bind:value={parameter.default} />
{#if bindable} {#if bindable}
<BindableInput <BindableInput
placeholder="Value"
type="string" type="string"
thin thin
on:change={evt => onBindingChange(parameter.name, evt.detail)} on:change={evt => onBindingChange(parameter.name, evt.detail)}
@ -57,9 +67,7 @@
{/each} {/each}
</div> </div>
{#if !bindable} {#if !bindable}
<Button thin secondary small on:click={newQueryParameter}> <Button secondary on:click={newQueryParameter}>Add Parameter</Button>
Add Parameter
</Button>
{/if} {/if}
</section> </section>

View File

@ -131,53 +131,44 @@
</script> </script>
<header> <header>
<Heading small>{query.name}</Heading> <div class="input">
<Input placeholder="✎ Edit Query Name" bind:value={query.name} />
</div>
{#if config} {#if config}
<div class="queryVerbs"> <div class="props">
</div> <div class="query-type">Query type: <span class="query-type-span">{config[query.queryVerb].type}</span></div>
<Select thin secondary bind:value={query.queryVerb}> <div class="select">
<Select primary thin bind:value={query.queryVerb}>
{#each Object.keys(config) as queryVerb} {#each Object.keys(config) as queryVerb}
<option value={queryVerb}>{queryVerb}</option> <option value={queryVerb}>{queryVerb}</option>
{/each} {/each}
</Select> </Select>
<div> </div>
{config[query.queryVerb].type} </div>
</div>
<EditQueryParamsPopover bind:parameters={query.parameters} bindable={false} /> <EditQueryParamsPopover bind:parameters={query.parameters} bindable={false} />
<Spacer medium />
<Button primary href={docsLink} target="_blank">
<i class="ri-book-2-line" />
</Button>
{/if} {/if}
</header> </header>
<Spacer extraLarge />
<Spacer large />
{#if shouldShowQueryConfig} {#if shouldShowQueryConfig}
<section> <section>
<div class="config"> <div class="config">
<Label extraSmall grey>Query Name</Label>
<Input thin bind:value={query.name} />
<Spacer medium />
<IntegrationQueryEditor <IntegrationQueryEditor
{query} {query}
schema={config[query.queryVerb]} schema={config[query.queryVerb]}
bind:parameters /> bind:parameters />
<Spacer medium /> <Spacer extraLarge />
<Spacer large />
<div class="viewer-controls"> <div class="viewer-controls">
<Button <Button
wide
thin
blue blue
disabled={data.length === 0} disabled={data.length === 0}
on:click={saveQuery}> on:click={saveQuery}>
Save Save Query
</Button> </Button>
<Button wide thin primary on:click={previewQuery}>Run</Button> <Button primary on:click={previewQuery}>Run Query</Button>
</div> </div>
<section class="viewer"> <section class="viewer">
@ -189,10 +180,11 @@
<ExternalDataSourceTable {query} {data} /> <ExternalDataSourceTable {query} {data} />
{:else if tab === 'SCHEMA'} {:else if tab === 'SCHEMA'}
{#each fields as field, idx} {#each fields as field, idx}
<Spacer small />
<div class="field"> <div class="field">
<Input thin type={'text'} bind:value={field.name} /> <Input outline placeholder="Field Name" type={'text'} bind:value={field.name} />
<Select secondary thin bind:value={field.type}> <Select thin border bind:value={field.type}>
<option value={''}>Select an option</option> <option value={''}>Select a field type</option>
<option value={'STRING'}>Text</option> <option value={'STRING'}>Text</option>
<option value={'NUMBER'}>Number</option> <option value={'NUMBER'}>Number</option>
<option value={'BOOLEAN'}>Boolean</option> <option value={'BOOLEAN'}>Boolean</option>
@ -203,7 +195,8 @@
on:click={() => deleteField(idx)} /> on:click={() => deleteField(idx)} />
</div> </div>
{/each} {/each}
<Button thin secondary on:click={newField}>Add Field</Button> <Spacer small />
<Button thin secondary on:click={newField}>Add Field</Button>
{/if} {/if}
</Switcher> </Switcher>
{/if} {/if}
@ -213,11 +206,28 @@
{/if} {/if}
<style> <style>
.input {
width: 300px;
}
.select {
width: 200px;
margin-right: 40px;
}
.props {
display: flex;
flex-direction: row;
margin-left: auto;
align-items: center;
gap: var(--layout-l);
}
.field { .field {
display: grid; display: grid;
grid-gap: 10px;
grid-template-columns: 1fr 1fr 50px; grid-template-columns: 1fr 1fr 50px;
margin-bottom: var(--spacing-m); gap: var(--spacing-l);
} }
a { a {
@ -233,6 +243,16 @@
cursor: pointer; cursor: pointer;
} }
.query-type {
font-family: var(--font-sans);
color: var(--grey-8);
font-size: var(--font-size-s);
}
.query-type-span {
text-transform: uppercase;
}
.preview { .preview {
width: 800px; width: 800px;
height: 100%; height: 100%;
@ -246,32 +266,18 @@
align-items: center; align-items: center;
} }
.queryVerbs {
display: flex;
flex: 1;
font-size: var(--font-size-m);
align-items: center;
margin-left: var(--spacing-l);
}
.queryVerb {
text-transform: capitalize;
margin-right: var(--spacing-m);
color: var(--grey-5);
cursor: pointer;
}
.selected {
color: var(--white);
font-weight: 500;
}
.viewer-controls { .viewer-controls {
display: grid; display: flex;
grid-gap: var(--spacing-m); flex-direction: row;
grid-auto-flow: column; margin-left: auto;
direction: rtl; direction: rtl;
grid-template-columns: 10% 10% 1fr; z-index: 5;
margin-bottom: var(--spacing-m); gap: var(--spacing-m);
min-width: 150px;
}
.viewer {
margin-top: -28px;
z-index: -2;
} }
</style> </style>

View File

@ -20,8 +20,6 @@
} }
</script> </script>
<Heading extraSmall black>Query</Heading>
<Spacer medium />
{#if schema} {#if schema}
{#key query._id} {#key query._id}
@ -33,7 +31,6 @@
readOnly={!editable} readOnly={!editable}
value={query.fields.sql} /> value={query.fields.sql} />
{:else if schema.type === QueryTypes.JSON} {:else if schema.type === QueryTypes.JSON}
<Spacer large />
<Editor <Editor
label="Query" label="Query"
mode="json" mode="json"

View File

@ -21,7 +21,6 @@
query => query._id === $backendUiStore.selectedQueryId query => query._id === $backendUiStore.selectedQueryId
) || { ) || {
datasourceId: $params.selectedDatasource, datasourceId: $params.selectedDatasource,
name: "New Query",
parameters: [], parameters: [],
fields: {}, fields: {},
queryVerb: "read", queryVerb: "read",
@ -36,8 +35,10 @@
<style> <style>
section { section {
background: var(--background); overflow: scroll;
padding: var(--spacing-xl); }
border-radius: var(--border-radius-m); ::-webkit-scrollbar {
width: 0px;
background: transparent; /* make scrollbar transparent */
} }
</style> </style>