Add snippets into context when transforming column values legacy tables
This commit is contained in:
parent
6f0ab5e170
commit
732c715498
|
@ -12,6 +12,7 @@
|
||||||
export let schema
|
export let schema
|
||||||
export let value
|
export let value
|
||||||
export let customRenderers = []
|
export let customRenderers = []
|
||||||
|
export let snippets
|
||||||
|
|
||||||
let renderer
|
let renderer
|
||||||
const typeMap = {
|
const typeMap = {
|
||||||
|
@ -32,6 +33,8 @@
|
||||||
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
$: renderer = customRenderer?.component ?? typeMap[type] ?? StringRenderer
|
||||||
$: cellValue = getCellValue(value, schema.template)
|
$: cellValue = getCellValue(value, schema.template)
|
||||||
|
|
||||||
|
$: console.log(snippets)
|
||||||
|
|
||||||
const getType = schema => {
|
const getType = schema => {
|
||||||
// Use a string renderer for dates if we use a custom template
|
// Use a string renderer for dates if we use a custom template
|
||||||
if (schema?.type === "datetime" && schema?.template) {
|
if (schema?.type === "datetime" && schema?.template) {
|
||||||
|
@ -44,7 +47,7 @@
|
||||||
if (!template) {
|
if (!template) {
|
||||||
return value
|
return value
|
||||||
}
|
}
|
||||||
return processStringSync(template, { value })
|
return processStringSync(template, { value, snippets })
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|
|
@ -42,6 +42,7 @@
|
||||||
export let customPlaceholder = false
|
export let customPlaceholder = false
|
||||||
export let showHeaderBorder = true
|
export let showHeaderBorder = true
|
||||||
export let placeholderText = "No rows found"
|
export let placeholderText = "No rows found"
|
||||||
|
export let snippets = []
|
||||||
|
|
||||||
const dispatch = createEventDispatcher()
|
const dispatch = createEventDispatcher()
|
||||||
|
|
||||||
|
@ -425,6 +426,7 @@
|
||||||
<CellRenderer
|
<CellRenderer
|
||||||
{customRenderers}
|
{customRenderers}
|
||||||
{row}
|
{row}
|
||||||
|
{snippets}
|
||||||
schema={schema[field]}
|
schema={schema[field]}
|
||||||
value={deepGet(row, field)}
|
value={deepGet(row, field)}
|
||||||
on:clickrelationship
|
on:clickrelationship
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
export let noRowsMessage
|
export let noRowsMessage
|
||||||
|
|
||||||
const component = getContext("component")
|
const component = getContext("component")
|
||||||
|
const context = getContext("context")
|
||||||
const { styleable, getAction, ActionTypes, rowSelectionStore } =
|
const { styleable, getAction, ActionTypes, rowSelectionStore } =
|
||||||
getContext("sdk")
|
getContext("sdk")
|
||||||
const customColumnKey = `custom-${Math.random()}`
|
const customColumnKey = `custom-${Math.random()}`
|
||||||
|
@ -28,6 +29,7 @@
|
||||||
|
|
||||||
let selectedRows = []
|
let selectedRows = []
|
||||||
|
|
||||||
|
$: snippets = $context.snippets
|
||||||
$: hasChildren = $component.children
|
$: hasChildren = $component.children
|
||||||
$: loading = dataProvider?.loading ?? false
|
$: loading = dataProvider?.loading ?? false
|
||||||
$: data = dataProvider?.rows || []
|
$: data = dataProvider?.rows || []
|
||||||
|
@ -178,6 +180,7 @@
|
||||||
{quiet}
|
{quiet}
|
||||||
{compact}
|
{compact}
|
||||||
{customRenderers}
|
{customRenderers}
|
||||||
|
{snippets}
|
||||||
allowSelectRows={allowSelectRows && table}
|
allowSelectRows={allowSelectRows && table}
|
||||||
bind:selectedRows
|
bind:selectedRows
|
||||||
allowEditRows={false}
|
allowEditRows={false}
|
||||||
|
|
Loading…
Reference in New Issue