Provide additional context from row explorer block

This commit is contained in:
Andrew Kingston 2024-02-16 14:36:28 +00:00
parent 840f499b47
commit 53bb890d3d
1 changed files with 13 additions and 3 deletions

View File

@ -3,25 +3,35 @@
import BlockComponent from "components/BlockComponent.svelte" import BlockComponent from "components/BlockComponent.svelte"
import { makePropSafe as safe } from "@budibase/string-templates" import { makePropSafe as safe } from "@budibase/string-templates"
import { generate } from "shortid" import { generate } from "shortid"
import { get } from "svelte/store"
import { getContext } from "svelte"
export let dataSource export let dataSource
export let height export let height
export let cardTitle export let cardTitle
export let cardSubtitle export let cardSubtitle
export let cardDescription export let cardDescription
export let cardImageURL export let cardImageURL
export let cardSearchField export let cardSearchField
export let detailFields export let detailFields
export let detailTitle export let detailTitle
export let noRowsMessage export let noRowsMessage
const stateKey = generate() const stateKey = generate()
const context = getContext("context")
const { generateGoldenSample } = getContext("sdk")
let listDataProviderId let listDataProviderId
let listRepeaterId let listRepeaterId
// Provide additional data context for live binding eval
export const getAdditionalDataContext = () => {
const rows = get(context)[listDataProviderId]?.rows || []
const goldenRow = generateGoldenSample(rows)
return {
[listRepeaterId]: goldenRow,
}
}
</script> </script>
<Block> <Block>