From 4ab9af53a099405b4f5db138af386e565702644f Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Thu, 2 Nov 2023 08:53:48 +0000 Subject: [PATCH] Add row to grid button click callback --- packages/client/src/components/app/GridBlock.svelte | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/packages/client/src/components/app/GridBlock.svelte b/packages/client/src/components/app/GridBlock.svelte index 9f93b6c4ff..2b06e41986 100644 --- a/packages/client/src/components/app/GridBlock.svelte +++ b/packages/client/src/components/app/GridBlock.svelte @@ -31,7 +31,7 @@ $: columnWhitelist = columns?.map(col => col.name) $: schemaOverrides = getSchemaOverrides(columns) - $: parsedButtons = parseButtons(buttons) + $: enrichedButtons = enrichButtons(buttons) const getSchemaOverrides = columns => { let overrides = {} @@ -44,7 +44,7 @@ return overrides } - const parseButtons = buttons => { + const enrichButtons = buttons => { if (!buttons?.length) { return null } @@ -52,8 +52,9 @@ size: "M", text: settings.text, type: settings.type, - onClick: async () => { - return await enrichButtonActions(settings.onClick, get(context))() + onClick: async row => { + const fn = enrichButtonActions(settings.onClick, get(context)) + return await fn({ row }) }, })) } @@ -82,7 +83,7 @@ showControls={false} notifySuccess={notificationStore.actions.success} notifyError={notificationStore.actions.error} - buttons={parsedButtons} + buttons={enrichedButtons} on:rowclick={e => onRowClick?.({ row: e.detail })} />