|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
<script setup lang="ts"> |
|
|
|
|
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' |
|
|
|
|
import { UITypes, isLinksOrLTAR } from 'nocodb-sdk' |
|
|
|
|
import { UITypes, isLinksOrLTAR, RelationTypes } from 'nocodb-sdk' |
|
|
|
|
import { |
|
|
|
|
ActiveViewInj, |
|
|
|
|
FieldsInj, |
|
|
|
@ -95,24 +95,28 @@ const onDrop = async (event: DragEvent) => {
|
|
|
|
|
|
|
|
|
|
const ltarOptions = c.colOptions as LinkToAnotherRecordType |
|
|
|
|
|
|
|
|
|
if (ltarOptions.type !== 'mm') { |
|
|
|
|
return false |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
if (ltarOptions.fk_related_model_id === childMeta.id) { |
|
|
|
|
return true |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return false |
|
|
|
|
return ltarOptions.fk_related_model_id === childMeta.id |
|
|
|
|
}) |
|
|
|
|
if (relationCol) { |
|
|
|
|
const lookupCol = childMeta.columns?.find((c) => c.pv) ?? childMeta.columns?.[0] |
|
|
|
|
grid.value?.openColumnCreate({ |
|
|
|
|
uidt: UITypes.Lookup, |
|
|
|
|
title: `${data.title}Lookup`, |
|
|
|
|
fk_relation_column_id: relationCol.id, |
|
|
|
|
fk_lookup_column_id: lookupCol?.id, |
|
|
|
|
}) |
|
|
|
|
if (relationCol.colOptions.type === RelationTypes.BELONGS_TO) { |
|
|
|
|
const lookupCol = childMeta.columns?.find((c) => c.pv) ?? childMeta.columns?.[0] |
|
|
|
|
|
|
|
|
|
grid.value?.openColumnCreate({ |
|
|
|
|
uidt: UITypes.Lookup, |
|
|
|
|
title: `${relationCol.title}Lookup`, |
|
|
|
|
fk_relation_column_id: relationCol.id, |
|
|
|
|
fk_lookup_column_id: lookupCol?.id, |
|
|
|
|
}) |
|
|
|
|
} else { |
|
|
|
|
const rollupCol = childMeta.columns?.find((c) => c.pk) ?? childMeta.columns?.[0] |
|
|
|
|
grid.value?.openColumnCreate({ |
|
|
|
|
uidt: UITypes.Rollup, |
|
|
|
|
title: `${relationCol.title}Rollup`, |
|
|
|
|
fk_relation_column_id: relationCol.id, |
|
|
|
|
fk_rollup_column_id: rollupCol?.id, |
|
|
|
|
rollup_function: 'max', |
|
|
|
|
}) |
|
|
|
|
} |
|
|
|
|
} else { |
|
|
|
|
grid.value?.openColumnCreate({ |
|
|
|
|
uidt: UITypes.Links, |
|
|
|
|