Browse Source

refactor: always create lookup on dnd if Link exist

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/5848/head
Pranav C 1 year ago
parent
commit
f4800710c2
  1. 28
      packages/nc-gui/components/tabs/Smartsheet.vue

28
packages/nc-gui/components/tabs/Smartsheet.vue

@ -1,6 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes, isLinksOrLTAR, RelationTypes } from 'nocodb-sdk' import { UITypes, isLinksOrLTAR } from 'nocodb-sdk'
import { import {
ActiveViewInj, ActiveViewInj,
FieldsInj, FieldsInj,
@ -98,25 +98,13 @@ const onDrop = async (event: DragEvent) => {
return ltarOptions.fk_related_model_id === childMeta.id return ltarOptions.fk_related_model_id === childMeta.id
}) })
if (relationCol) { if (relationCol) {
if (relationCol.colOptions.type === RelationTypes.BELONGS_TO) { const lookupCol = childMeta.columns?.find((c) => c.pv) ?? childMeta.columns?.[0]
const lookupCol = childMeta.columns?.find((c) => c.pv) ?? childMeta.columns?.[0] grid.value?.openColumnCreate({
uidt: UITypes.Lookup,
grid.value?.openColumnCreate({ title: `${relationCol.title}Lookup`,
uidt: UITypes.Lookup, fk_relation_column_id: relationCol.id,
title: `${relationCol.title}Lookup`, fk_lookup_column_id: lookupCol?.id,
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 { } else {
grid.value?.openColumnCreate({ grid.value?.openColumnCreate({
uidt: UITypes.Links, uidt: UITypes.Links,

Loading…
Cancel
Save