mirror of https://github.com/nocodb/nocodb
Pranav C
2 years ago
7 changed files with 59 additions and 37 deletions
@ -1,40 +1,59 @@ |
|||||||
<script lang="ts" setup> |
<script lang="ts" setup> |
||||||
import { ColumnType, LinkToAnotherRecordType, LookupType, isVirtualCol } from 'nocodb-sdk' |
import type { ColumnType, LinkToAnotherRecordType, LookupType } from 'nocodb-sdk' |
||||||
|
import { RelationTypes, isVirtualCol, UITypes } from 'nocodb-sdk' |
||||||
import { useColumn } from '~/composables' |
import { useColumn } from '~/composables' |
||||||
import { ColumnInj, EditModeInj, MetaInj, ReadonlyInj, ValueInj } from '~/context' |
import { ColumnInj, MetaInj, ReadonlyInj, ValueInj } from '~/context' |
||||||
|
|
||||||
|
const { metas, getMeta } = useMetas() |
||||||
|
|
||||||
const {metas, getMeta} = useMetas(); |
provide(ReadonlyInj, true) |
||||||
|
|
||||||
provide(ReadonlyInj, true); |
const column = inject(ColumnInj) as ColumnType & { colOptions: LookupType } |
||||||
|
const meta = inject(MetaInj) |
||||||
|
const value = inject(ValueInj) |
||||||
|
const arrValue = Array.isArray(value) ? value : [value] |
||||||
|
|
||||||
const column = inject(ColumnInj) as ColumnType & { colOptions: LookupType }; |
const relationColumn = meta?.value.columns?.find((c) => c.id === column.colOptions.fk_relation_column_id) as ColumnType & { |
||||||
const meta = inject(MetaInj); |
colOptions: LinkToAnotherRecordType |
||||||
const value = inject(ValueInj); |
} |
||||||
|
await getMeta(relationColumn.colOptions.fk_related_model_id as string) |
||||||
|
const lookupTableMeta = metas?.value[relationColumn.colOptions.fk_related_model_id as string] |
||||||
|
const lookupColumn = lookupTableMeta?.columns?.find((c) => c.id === column.colOptions.fk_lookup_column_id) as ColumnType |
||||||
|
|
||||||
const relationColumn = meta?.value.columns?.find(c => c.id === column.colOptions.fk_relation_column_id) as ColumnType & { colOptions: LinkToAnotherRecordType }; |
provide(MetaInj, ref(lookupTableMeta)) |
||||||
await getMeta(relationColumn.colOptions.fk_related_model_id as string); |
|
||||||
const lookupTableMeta = metas?.value[relationColumn.colOptions.fk_related_model_id as string]; |
|
||||||
const lookupColumn = lookupTableMeta?.columns?.find(c => c.id === column.colOptions.fk_lookup_column_id) as ColumnType; |
|
||||||
|
|
||||||
provide(MetaInj, ref(lookupTableMeta)); |
|
||||||
|
|
||||||
const lookupColumnMetaProps = useColumn(lookupColumn) |
const lookupColumnMetaProps = useColumn(lookupColumn) |
||||||
|
|
||||||
</script> |
</script> |
||||||
|
|
||||||
<template> |
<template> |
||||||
<div class="w-full h-full"> |
<div class="w-full h-full flex gap-1"> |
||||||
{{lookupColumnMetaProps}} |
<template v-if="lookupColumn"> |
||||||
<SmartsheetVirtualCell |
<!-- Render virtual cell --> |
||||||
:edit-enabled="false" v-if="isVirtualCol(lookupColumn)" v-model="value" :column="lookupColumn" |
<div v-if="isVirtualCol(lookupColumn)"> |
||||||
/> |
<template |
||||||
|
v-if="lookupColumn.uidt === UITypes.LinkToAnotherRecord && lookupColumn.colOptions.type === RelationTypes.BELONGS_TO" |
||||||
<SmartsheetCell |
> |
||||||
v-else |
<SmartsheetVirtualCell |
||||||
v-model="value" |
v-for="(v, i) of arrValue" |
||||||
:column="lookupColumn" |
:key="i" |
||||||
:edit-enabled="false" |
:edit-enabled="false" |
||||||
/> |
:model-value="v" |
||||||
|
:column="lookupColumn" |
||||||
|
/> |
||||||
|
</template> |
||||||
|
|
||||||
|
<SmartsheetVirtualCell v-else :edit-enabled="false" :model-value="arrValue" :column="lookupColumn" /> |
||||||
|
</div> |
||||||
|
|
||||||
|
<!-- Render normal cell --> |
||||||
|
<template v-else> |
||||||
|
<!-- For attachment cell avoid adding chip style --> |
||||||
|
<div v-for="(v, i) in arrValue" :key="i" |
||||||
|
:class="{'bg-gray-100 px-2 rounded-full':!lookupColumnMetaProps.isAttachment}"> |
||||||
|
<SmartsheetCell :model-value="v" :column="lookupColumn" :edit-enabled="false" /> |
||||||
|
</div> |
||||||
|
</template> |
||||||
|
|
||||||
|
</template> |
||||||
</div> |
</div> |
||||||
</template> |
</template> |
||||||
|
Loading…
Reference in new issue