From 12ced8cba77099b7de0c378febe5b41c75a69e3c Mon Sep 17 00:00:00 2001 From: Mel O'Hagan Date: Tue, 7 Jun 2022 14:40:56 +0100 Subject: [PATCH] Added preventSelectRow prop to custom column --- packages/bbui/src/Table/Table.svelte | 44 +++++++++---------- .../src/components/app/table/Table.svelte | 1 + 2 files changed, 21 insertions(+), 24 deletions(-) diff --git a/packages/bbui/src/Table/Table.svelte b/packages/bbui/src/Table/Table.svelte index 2a22236474..b41b77353a 100644 --- a/packages/bbui/src/Table/Table.svelte +++ b/packages/bbui/src/Table/Table.svelte @@ -132,7 +132,7 @@ style += " auto" } fields?.forEach(field => { - const fieldSchema = schema[field] + const fieldSchema = schema[field.name] if (fieldSchema.width) { style += ` ${fieldSchema.width}` } else { @@ -204,7 +204,6 @@ return nameA < nameB ? a : b }) .concat(autoColumns) - .map(column => column.name) } const editColumn = (e, field) => { @@ -300,19 +299,19 @@ {#each fields as field}
sortBy(schema[field])} + on:click={() => sortBy(schema[field.name])} > -
{getDisplayName(schema[field])}
- {#if schema[field]?.autocolumn} +
{getDisplayName(schema[field.name])}
+ {#if schema[field.name]?.autocolumn} {/if} - {#if sortColumn === field} + {#if sortColumn === field.name} {/if} - {#if allowEditColumns && schema[field]?.editable !== false} + {#if allowEditColumns && schema[field.name]?.editable !== false} editColumn(e, field)} + on:click={e => editColumn(e, field.name)} > @@ -343,7 +342,7 @@
{/if} {#if sortedRows?.length} - {#each sortedRows as row, idx} + {#each sortedRows as row}
{#if showEditColumn}
{ - if (!field.startsWith("custom-")) { + if (!field.preventSelectRow) { dispatch("click", row) - } - }} - on:click={() => { - if (!field.startsWith("custom-")) { toggleSelectRow(row) } }} @@ -383,8 +379,8 @@ diff --git a/packages/client/src/components/app/table/Table.svelte b/packages/client/src/components/app/table/Table.svelte index 9346b3ca59..f56d91d7c8 100644 --- a/packages/client/src/components/app/table/Table.svelte +++ b/packages/client/src/components/app/table/Table.svelte @@ -86,6 +86,7 @@ sortable: false, divider: true, width: "auto", + preventSelectRow: true, } }