rename DrawerContentWithSidebar to DrawerContent and add sidebar check

This commit is contained in:
Keviin Åberg Kultalahti 2021-04-28 14:42:44 +02:00
parent 6beb6c4f44
commit c82d171106
5 changed files with 54 additions and 41 deletions

View File

@ -1,8 +1,14 @@
<div class="drawer-contents"> <div class="drawer-contents">
<div class="container" data-cy="binding-dropdown-modal"> <div
class:no-sidebar={!$$slots.sidebar}
class="container"
data-cy="binding-dropdown-modal"
>
{#if $$slots.sidebar}
<div class="sidebar"> <div class="sidebar">
<slot name="sidebar" /> <slot name="sidebar" />
</div> </div>
{/if}
<div class="main"> <div class="main">
<slot name="main" /> <slot name="main" />
</div> </div>
@ -19,6 +25,9 @@
display: grid; display: grid;
grid-template-columns: 290px 1fr; grid-template-columns: 290px 1fr;
} }
.no-sidebar {
grid-template-columns: 1fr;
}
.sidebar { .sidebar {
border-right: var(--border-light); border-right: var(--border-light);
overflow: auto; overflow: auto;

View File

@ -10,7 +10,7 @@ export { default as Select } from "./Form/Select.svelte"
export { default as Combobox } from "./Form/Combobox.svelte" export { default as Combobox } from "./Form/Combobox.svelte"
export { default as Dropzone } from "./Form/Dropzone.svelte" export { default as Dropzone } from "./Form/Dropzone.svelte"
export { default as Drawer } from "./Drawer/Drawer.svelte" export { default as Drawer } from "./Drawer/Drawer.svelte"
export { default as DrawerContentWithSidebar } from "./Drawer/DrawerContentWithSidebar.svelte" export { default as DrawerContent } from "./Drawer/DrawerContent.svelte"
export { default as Avatar } from "./Avatar/Avatar.svelte" export { default as Avatar } from "./Avatar/Avatar.svelte"
export { default as ActionButton } from "./ActionButton/ActionButton.svelte" export { default as ActionButton } from "./ActionButton/ActionButton.svelte"
export { default as ActionGroup } from "./ActionGroup/ActionGroup.svelte" export { default as ActionGroup } from "./ActionGroup/ActionGroup.svelte"

View File

@ -1,6 +1,6 @@
<script> <script>
import groupBy from "lodash/fp/groupBy" import groupBy from "lodash/fp/groupBy"
import { Search, TextArea, Heading, Label, DrawerContentWithSidebar, Layout } from "@budibase/bbui" import { Search, TextArea, Heading, Label, DrawerContent, Layout } from "@budibase/bbui"
import { createEventDispatcher } from "svelte" import { createEventDispatcher } from "svelte"
import { isValid } from "@budibase/string-templates" import { isValid } from "@budibase/string-templates"
import { import {
@ -57,7 +57,7 @@
} }
</script> </script>
<DrawerContentWithSidebar> <DrawerContent>
<svelte:fragment slot="sidebar"> <svelte:fragment slot="sidebar">
<Layout> <Layout>
<Search placeholder="Search" bind:value={search} /> <Search placeholder="Search" bind:value={search} />
@ -121,7 +121,7 @@
</p> </p>
{/if} {/if}
</div> </div>
</DrawerContentWithSidebar> </DrawerContent>
<style> <style>
.main { .main {

View File

@ -2,10 +2,10 @@
import { getBindableProperties } from "builderStore/dataBinding" import { getBindableProperties } from "builderStore/dataBinding"
import { import {
Button, Button,
Icon,
Popover, Popover,
Divider, Divider,
Select, Select,
Layout,
Spacer, Spacer,
Heading, Heading,
Drawer, Drawer,
@ -30,7 +30,7 @@
export let showAllQueries export let showAllQueries
$: text = value?.label ?? "Choose an option" $: text = value?.label ?? "Choose an option"
$: tables = $tablesStore.list.map(m => ({ $: tables = $tablesStore.list.map((m) => ({
label: m.name, label: m.name,
tableId: m._id, tableId: m._id,
type: "table", type: "table",
@ -46,9 +46,9 @@
}, []) }, [])
$: queries = $queriesStore.list $: queries = $queriesStore.list
.filter( .filter(
query => showAllQueries || query.queryVerb === "read" || query.readable (query) => showAllQueries || query.queryVerb === "read" || query.readable
) )
.map(query => ({ .map((query) => ({
label: query.name, label: query.name,
name: query.name, name: query.name,
tableId: query._id, tableId: query._id,
@ -61,15 +61,15 @@
$currentAsset, $currentAsset,
$store.selectedComponentId $store.selectedComponentId
) )
$: queryBindableProperties = bindableProperties.map(property => ({ $: queryBindableProperties = bindableProperties.map((property) => ({
...property, ...property,
category: property.type === "instance" ? "Component" : "Table", category: property.type === "instance" ? "Component" : "Table",
label: property.readableBinding, label: property.readableBinding,
path: property.readableBinding, path: property.readableBinding,
})) }))
$: links = bindableProperties $: links = bindableProperties
.filter(x => x.fieldSchema?.type === "link") .filter((x) => x.fieldSchema?.type === "link")
.map(property => { .map((property) => {
return { return {
providerId: property.providerId, providerId: property.providerId,
label: property.readableBinding, label: property.readableBinding,
@ -89,7 +89,7 @@
} }
function fetchQueryDefinition(query) { function fetchQueryDefinition(query) {
const source = $datasources.list.find(ds => ds._id === query.datasourceId) const source = $datasources.list.find((ds) => ds._id === query.datasourceId)
.source .source
return $integrations[source].query[query.queryVerb] return $integrations[source].query[query.queryVerb]
} }
@ -100,19 +100,21 @@
readonly readonly
value={text} value={text}
options={[text]} options={[text]}
on:click={dropdownRight.show} /> on:click={dropdownRight.show}
{#if value?.type === 'query'} />
{#if value?.type === "query"}
<i class="ri-settings-5-line" on:click={drawer.show} /> <i class="ri-settings-5-line" on:click={drawer.show} />
<Drawer title={'Query Parameters'} bind:this={drawer}> <Drawer title={"Query Parameters"} bind:this={drawer}>
<div slot="buttons"> <div slot="buttons">
<Button <Button
blue blue
thin thin
on:click={() => { on:click={() => {
notifications.success('Query parameters saved.') notifications.success("Query parameters saved.")
handleSelected(value) handleSelected(value)
drawer.hide() drawer.hide()
}}> }}
>
Save Save
</Button> </Button>
</div> </div>
@ -120,17 +122,20 @@
{#if value.parameters.length > 0} {#if value.parameters.length > 0}
<ParameterBuilder <ParameterBuilder
bind:customParams={value.queryParams} bind:customParams={value.queryParams}
parameters={queries.find(query => query._id === value._id).parameters} parameters={queries.find((query) => query._id === value._id)
bindings={queryBindableProperties} /> .parameters}
bindings={queryBindableProperties}
/>
{/if} {/if}
<!-- <Spacer large />-->
<IntegrationQueryEditor <IntegrationQueryEditor
height={200} height={200}
query={value} query={value}
schema={fetchQueryDefinition(value)} schema={fetchQueryDefinition(value)}
datasource={$datasources.list.find(ds => ds._id === value.datasourceId)} datasource={$datasources.list.find(
editable={false} /> (ds) => ds._id === value.datasourceId
<Spacer large /> )}
editable={false}
/>
</div> </div>
</Drawer> </Drawer>
{/if} {/if}
@ -144,7 +149,8 @@
{#each tables as table} {#each tables as table}
<li <li
class:selected={value === table} class:selected={value === table}
on:click={() => handleSelected(table)}> on:click={() => handleSelected(table)}
>
{table.label} {table.label}
</li> </li>
{/each} {/each}
@ -157,7 +163,8 @@
{#each views as view} {#each views as view}
<li <li
class:selected={value === view} class:selected={value === view}
on:click={() => handleSelected(view)}> on:click={() => handleSelected(view)}
>
{view.label} {view.label}
</li> </li>
{/each} {/each}
@ -170,7 +177,8 @@
{#each links as link} {#each links as link}
<li <li
class:selected={value === link} class:selected={value === link}
on:click={() => handleSelected(link)}> on:click={() => handleSelected(link)}
>
{link.label} {link.label}
</li> </li>
{/each} {/each}
@ -183,7 +191,8 @@
{#each queries as query} {#each queries as query}
<li <li
class:selected={value === query} class:selected={value === query}
on:click={() => handleSelected(query)}> on:click={() => handleSelected(query)}
>
{query.label} {query.label}
</li> </li>
{/each} {/each}
@ -198,7 +207,8 @@
{#each otherSources as source} {#each otherSources as source}
<li <li
class:selected={value === source} class:selected={value === source}
on:click={() => handleSelected(source)}> on:click={() => handleSelected(source)}
>
{source.label} {source.label}
</li> </li>
{/each} {/each}

View File

@ -1,13 +1,7 @@
<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 { import { Icon, Button, Popover, Spacer, DrawerContent } from "@budibase/bbui"
Icon,
Button,
Popover,
Spacer,
DrawerContentWithSidebar,
} from "@budibase/bbui"
import actionTypes from "./actions" import actionTypes from "./actions"
import { generate } from "shortid" import { generate } from "shortid"
@ -74,7 +68,7 @@
} }
</script> </script>
<DrawerContentWithSidebar> <DrawerContent>
<div class="actions-list" slot="sidebar"> <div class="actions-list" slot="sidebar">
<div> <div>
<div bind:this={addActionButton}> <div bind:this={addActionButton}>
@ -133,7 +127,7 @@
</div> </div>
{/if} {/if}
</div> </div>
</DrawerContentWithSidebar> </DrawerContent>
<div class="actions-container"> <div class="actions-container">
<div class="action-config"> <div class="action-config">
{#if selectedAction} {#if selectedAction}