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",
|
"name": "Single Row Provider",
|
||||||
"icon": "SQLQuery",
|
"icon": "SQLQuery",
|
||||||
"hasChildren": true,
|
"hasChildren": true,
|
||||||
|
"actions": ["RefreshDatasource"],
|
||||||
"size": {
|
"size": {
|
||||||
"width": 500,
|
"width": 500,
|
||||||
"height": 200
|
"height": 200
|
||||||
|
@ -8201,7 +8202,8 @@
|
||||||
"type": "text",
|
"type": "text",
|
||||||
"label": "Row ID",
|
"label": "Row ID",
|
||||||
"key": "rowId",
|
"key": "rowId",
|
||||||
"required": true
|
"required": true,
|
||||||
|
"resetOn": "datasource"
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
"context": {
|
"context": {
|
||||||
|
|
|
@ -6,13 +6,20 @@
|
||||||
export let rowId: string
|
export let rowId: string
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
const { styleable, API, Provider } = getContext("sdk")
|
const { styleable, API, Provider, ActionTypes } = getContext("sdk")
|
||||||
|
|
||||||
let row: Row | undefined
|
let row: Row | undefined
|
||||||
|
|
||||||
$: datasourceId =
|
$: datasourceId =
|
||||||
datasource.type === "table" ? datasource.tableId : datasource.id
|
datasource.type === "table" ? datasource.tableId : datasource.id
|
||||||
$: fetchRow(datasourceId, rowId)
|
$: fetchRow(datasourceId, rowId)
|
||||||
|
$: actions = [
|
||||||
|
{
|
||||||
|
type: ActionTypes.RefreshDatasource,
|
||||||
|
callback: () => fetchRow(datasourceId, rowId),
|
||||||
|
metadata: { dataSource: datasource },
|
||||||
|
},
|
||||||
|
]
|
||||||
|
|
||||||
const fetchRow = async (datasourceId: string, rowId: string) => {
|
const fetchRow = async (datasourceId: string, rowId: string) => {
|
||||||
try {
|
try {
|
||||||
|
@ -24,7 +31,7 @@
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<div use:styleable={$component.styles}>
|
<div use:styleable={$component.styles}>
|
||||||
<Provider data={row ?? null}>
|
<Provider {actions} data={row ?? null}>
|
||||||
<slot />
|
<slot />
|
||||||
</Provider>
|
</Provider>
|
||||||
</div>
|
</div>
|
||||||
|
|
Loading…
Reference in New Issue