From 5c6cb0a73a084192fbb6a198698e0576aac4361f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Mon, 24 Jun 2024 15:01:04 +0100 Subject: [PATCH] Ensure grid props are respected when using new features --- packages/client/src/components/app/GridBlock.svelte | 1 - .../src/components/grid/cells/GutterCell.svelte | 8 ++------ .../src/components/grid/controls/BulkDeleteHandler.svelte | 5 +++-- .../frontend-core/src/components/grid/layout/Grid.svelte | 6 +----- 4 files changed, 6 insertions(+), 14 deletions(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 5e0f32a971..2035b03391 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -171,7 +171,6 @@ canEditColumns={false} canExpandRows={false} canSaveSchema={false} - canSelectRows={true} showControls={false} notifySuccess={notificationStore.actions.success} notifyError={notificationStore.actions.error} diff --git a/packages/frontend-core/src/components/grid/cells/GutterCell.svelte b/packages/frontend-core/src/components/grid/cells/GutterCell.svelte index b5cf7eb5d6..0cb9502322 100644 --- a/packages/frontend-core/src/components/grid/cells/GutterCell.svelte +++ b/packages/frontend-core/src/components/grid/cells/GutterCell.svelte @@ -16,8 +16,6 @@ const { config, dispatch, selectedRows } = getContext("grid") const svelteDispatch = createEventDispatcher() - $: selectionEnabled = $config.canSelectRows || $config.canDeleteRows - const select = e => { e.stopPropagation() svelteDispatch("select") @@ -64,16 +62,14 @@
{#if !disableNumber}
{row.__idx + 1}
diff --git a/packages/frontend-core/src/components/grid/controls/BulkDeleteHandler.svelte b/packages/frontend-core/src/components/grid/controls/BulkDeleteHandler.svelte index fae2985861..027ac96aa2 100644 --- a/packages/frontend-core/src/components/grid/controls/BulkDeleteHandler.svelte +++ b/packages/frontend-core/src/components/grid/controls/BulkDeleteHandler.svelte @@ -14,6 +14,7 @@ selectedRowCount, selectedCells, rowLookupMap, + config, } = getContext("grid") const duration = 260 @@ -30,14 +31,14 @@ const handleBulkDeleteRequest = () => { progressPercentage = 0 menu.actions.close() - if ($selectedRowCount) { + if ($selectedRowCount && $config.canDeleteRows) { if ($selectedRowCount === 1) { bulkDeleteRows() } else { promptQuantity = $selectedRowCount rowsModal?.show() } - } else if ($selectedCellCount) { + } else if ($selectedCellCount && $config.canEditRows) { promptQuantity = $selectedCellCount cellsModal?.show() } diff --git a/packages/frontend-core/src/components/grid/layout/Grid.svelte b/packages/frontend-core/src/components/grid/layout/Grid.svelte index 6c61fdd45e..1ec785b166 100644 --- a/packages/frontend-core/src/components/grid/layout/Grid.svelte +++ b/packages/frontend-core/src/components/grid/layout/Grid.svelte @@ -44,7 +44,6 @@ export let canDeleteRows = true export let canEditColumns = true export let canSaveSchema = true - export let canSelectRows = false export let stripeRows = false export let quiet = false export let collaboration = true @@ -101,7 +100,6 @@ canDeleteRows, canEditColumns, canSaveSchema, - canSelectRows, stripeRows, quiet, collaboration, @@ -211,12 +209,10 @@ {/if} - {#if $config.canDeleteRows} - - {/if} {#if $config.canAddRows} {/if} +