Make workflow builder scrollable and improve UX around selecting and editing worflow blocks

This commit is contained in:
Andrew Kingston 2020-09-10 07:46:01 +01:00
parent 4d118b6eed
commit 6dcaa3c4d8
6 changed files with 100 additions and 64 deletions

View File

@ -15,7 +15,7 @@
}
</script>
<div class="bb-margin-xl block-field">
<div class="block-field">
<select class="budibase__input" bind:value={value.model}>
{#each $backendUiStore.models as model}
<option value={model}>{model.name}</option>

View File

@ -14,44 +14,49 @@
: []
</script>
<label class="selected-label">{workflowBlock.type}: {workflowBlock.name}</label>
{#each workflowParams as [parameter, type]}
<div class="block-field">
<label class="label">{parameter}</label>
{#if Array.isArray(type)}
<Select bind:value={workflowBlock.args[parameter]} thin>
{#each type as option}
<option value={option}>{option}</option>
{/each}
</Select>
{:else if type === 'component'}
<ComponentSelector bind:value={workflowBlock.args[parameter]} />
{:else if type === 'accessLevel'}
<Select bind:value={workflowBlock.args[parameter]} thin secondary>
<option value="ADMIN">Admin</option>
<option value="POWER_USER">Power User</option>
</Select>
{:else if type === 'password'}
<Input type="password" thin bind:value={workflowBlock.args[parameter]} />
{:else if type === 'number'}
<Input type="number" thin bind:value={workflowBlock.args[parameter]} />
{:else if type === 'longText'}
<TextArea
type="text"
thin
bind:value={workflowBlock.args[parameter]}
label="" />
{:else if type === 'model'}
<ModelSelector bind:value={workflowBlock.args[parameter]} />
{:else if type === 'record'}
<RecordSelector value={workflowBlock.args[parameter]} />
{:else if type === 'string'}
<Input type="text" thin bind:value={workflowBlock.args[parameter]} />
{/if}
</div>
{/each}
<div class="container">
<!-- <label class="selected-label">{workflowBlock.type}: {workflowBlock.name}</label> -->
{#each workflowParams as [parameter, type]}
<div class="block-field">
<label class="label">{parameter}</label>
{#if Array.isArray(type)}
<Select bind:value={workflowBlock.args[parameter]} thin secondary>
{#each type as option}
<option value={option}>{option}</option>
{/each}
</Select>
{:else if type === 'component'}
<ComponentSelector bind:value={workflowBlock.args[parameter]} />
{:else if type === 'accessLevel'}
<Select bind:value={workflowBlock.args[parameter]} thin secondary>
<option value="ADMIN">Admin</option>
<option value="POWER_USER">Power User</option>
</Select>
{:else if type === 'password'}
<Input
type="password"
thin
bind:value={workflowBlock.args[parameter]} />
{:else if type === 'number'}
<Input type="number" thin bind:value={workflowBlock.args[parameter]} />
{:else if type === 'longText'}
<TextArea type="text" thin bind:value={workflowBlock.args[parameter]} />
{:else if type === 'model'}
<ModelSelector bind:value={workflowBlock.args[parameter]} />
{:else if type === 'record'}
<RecordSelector value={workflowBlock.args[parameter]} />
{:else if type === 'string'}
<Input type="text" thin bind:value={workflowBlock.args[parameter]} />
{/if}
</div>
{/each}
</div>
<style>
.container {
margin-top: -20px;
}
.block-field {
display: grid;
}

View File

@ -37,31 +37,41 @@
<section>
<Flowchart blocks={uiTree} {onSelect} />
<footer>
{#if selectedWorkflow}
<button
class:highlighted={workflowLive}
class:hoverable={workflowLive}
class="stop-button hoverable">
<i class="ri-stop-fill" on:click={() => setWorkflowLive(false)} />
</button>
<button
class:highlighted={!workflowLive}
class:hoverable={!workflowLive}
class="play-button hoverable"
data-cy="activate-workflow"
on:click={() => setWorkflowLive(true)}>
<i class="ri-play-fill" />
</button>
{/if}
</footer>
</section>
<footer>
{#if selectedWorkflow}
<button
class:highlighted={workflowLive}
class:hoverable={workflowLive}
class="stop-button hoverable">
<i class="ri-stop-fill" on:click={() => setWorkflowLive(false)} />
</button>
<button
class:highlighted={!workflowLive}
class:hoverable={!workflowLive}
class="play-button hoverable"
data-cy="activate-workflow"
on:click={() => setWorkflowLive(true)}>
<i class="ri-play-fill" />
</button>
{/if}
</footer>
<style>
section {
display: flex;
flex-direction: row;
justify-content: center;
align-items: flex-start;
overflow: auto;
height: 100%;
position: relative;
}
footer {
position: absolute;
bottom: 0;
right: 0;
bottom: 20px;
right: 30px;
display: flex;
align-items: flex-end;
}
@ -77,7 +87,9 @@
display: flex;
align-items: center;
justify-content: center;
margin-right: 24px;
}
footer > button:first-child {
margin-right: 20px;
}
.play-button.highlighted {

View File

@ -7,7 +7,7 @@
</script>
<section class="canvas">
{#each blocks as block, idx}
{#each blocks as block, idx (block.id)}
<FlowItem {onSelect} {block} />
{#if idx !== blocks.length - 1}
<Arrow />
@ -16,6 +16,11 @@
</section>
<style>
section {
position: absolute;
padding: 20px 40px;
}
.canvas {
display: flex;
align-items: center;

View File

@ -1,15 +1,27 @@
<script>
import { fade } from "svelte/transition"
import { workflowStore } from "builderStore"
export let onSelect
export let block
let selected = false
function selectBlock() {
onSelect(block)
}
$: selected =
$workflowStore.selectedWorkflowBlock != null &&
$workflowStore.selectedWorkflowBlock.id === block.id
console.log(selected)
</script>
<div transition:fade class={`${block.type} hoverable`} on:click={selectBlock}>
<div
transition:fade
class={`${block.type} hoverable`}
class:selected
on:click={selectBlock}>
<header>
{#if block.type === 'TRIGGER'}
<i class="ri-lightbulb-fill" />
@ -32,8 +44,8 @@
div {
width: 320px;
padding: 20px;
border-radius: 5px;
transition: 0.3s all;
border-radius: var(--border-radius-m);
transition: 0.3s all ease;
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.08);
background-color: var(--ink);
font-size: 16px;
@ -69,9 +81,12 @@
p {
color: inherit;
margin-bottom: 0;
}
div.selected,
div:hover {
transform: scale(1.05);
transform: scale(1.1);
box-shadow: 0 4px 30px 0 rgba(57, 60, 68, 0.15);
}
</style>

View File

@ -35,7 +35,6 @@
.content {
flex: 1 1 auto;
margin: 20px 40px;
}
.nav {