Improve sheet loading states

This commit is contained in:
Andrew Kingston 2023-04-13 14:30:01 +01:00
parent fa0cc17682
commit f7f1ee49a6
12 changed files with 45 additions and 22 deletions

View File

@ -4,6 +4,7 @@
import ManageAccessModal from "../modals/ManageAccessModal.svelte" import ManageAccessModal from "../modals/ManageAccessModal.svelte"
export let resourceId export let resourceId
export let disabled = false
let modal let modal
let resourcePermissions let resourcePermissions
@ -14,7 +15,7 @@
} }
</script> </script>
<ActionButton icon="LockClosed" quiet on:click={openDropdown}> <ActionButton icon="LockClosed" quiet on:click={openDropdown} {disabled}>
Manage access Manage access
</ActionButton> </ActionButton>
<Modal bind:this={modal}> <Modal bind:this={modal}>

View File

@ -3,11 +3,11 @@
import { Modal, ActionButton } from "@budibase/bbui" import { Modal, ActionButton } from "@budibase/bbui"
import CreateViewModal from "../../modals/CreateViewModal.svelte" import CreateViewModal from "../../modals/CreateViewModal.svelte"
const { rows, columns } = getContext("sheet") const { rows, columns, loaded } = getContext("sheet")
let modal let modal
$: disabled = !$columns.length || !$rows.length $: disabled = !$loaded || !$columns.length || !$rows.length
</script> </script>
<ActionButton {disabled} icon="CollectionAdd" quiet on:click={modal.show}> <ActionButton {disabled} icon="CollectionAdd" quiet on:click={modal.show}>

View File

@ -2,10 +2,10 @@
import ExportButton from "../ExportButton.svelte" import ExportButton from "../ExportButton.svelte"
import { getContext } from "svelte" import { getContext } from "svelte"
const { rows, columns, tableId, sort, selectedRows, filter } = const { rows, columns, tableId, sort, selectedRows, filter, loaded } =
getContext("sheet") getContext("sheet")
$: disabled = !$rows.length || !$columns.length $: disabled = !$loaded || !$rows.length || !$columns.length
$: selectedRowArray = Object.keys($selectedRows).map(id => ({ _id: id })) $: selectedRowArray = Object.keys($selectedRows).map(id => ({ _id: id }))
</script> </script>

View File

