Expose refresh data provider action from single row provider and reset row ID setting when changing datasource
This commit is contained in:
parent
a92fce8e77
commit
35b9a4038b
|
@ -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": {
|
||||
|
|
|
@ -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>
|
||||
|
|
Loading…
Reference in New Issue