Improve relationship datatable title when no primary display is selected for a model
This commit is contained in:
parent
7a08c5584d
commit
fa1836ad23
|
@ -9,6 +9,7 @@
|
||||||
export let fieldName
|
export let fieldName
|
||||||
|
|
||||||
let record
|
let record
|
||||||
|
let title
|
||||||
|
|
||||||
$: data = record?.[fieldName] ?? []
|
$: data = record?.[fieldName] ?? []
|
||||||
$: linkedModelId = data?.length ? data[0].modelId : null
|
$: linkedModelId = data?.length ? data[0].modelId : null
|
||||||
|
@ -17,8 +18,15 @@
|
||||||
)
|
)
|
||||||
$: schema = linkedModel?.schema
|
$: schema = linkedModel?.schema
|
||||||
$: model = $backendUiStore.models.find(model => model._id === modelId)
|
$: model = $backendUiStore.models.find(model => model._id === modelId)
|
||||||
$: title = `${record?.[model?.primaryDisplay]} - ${fieldName}`
|
|
||||||
$: fetchData(modelId, recordId)
|
$: fetchData(modelId, recordId)
|
||||||
|
$: {
|
||||||
|
let recordLabel = record?.[model?.primaryDisplay]
|
||||||
|
if (recordLabel) {
|
||||||
|
title = `${recordLabel} - ${fieldName}`
|
||||||
|
} else {
|
||||||
|
title = fieldName
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function fetchData(modelId, recordId) {
|
async function fetchData(modelId, recordId) {
|
||||||
const QUERY_VIEW_URL = `/api/${modelId}/${recordId}/enrich`
|
const QUERY_VIEW_URL = `/api/${modelId}/${recordId}/enrich`
|
||||||
|
|
Loading…
Reference in New Issue