merge fixes

This commit is contained in:
Keviin Åberg Kultalahti 2021-05-03 09:24:04 +02:00
commit 27ce375f17
7 changed files with 80 additions and 97 deletions

View File

@ -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,20 +100,18 @@
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}>
<Button <Button
slot="buttons" slot="buttons"
cta cta
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>
<DrawerContent slot="body"> <DrawerContent slot="body">
@ -121,20 +119,15 @@
{#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={queries.find(query => query._id === value._id).parameters}
.parameters} bindings={queryBindableProperties} />
bindings={queryBindableProperties}
/>
{/if} {/if}
<IntegrationQueryEditor <IntegrationQueryEditor
height={200} height={200}
query={value} query={value}
schema={fetchQueryDefinition(value)} schema={fetchQueryDefinition(value)}
datasource={$datasources.list.find( datasource={$datasources.list.find(ds => ds._id === value.datasourceId)}
(ds) => ds._id === value.datasourceId editable={false} />
)}
editable={false}
/>
</Layout> </Layout>
</DrawerContent> </DrawerContent>
</Drawer> </Drawer>
@ -147,12 +140,7 @@
</div> </div>
<ul> <ul>
{#each tables as table} {#each tables as table}
<li <li on:click={() => handleSelected(table)}>{table.label}</li>
class:selected={value === table}
on:click={() => handleSelected(table)}
>
{table.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -161,12 +149,7 @@
</div> </div>
<ul> <ul>
{#each views as view} {#each views as view}
<li <li on:click={() => handleSelected(view)}>{view.label}</li>
class:selected={value === view}
on:click={() => handleSelected(view)}
>
{view.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -175,12 +158,7 @@
</div> </div>
<ul> <ul>
{#each links as link} {#each links as link}
<li <li on:click={() => handleSelected(link)}>{link.label}</li>
class:selected={value === link}
on:click={() => handleSelected(link)}
>
{link.label}
</li>
{/each} {/each}
</ul> </ul>
<Divider size="S" /> <Divider size="S" />
@ -191,8 +169,7 @@
{#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}
@ -205,12 +182,7 @@
</div> </div>
<ul> <ul>
{#each otherSources as source} {#each otherSources as source}
<li <li on:click={() => handleSelected(source)}>{source.label}</li>
class:selected={value === source}
on:click={() => handleSelected(source)}
>
{source.label}
</li>
{/each} {/each}
</ul> </ul>
{/if} {/if}
@ -246,15 +218,15 @@
cursor: pointer; cursor: pointer;
margin: 0px; margin: 0px;
padding: var(--spacing-s) var(--spacing-m); padding: var(--spacing-s) var(--spacing-m);
font-size: var(--font-size-xs); font-size: var(--font-size-m);
} }
.selected { .selected {
background-color: var(--grey-4); color: var(--spectrum-global-color-blue-600);
} }
li:hover { li:hover {
background-color: var(--grey-4); background-color: var(--spectrum-global-color-gray-200);
} }
.drawer-contents { .drawer-contents {

View File

@ -1,7 +1,14 @@
<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 { Icon, Button, Popover, Layout, DrawerContent } from "@budibase/bbui" import {
Icon,
Button,
Layout,
DrawerContent,
ActionMenu,
MenuItem,
} from "@budibase/bbui"
import actionTypes from "./actions" import actionTypes from "./actions"
import { generate } from "shortid" import { generate } from "shortid"
@ -22,8 +29,6 @@
} }
} }
let addActionButton
let addActionDropdown
let selectedAction = actions?.length ? actions[0] : null let selectedAction = actions?.length ? actions[0] : null
$: selectedActionComponent = $: selectedActionComponent =
@ -53,7 +58,6 @@
} }
actions = [...actions, newAction] actions = [...actions, newAction]
selectedAction = newAction selectedAction = newAction
addActionDropdown.hide()
} }
const selectAction = (action) => () => { const selectAction = (action) => () => {
@ -71,24 +75,14 @@
<DrawerContent> <DrawerContent>
<div class="actions-list" slot="sidebar"> <div class="actions-list" slot="sidebar">
<Layout> <Layout>
<div bind:this={addActionButton}> <ActionMenu>
<Button wide secondary on:click={addActionDropdown.show}> <Button slot="control" secondary>Add Action</Button>
Add Action {#each actionTypes as actionType}
</Button> <MenuItem on:click={addAction(actionType)}>
</div> {actionType.name}
<Popover </MenuItem>
bind:this={addActionDropdown} {/each}
anchor={addActionButton} </ActionMenu>
align="right"
>
<div class="available-actions-container">
{#each actionTypes as actionType}
<div class="available-action" on:click={addAction(actionType)}>
<span>{actionType.name}</span>
</div>
{/each}
</div>
</Popover>
{#if actions && actions.length > 0} {#if actions && actions.length > 0}
<div <div
@ -148,7 +142,7 @@
.action-header { .action-header {
margin-bottom: var(--spacing-m); margin-bottom: var(--spacing-m);
font-size: var(--font-size-xs); font-size: var(--font-size-s);
color: var(--grey-7); color: var(--grey-7);
font-weight: 500; font-weight: 500;
} }
@ -161,7 +155,7 @@
.available-action { .available-action {
padding: var(--spacing-s); padding: var(--spacing-s);
font-size: var(--font-size-xs); font-size: var(--font-size-s);
cursor: pointer; cursor: pointer;
} }

View File

@ -51,7 +51,7 @@
} }
</script> </script>
<Button primary on:click={drawer.show}>Define Actions</Button> <Button secondary on:click={drawer.show}>Define Actions</Button>
<Drawer bind:this={drawer} title={'Actions'}> <Drawer bind:this={drawer} title={'Actions'}>
<svelte:fragment slot="description"> <svelte:fragment slot="description">
Define what actions to run. Define what actions to run.

View File

@ -35,7 +35,7 @@
} }
</script> </script>
<Button secondary wide on:click={drawer.show}>Define Filters</Button> <Button secondary on:click={drawer.show}>Define Filters</Button>
<Drawer bind:this={drawer} title="Filtering"> <Drawer bind:this={drawer} title="Filtering">
<Button cta slot="buttons" on:click={saveFilter}>Save</Button> <Button cta slot="buttons" on:click={saveFilter}>Save</Button>
<DrawerContent slot="body"> <DrawerContent slot="body">

View File

@ -80,11 +80,11 @@
"field/link": RelationshipFieldSelect, "field/link": RelationshipFieldSelect,
} }
const getControl = type => { const getControl = (type) => {
return controlMap[type] return controlMap[type]
} }
const canRenderControl = setting => { const canRenderControl = (setting) => {
const control = getControl(setting?.type) const control = getControl(setting?.type)
if (!control) { if (!control) {
return false return false
@ -95,7 +95,7 @@
return true return true
} }
const onInstanceNameChange = name => { const onInstanceNameChange = (name) => {
onChange("_instanceName", name) onChange("_instanceName", name)
} }
@ -103,13 +103,13 @@
const form = findClosestMatchingComponent( const form = findClosestMatchingComponent(
$currentAsset.props, $currentAsset.props,
componentInstance._id, componentInstance._id,
component => component._component.endsWith("/form") (component) => component._component.endsWith("/form")
) )
const dataSource = form?.dataSource const dataSource = form?.dataSource
const fields = makeDatasourceFormComponents(dataSource) const fields = makeDatasourceFormComponents(dataSource)
onChange( onChange(
"_children", "_children",
fields.map(field => field.json()) fields.map((field) => field.json())
) )
} }
</script> </script>
@ -123,7 +123,8 @@
label={def.label} label={def.label}
key={def.key} key={def.key}
value={get(assetInstance, def.key)} value={get(assetInstance, def.key)}
onChange={val => onScreenPropChange(def.key, val)} /> onChange={(val) => onScreenPropChange(def.key, val)}
/>
{/each} {/each}
{/if} {/if}
@ -134,7 +135,8 @@
label="Name" label="Name"
key="_instanceName" key="_instanceName"
value={componentInstance._instanceName} value={componentInstance._instanceName}
onChange={onInstanceNameChange} /> onChange={onInstanceNameChange}
/>
{/if} {/if}
{#if settings && settings.length > 0} {#if settings && settings.length > 0}
@ -145,10 +147,12 @@
control={getControl(setting.type)} control={getControl(setting.type)}
label={setting.label} label={setting.label}
key={setting.key} key={setting.key}
value={componentInstance[setting.key] ?? componentInstance[setting.key]?.defaultValue} value={componentInstance[setting.key] ??
componentInstance[setting.key]?.defaultValue}
{componentInstance} {componentInstance}
onChange={val => onChange(setting.key, val)} onChange={(val) => onChange(setting.key, val)}
props={{ options: setting.options, placeholder: setting.placeholder }} /> props={{ options: setting.options, placeholder: setting.placeholder }}
/>
{/if} {/if}
{/each} {/each}
{:else} {:else}
@ -157,10 +161,12 @@
</div> </div>
{/if} {/if}
{#if componentDefinition?.component?.endsWith('/fieldgroup')} {#if componentDefinition?.component?.endsWith("/fieldgroup")}
<Button secondary wide on:click={() => confirmResetFieldsDialog?.show()}> <div class="buttonWrapper">
Update Form Fields <Button secondary wide on:click={() => confirmResetFieldsDialog?.show()}>
</Button> Update Form Fields
</Button>
</div>
{/if} {/if}
</div> </div>
<ConfirmDialog <ConfirmDialog
@ -168,7 +174,8 @@
body={`All components inside this group will be deleted and replaced with fields to match the schema. Are you sure you want to update this Field Group?`} body={`All components inside this group will be deleted and replaced with fields to match the schema. Are you sure you want to update this Field Group?`}
okText="Update" okText="Update"
onOk={resetFormFields} onOk={resetFormFields}
title="Confirm Form Field Update" /> title="Confirm Form Field Update"
/>
<style> <style>
.settings-view-container { .settings-view-container {
@ -183,4 +190,9 @@
margin-top: var(--spacing-m); margin-top: var(--spacing-m);
color: var(--grey-6); color: var(--grey-6);
} }
.buttonWrapper {
margin-top: 10px;
display: flex;
flex-direction: column;
}
</style> </style>

View File

@ -24,7 +24,10 @@ const addBuilderPreviewStyles = (node, styleString, componentId) => {
if (componentId === get(builderStore).selectedComponentId) { if (componentId === get(builderStore).selectedComponentId) {
const style = window.getComputedStyle(node) const style = window.getComputedStyle(node)
const property = style?.display === "table-row" ? "outline" : "border" const property = style?.display === "table-row" ? "outline" : "border"
return styleString + `;${property}: 2px solid #4285f4 !important;` return (
styleString +
`;${property}: 2px solid #4285f4 !important; border-radius: 4px !important;`
)
} else { } else {
return styleString return styleString
} }

View File

@ -103,6 +103,8 @@
} }
</script> </script>
<Provider {actions} data={dataContext}> <div use:styleable={$component.styles}>
<slot /> <Provider {actions} data={dataContext}>
</Provider> <slot />
</Provider>
</div>