Remove RowDetail component
This commit is contained in:
parent
28e1688138
commit
5d9692e338
|
@ -63,8 +63,7 @@
|
|||
"children": [
|
||||
"screenslot",
|
||||
"navigation",
|
||||
"login",
|
||||
"rowdetail"
|
||||
"login"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
|
|
@ -1,57 +0,0 @@
|
|||
<script>
|
||||
import { onMount, getContext } from "svelte"
|
||||
|
||||
export let table
|
||||
|
||||
const {
|
||||
API,
|
||||
screenStore,
|
||||
routeStore,
|
||||
Provider,
|
||||
styleable,
|
||||
ActionTypes,
|
||||
} = getContext("sdk")
|
||||
const component = getContext("component")
|
||||
let headers = []
|
||||
let row
|
||||
|
||||
const fetchFirstRow = async tableId => {
|
||||
const rows = await API.fetchTableData(tableId)
|
||||
return Array.isArray(rows) && rows.length ? rows[0] : { tableId }
|
||||
}
|
||||
|
||||
const fetchData = async (rowId, tableId) => {
|
||||
if (!tableId) {
|
||||
return
|
||||
}
|
||||
|
||||
const pathParts = window.location.pathname.split("/")
|
||||
|
||||
// if srcdoc, then we assume this is the builder preview
|
||||
if ((pathParts.length === 0 || pathParts[0] === "srcdoc") && tableId) {
|
||||
row = await fetchFirstRow(tableId)
|
||||
} else if (rowId) {
|
||||
row = await API.fetchRow({ tableId, rowId })
|
||||
} else {
|
||||
throw new Error("Row ID was not supplied to RowDetail")
|
||||
}
|
||||
}
|
||||
|
||||
$: actions = [
|
||||
{
|
||||
type: ActionTypes.RefreshDatasource,
|
||||
callback: () => fetchData($routeStore.routeParams.id, table),
|
||||
metadata: { datasource: { type: "table", tableId: table } },
|
||||
},
|
||||
]
|
||||
|
||||
onMount(() => fetchData($routeStore.routeParams.id, table))
|
||||
</script>
|
||||
|
||||
{#if row}
|
||||
<Provider data={row} {actions}>
|
||||
<div use:styleable={$component.styles}>
|
||||
<slot />
|
||||
</div>
|
||||
</Provider>
|
||||
{/if}
|
|
@ -24,7 +24,6 @@ export { default as text } from "./Text.svelte"
|
|||
export { default as login } from "./Login.svelte"
|
||||
export { default as navigation } from "./Navigation.svelte"
|
||||
export { default as link } from "./Link.svelte"
|
||||
export { default as rowdetail } from "./RowDetail.svelte"
|
||||
export { default as heading } from "./Heading.svelte"
|
||||
export { default as image } from "./Image.svelte"
|
||||
export { default as embed } from "./Embed.svelte"
|
||||
|
|
Loading…
Reference in New Issue