@ -2,7 +2,7 @@
import TableFilterButton from "../TableFilterButton.svelte" import TableFilterButton from "../TableFilterButton.svelte"
import { getContext } from "svelte" import { getContext } from "svelte"
const { columns, config, filter, table } = getContext("sheet") const { columns, config, filter, table, loaded } = getContext("sheet")
const onFilter = e => { const onFilter = e => {
filter.set(e.detail || []) filter.set(e.detail || [])
@ -14,7 +14,7 @@
schema={$table?.schema} schema={$table?.schema}
filters={$filter} filters={$filter}
on:change={onFilter} on:change={onFilter}
disabled={!$columns.length} disabled={!$loaded || !$columns.length}
tableId={$config.tableId} tableId={$config.tableId}
/> />
{/key} {/key}

View File

@ -2,7 +2,11 @@
import ImportButton from "../ImportButton.svelte" import ImportButton from "../ImportButton.svelte"
import { getContext } from "svelte" import { getContext } from "svelte"
const { rows, tableId } = getContext("sheet") const { rows, tableId, loaded } = getContext("sheet")
</script> </script>
<ImportButton tableId={$tableId} on:importrows={rows.actions.refreshData} /> <ImportButton
tableId={$tableId}
on:importrows={rows.actions.refreshData}
disabled={!$loaded}
/>

View File

@ -2,7 +2,7 @@
import ManageAccessButton from "../ManageAccessButton.svelte" import ManageAccessButton from "../ManageAccessButton.svelte"
import { getContext } from "svelte" import { getContext } from "svelte"
const { config } = getContext("sheet") const { config, loaded } = getContext("sheet")
</script> </script>
<ManageAccessButton resourceId={$config.tableId} /> <ManageAccessButton disabled={!$loaded} resourceId={$config.tableId} />

View File

@ -2,7 +2,7 @@
import { ActionButton } from "@budibase/bbui" import { ActionButton } from "@budibase/bbui"
import { getContext } from "svelte" import { getContext } from "svelte"
const { config, dispatch } = getContext("sheet") const { config, dispatch, loaded } = getContext("sheet")
</script> </script>
<ActionButton <ActionButton
@ -10,7 +10,7 @@
quiet quiet
size="M" size="M"
on:click={() => dispatch("add-column")} on:click={() => dispatch("add-column")}
disabled={!$config.allowAddColumns} disabled={!$loaded || !$config.allowAddColumns}
> >
Create column Create column
</ActionButton> </ActionButton>

View File

@ -2,7 +2,8 @@
import { ActionButton } from "@budibase/bbui" import { ActionButton } from "@budibase/bbui"
import { getContext } from "svelte" import { getContext } from "svelte"
const { dispatch, columns, stickyColumn, config } = getContext("sheet") const { dispatch, columns, stickyColumn, config, loaded } =
getContext("sheet")
</script> </script>
<ActionButton <ActionButton
@ -10,7 +11,9 @@
quiet quiet
size="M" size="M"
on:click={() => dispatch("add-row")} on:click={() => dispatch("add-row")}
disabled={!$config.allowAddRows || (!$columns.length && !$stickyColumn)} disabled={!loaded ||
!$config.allowAddRows ||
(!$columns.length && !$stickyColumn)}
> >
Create row Create row
</ActionButton> </ActionButton>

View File

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
import { ActionButton, Popover, Toggle } from "@budibase/bbui" import { ActionButton, Popover, Toggle } from "@budibase/bbui"
const { columns } = getContext("sheet") const { columns, loaded } = getContext("sheet")
let open = false let open = false
let anchor let anchor
@ -46,7 +46,7 @@
size="M" size="M"
on:click={() => (open = !open)} on:click={() => (open = !open)}
selected={open || anyHidden} selected={open || anyHidden}
disabled={!$columns.length} disabled={!$loaded || !$columns.length}
> >
Hide columns Hide columns
</ActionButton> </ActionButton>

View File

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
import { ActionButton, Popover } from "@budibase/bbui" import { ActionButton, Popover } from "@budibase/bbui"
const { rowHeight } = getContext("sheet") const { rowHeight, loaded } = getContext("sheet")
const sizeOptions = [ const sizeOptions = [
{ {
label: "Small", label: "Small",
@ -29,6 +29,7 @@
size="M" size="M"
on:click={() => (open = !open)} on:click={() => (open = !open)}
selected={open} selected={open}
disabled={!$loaded}
> >
Row height Row height
</ActionButton> </ActionButton>

View File

@ -2,7 +2,7 @@
import { getContext } from "svelte" import { getContext } from "svelte"
import { ActionButton, Popover, Select } from "@budibase/bbui" import { ActionButton, Popover, Select } from "@budibase/bbui"
const { sort, visibleColumns, stickyColumn } = getContext("sheet") const { sort, visibleColumns, stickyColumn, loaded } = getContext("sheet")
const orderOptions = [ const orderOptions = [
{ label: "A-Z", value: "ascending" }, { label: "A-Z", value: "ascending" },
{ label: "Z-A", value: "descending" }, { label: "Z-A", value: "descending" },
@ -67,7 +67,7 @@
size="M" size="M"
on:click={() => (open = !open)} on:click={() => (open = !open)}
selected={open || $sort.column} selected={open || $sort.column}
disabled={!columnOptions.length} disabled={!$loaded || !columnOptions.length}
> >
Sort Sort
</ActionButton> </ActionButton>

View File

@ -14,7 +14,7 @@
import StickyColumn from "./StickyColumn.svelte" import StickyColumn from "./StickyColumn.svelte"
import UserAvatars from "./UserAvatars.svelte" import UserAvatars from "./UserAvatars.svelte"
import KeyboardManager from "../overlays/KeyboardManager.svelte" import KeyboardManager from "../overlays/KeyboardManager.svelte"
import { clickOutside } from "@budibase/bbui" import { clickOutside, ProgressCircle } from "@budibase/bbui"
import { import {
MaxCellRenderHeight, MaxCellRenderHeight,
MaxCellRenderWidthOverflow, MaxCellRenderWidthOverflow,
@ -119,6 +119,10 @@
</div> </div>
</div> </div>
</div> </div>
{:else}
<div class="sheet-loading">
<ProgressCircle />
</div>
{/if} {/if}
<KeyboardManager /> <KeyboardManager />
</div> </div>
@ -132,6 +136,7 @@
align-items: stretch; align-items: stretch;
position: relative; position: relative;
overflow: hidden; overflow: hidden;
background: var(--cell-background);
/* Variables */ /* Variables */
--cell-background: var(--spectrum-global-color-gray-50); --cell-background: var(--spectrum-global-color-gray-50);
@ -164,7 +169,6 @@
.sheet-data-outer { .sheet-data-outer {
height: 0; height: 0;
flex-direction: column; flex-direction: column;
background: var(--cell-background);
} }
.sheet-data-inner { .sheet-data-inner {
flex-direction: row; flex-direction: row;
@ -187,6 +191,7 @@
border-bottom: 2px solid var(--spectrum-global-color-gray-200); border-bottom: 2px solid var(--spectrum-global-color-gray-200);
padding: var(--cell-padding); padding: var(--cell-padding);
gap: var(--cell-spacing); gap: var(--cell-spacing);
background: var(--spectrum-global-color-gray-100);
} }
.controls-left, .controls-left,
.controls-right { .controls-right {
@ -204,4 +209,13 @@
.overlays { .overlays {
z-index: 10; z-index: 10;
} }
/* Loading */
.sheet-loading {
position: absolute;
width: 100%;
height: 100%;
display: grid;
place-items: center;
}
</style> </style>