mirror of https://github.com/nocodb/nocodb
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
804 B
21 lines
804 B
3 years ago
|
import type { ColumnType, TableType } from 'nocodb-sdk'
|
||
|
import type LinkToAnotherRecordColumn from '../../nocodb/src/lib/models/LinkToAnotherRecordColumn'
|
||
|
import useMetas from '~/composables/useMetas'
|
||
|
|
||
|
export default function (column: ColumnType) {
|
||
|
const { metas, getMeta } = useMetas()
|
||
|
const parentMeta = computed<TableType>(() => {
|
||
|
return metas.value?.[(column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string]
|
||
|
})
|
||
|
|
||
|
const loadParentMeta = async () => {
|
||
|
await getMeta((column.colOptions as LinkToAnotherRecordColumn)?.fk_related_model_id as string)
|
||
|
}
|
||
|
|
||
|
const primaryValueProp = computed(() => {
|
||
|
return (parentMeta?.value?.columns?.find((c) => c.pv) || parentMeta?.value?.columns?.[0])?.title
|
||
|
})
|
||
|
|
||
|
return { parentMeta, loadParentMeta, primaryValueProp }
|
||
|
}
|