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.
82 lines
3.2 KiB
82 lines
3.2 KiB
3 years ago
|
<script setup lang="ts">
|
||
2 years ago
|
import type { ColumnType, LinkToAnotherRecordType, LookupType } from 'nocodb-sdk'
|
||
2 years ago
|
import { RelationTypes, UITypes } from 'nocodb-sdk'
|
||
2 years ago
|
import type { Ref } from 'vue'
|
||
2 years ago
|
import { toRef } from 'vue'
|
||
2 years ago
|
import { ColumnInj } from '~/context'
|
||
3 years ago
|
import GenericIcon from '~icons/mdi/square-rounded'
|
||
|
import HMIcon from '~icons/mdi/table-arrow-right'
|
||
|
import BTIcon from '~icons/mdi/table-arrow-left'
|
||
|
import MMIcon from '~icons/mdi/table-network'
|
||
|
import FormulaIcon from '~icons/mdi/math-integral'
|
||
|
import RollupIcon from '~icons/mdi/movie-roll'
|
||
2 years ago
|
import CountIcon from '~icons/mdi/counter'
|
||
2 years ago
|
import SpecificDBTypeIcon from '~icons/mdi/database-settings'
|
||
2 years ago
|
import TableColumnPlusBefore from '~icons/mdi/table-column-plus-before'
|
||
3 years ago
|
|
||
2 years ago
|
const props = defineProps<{ columnMeta?: ColumnType }>()
|
||
|
const columnMeta = toRef(props, 'columnMeta')
|
||
2 years ago
|
|
||
2 years ago
|
const column = inject(ColumnInj, ref(columnMeta)) as Ref<ColumnType & { colOptions: LookupType }>
|
||
|
|
||
|
let relationColumn: ColumnType & { colOptions: LookupType }
|
||
|
|
||
|
if (column) {
|
||
|
const { isLookup, isBt, isRollup, isMm, isHm } = useVirtualCell(column as Ref<ColumnType>)
|
||
|
|
||
|
if (isLookup || isBt || isRollup || isMm || isHm) {
|
||
|
const meta = inject(MetaInj)
|
||
|
|
||
|
relationColumn = meta?.value.columns?.find((c) => c.id === column.value?.colOptions?.fk_relation_column_id) as ColumnType & {
|
||
|
colOptions: LinkToAnotherRecordType
|
||
|
}
|
||
|
}
|
||
|
}
|
||
3 years ago
|
|
||
|
const icon = computed(() => {
|
||
2 years ago
|
switch (column?.value?.uidt) {
|
||
3 years ago
|
case UITypes.LinkToAnotherRecord:
|
||
2 years ago
|
switch ((column?.value?.colOptions as LinkToAnotherRecordType)?.type) {
|
||
3 years ago
|
case RelationTypes.MANY_TO_MANY:
|
||
2 years ago
|
return { icon: MMIcon, color: 'text-accent' }
|
||
3 years ago
|
case RelationTypes.HAS_MANY:
|
||
2 years ago
|
return { icon: HMIcon, color: 'text-yellow-500' }
|
||
3 years ago
|
case RelationTypes.BELONGS_TO:
|
||
2 years ago
|
return { icon: BTIcon, color: 'text-sky-500' }
|
||
3 years ago
|
}
|
||
|
break
|
||
2 years ago
|
case UITypes.SpecificDBType:
|
||
2 years ago
|
return { icon: SpecificDBTypeIcon, color: 'text-grey' }
|
||
3 years ago
|
case UITypes.Formula:
|
||
2 years ago
|
return { icon: FormulaIcon, color: 'text-grey' }
|
||
3 years ago
|
case UITypes.Lookup:
|
||
2 years ago
|
switch ((relationColumn?.colOptions as LinkToAnotherRecordType)?.type) {
|
||
|
case RelationTypes.MANY_TO_MANY:
|
||
2 years ago
|
return { icon: TableColumnPlusBefore, color: 'text-accent' }
|
||
2 years ago
|
case RelationTypes.HAS_MANY:
|
||
|
return { icon: TableColumnPlusBefore, color: 'text-yellow-500' }
|
||
|
case RelationTypes.BELONGS_TO:
|
||
|
return { icon: TableColumnPlusBefore, color: 'text-sky-500' }
|
||
|
}
|
||
|
return { icon: TableColumnPlusBefore, color: 'text-grey' }
|
||
3 years ago
|
case UITypes.Rollup:
|
||
2 years ago
|
switch ((relationColumn?.colOptions as LinkToAnotherRecordType)?.type) {
|
||
|
case RelationTypes.MANY_TO_MANY:
|
||
2 years ago
|
return { icon: RollupIcon, color: 'text-accent' }
|
||
2 years ago
|
case RelationTypes.HAS_MANY:
|
||
|
return { icon: RollupIcon, color: 'text-yellow-500' }
|
||
|
case RelationTypes.BELONGS_TO:
|
||
|
return { icon: RollupIcon, color: 'text-sky-500' }
|
||
|
}
|
||
|
return { icon: RollupIcon, color: 'text-grey' }
|
||
2 years ago
|
case UITypes.Count:
|
||
2 years ago
|
return { icon: CountIcon, color: 'text-grey' }
|
||
3 years ago
|
}
|
||
2 years ago
|
return { icon: GenericIcon, color: 'text-grey' }
|
||
3 years ago
|
})
|
||
|
</script>
|
||
|
|
||
|
<template>
|
||
2 years ago
|
<component :is="icon.icon" class="mx-1 !text-sm" :class="icon.color" />
|
||
3 years ago
|
</template>
|