Expose refresh data provider action from single row provider and reset row ID setting when changing datasource

This commit is contained in:
Andrew Kingston 2025-04-01 09:30:34 +01:00
parent a92fce8e77
commit 35b9a4038b
No known key found for this signature in database
2 changed files with 12 additions and 3 deletions

View File

@ -8182,6 +8182,7 @@
"name": "Single Row Provider",
"icon": "SQLQuery",
"hasChildren": true,
"actions": ["RefreshDatasource"],
"size": {
"width": 500,
"height": 200
@ -8201,7 +8202,8 @@
"type": "text",
"label": "Row ID",
"key": "rowId",
"required": true
"required": true,
"resetOn": "datasource"
}
],
"context": {

View File

@ -6,13 +6,20 @@
export let rowId: string
const component = getContext("component")
const { styleable, API, Provider } = getContext("sdk")
const { styleable, API, Provider, ActionTypes } = getContext("sdk")
let row: Row | undefined
$: datasourceId =
datasource.type === "table" ? datasource.tableId : datasource.id
$: fetchRow(datasourceId, rowId)
$: actions = [
{
type: ActionTypes.RefreshDatasource,
callback: () => fetchRow(datasourceId, rowId),
metadata: { dataSource: datasource },
},
]
const fetchRow = async (datasourceId: string, rowId: string) => {
try {
@ -24,7 +31,7 @@
</script>
<div use:styleable={$component.styles}>
<Provider data={row ?? null}>
<Provider {actions} data={row ?? null}>
<slot />
</Provider>
</div>