Add initial grid block, and update grid to keep indentation consistent when row expansion is disabled

This commit is contained in:
Andrew Kingston 2023-06-07 15:50:38 +01:00
parent 61a143628b
commit 752dd93d84
6 changed files with 83 additions and 17 deletions

View File

@ -3,6 +3,7 @@
"name": "Blocks", "name": "Blocks",
"icon": "Article", "icon": "Article",
"children": [ "children": [
"gridblock",
"tableblock", "tableblock",
"cardsblock", "cardsblock",
"repeaterblock", "repeaterblock",

View File

@ -5225,5 +5225,25 @@
"type": "schema", "type": "schema",
"suffix": "repeater" "suffix": "repeater"
} }
},
"gridblock": {
"block": true,
"name": "Grid block",
"icon": "Table",
"styles": [
"size"
],
"size": {
"width": 600,
"height": 400
},
"settings": [
{
"type": "table",
"label": "Table",
"key": "table",
"required": true
}
]
} }
} }

View File

@ -0,0 +1,37 @@
<script>
// NOTE: this is not a block - it's just named as such to avoid confusing users,
// because it functions similarly to one
import { getContext } from "svelte"
import { Grid } from "@budibase/frontend-core"
export let table
export let allowAddRows
export let allowEditRows
export let allowDeleteRows
const component = getContext("component")
const { styleable, API } = getContext("sdk")
</script>
<div use:styleable={$component.styles}>
<Grid
tableId={table?.tableId}
{API}
{allowAddRows}
{allowEditRows}
{allowDeleteRows}
showControls={false}
allowAddColumns={false}
allowEditColumns={false}
allowExpandRows={false}
/>
</div>
<style>
div {
display: flex;
flex-direction: column;
align-items: stretch;
border: 1px solid var(--spectrum-global-color-gray-300);
}
</style>

View File

@ -36,6 +36,7 @@ export { default as markdownviewer } from "./MarkdownViewer.svelte"
export { default as embeddedmap } from "./embedded-map/EmbeddedMap.svelte" export { default as embeddedmap } from "./embedded-map/EmbeddedMap.svelte"
export { default as grid } from "./Grid.svelte" export { default as grid } from "./Grid.svelte"
export { default as sidepanel } from "./SidePanel.svelte" export { default as sidepanel } from "./SidePanel.svelte"
export { default as gridblock } from "./GridBlock.svelte"
export * from "./charts" export * from "./charts"
export * from "./forms" export * from "./forms"
export * from "./table" export * from "./table"

View File

@ -70,10 +70,12 @@
color="var(--spectrum-global-color-red-400)" color="var(--spectrum-global-color-red-400)"
/> />
</div> </div>
{:else if $config.allowExpandRows} {:else}
<div <div
class="expand" class="expand"
class:visible={!disableExpand && (rowFocused || rowHovered)} class:visible={$config.allowExpandRows &&
!disableExpand &&
(rowFocused || rowHovered)}
> >
<Icon name="Maximize" hoverable size="S" on:click={expand} /> <Icon name="Maximize" hoverable size="S" on:click={expand} />
</div> </div>

View File

@ -43,6 +43,9 @@
export let stripeRows = false export let stripeRows = false
export let collaboration = true export let collaboration = true
export let showAvatars = true export let showAvatars = true
export let showControls = true
allowExpandRows = false
// Unique identifier for DOM nodes inside this instance // Unique identifier for DOM nodes inside this instance
const rand = Math.random() const rand = Math.random()
@ -117,6 +120,7 @@
class:stripe={$config.stripeRows} class:stripe={$config.stripeRows}
style="--row-height:{$rowHeight}px; --default-row-height:{DefaultRowHeight}px; --gutter-width:{GutterWidth}px; --max-cell-render-height:{MaxCellRenderHeight}px; --max-cell-render-width-overflow:{MaxCellRenderWidthOverflow}px; --content-lines:{$contentLines};" style="--row-height:{$rowHeight}px; --default-row-height:{DefaultRowHeight}px; --gutter-width:{GutterWidth}px; --max-cell-render-height:{MaxCellRenderHeight}px; --max-cell-render-width-overflow:{MaxCellRenderWidthOverflow}px; --content-lines:{$contentLines};"
> >
{#if showControls}
<div class="controls"> <div class="controls">
<div class="controls-left"> <div class="controls-left">
<AddRowButton /> <AddRowButton />
@ -133,6 +137,7 @@
{/if} {/if}
</div> </div>
</div> </div>
{/if}
{#if $loaded} {#if $loaded}
<div class="grid-data-outer" use:clickOutside={ui.actions.blur}> <div class="grid-data-outer" use:clickOutside={ui.actions.blur}>
<div class="grid-data-inner"> <div class="grid-data-inner">