diff --git a/packages/client/manifest.json b/packages/client/manifest.json index 46f87818ff..982f96ef90 100644 --- a/packages/client/manifest.json +++ b/packages/client/manifest.json @@ -2457,12 +2457,12 @@ "settings": [ { "type": "dataProvider", - "label": "Provider", + "label": "Data provider", "key": "dataProvider" }, { "type": "number", - "label": "Row Count", + "label": "Row count", "key": "rowCount", "defaultValue": 8 }, @@ -2496,9 +2496,36 @@ }, { "type": "boolean", - "label": "Auto Columns", + "label": "Show auto columns", "key": "showAutoColumns", "defaultValue": false + }, + { + "type": "boolean", + "label": "Link table rows", + "key": "linkRows" + }, + { + "type": "boolean", + "label": "Open link screens in modal", + "key": "linkPeek" + }, + { + "type": "url", + "label": "Link screen", + "key": "linkURL" + }, + { + "section": true, + "name": "Advanced", + "settings": [ + { + "type": "field", + "label": "ID column for linking (appended to URL)", + "key": "linkColumn", + "placeholder": "Default" + } + ] } ], "context": { @@ -2662,8 +2689,22 @@ { "type": "boolean", "label": "Show auto columns", - "key": "showAutoColumns", - "defaultValue": false + "key": "showAutoColumns" + }, + { + "type": "boolean", + "label": "Link table rows", + "key": "linkRows" + }, + { + "type": "boolean", + "label": "Open link in modal", + "key": "linkPeek" + }, + { + "type": "url", + "label": "Link screen", + "key": "linkURL" } ] }, @@ -2684,10 +2725,22 @@ }, { "type": "event", - "label": "Title Button Action", + "label": "Title button action", "key": "titleButtonOnClick" } ] + }, + { + "section": true, + "name": "Advanced", + "settings": [ + { + "type": "field", + "label": "ID column for linking (appended to URL)", + "key": "linkColumn", + "placeholder": "Default" + } + ] } ], "context": { diff --git a/packages/client/src/components/app/blocks/TableWithSearch.svelte b/packages/client/src/components/app/blocks/TableWithSearch.svelte index c4143df986..378a111571 100644 --- a/packages/client/src/components/app/blocks/TableWithSearch.svelte +++ b/packages/client/src/components/app/blocks/TableWithSearch.svelte @@ -16,6 +16,10 @@ export let rowCount export let quiet export let size + export let linkRows + export let linkURL + export let linkColumn + export let linkPeek export let showTitleButton export let titleButtonText export let titleButtonOnClick @@ -138,6 +142,10 @@ rowCount, quiet, size, + linkRows, + linkURL, + linkColumn, + linkPeek, }} /> diff --git a/packages/client/src/components/app/table/Table.svelte b/packages/client/src/components/app/table/Table.svelte index a6508c5763..4178ca2bb2 100644 --- a/packages/client/src/components/app/table/Table.svelte +++ b/packages/client/src/components/app/table/Table.svelte @@ -9,9 +9,13 @@ export let rowCount export let quiet export let size + export let linkRows + export let linkURL + export let linkColumn + export let linkPeek const component = getContext("component") - const { styleable, getAction, ActionTypes } = getContext("sdk") + const { styleable, getAction, ActionTypes, routeStore } = getContext("sdk") const setSorting = getAction( dataProvider?.id, ActionTypes.SetDataProviderSorting @@ -81,6 +85,19 @@ order: e.detail.order, }) } + + const onClick = e => { + if (!linkRows || !linkURL) { + return + } + const col = linkColumn || "_id" + const id = e.detail?.[col] + if (!id) { + return + } + const split = linkURL.split("/:") + routeStore.actions.navigate(`${split[0]}/${id}`, linkPeek) + }