|
|
|
@ -3,63 +3,54 @@ import type { ColumnType, LinkToAnotherRecordType, LookupType, RollupType } from
|
|
|
|
|
import type { Ref } from 'vue' |
|
|
|
|
import { RelationTypes, UITypes } from 'nocodb-sdk' |
|
|
|
|
import { ColumnInj, MetaInj, defineComponent, h, inject, isBt, isHm, isLookup, isMm, isRollup, ref, toRef } from '#imports' |
|
|
|
|
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 QrCodeScan from '~icons/mdi/qrcode-scan' |
|
|
|
|
import BarcodeScan from '~icons/mdi/barcode-scan' |
|
|
|
|
import RollupIcon from '~icons/mdi/movie-roll' |
|
|
|
|
import { iconMap } from '~/utils' |
|
|
|
|
import CountIcon from '~icons/mdi/counter' |
|
|
|
|
import SpecificDBTypeIcon from '~icons/mdi/database-settings' |
|
|
|
|
import MdiTextSearchVariant from '~icons/mdi/text-search-variant' |
|
|
|
|
|
|
|
|
|
const renderIcon = (column: ColumnType, relationColumn?: ColumnType) => { |
|
|
|
|
switch (column.uidt) { |
|
|
|
|
case UITypes.LinkToAnotherRecord: |
|
|
|
|
switch ((column.colOptions as LinkToAnotherRecordType)?.type) { |
|
|
|
|
case RelationTypes.MANY_TO_MANY: |
|
|
|
|
return { icon: MMIcon, color: 'text-accent' } |
|
|
|
|
return { icon: iconMap.mm, color: 'text-accent' } |
|
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
|
return { icon: HMIcon, color: 'text-yellow-500' } |
|
|
|
|
return { icon: iconMap.hm, color: 'text-yellow-500' } |
|
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
|
return { icon: BTIcon, color: 'text-sky-500' } |
|
|
|
|
return { icon: iconMap.bt, color: 'text-sky-500' } |
|
|
|
|
} |
|
|
|
|
break |
|
|
|
|
case UITypes.SpecificDBType: |
|
|
|
|
return { icon: SpecificDBTypeIcon, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap['specific-db-type'], color: 'text-grey' } |
|
|
|
|
case UITypes.Formula: |
|
|
|
|
return { icon: FormulaIcon, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap.formula, color: 'text-grey' } |
|
|
|
|
case UITypes.QrCode: |
|
|
|
|
return { icon: QrCodeScan, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap['qr-code'], color: 'text-grey' } |
|
|
|
|
case UITypes.Barcode: |
|
|
|
|
return { icon: BarcodeScan, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap['qr-code'], color: 'text-grey' } |
|
|
|
|
case UITypes.Lookup: |
|
|
|
|
switch ((relationColumn?.colOptions as LinkToAnotherRecordType)?.type) { |
|
|
|
|
case RelationTypes.MANY_TO_MANY: |
|
|
|
|
return { icon: MdiTextSearchVariant, color: 'text-accent' } |
|
|
|
|
return { icon: iconMap.lookup, color: 'text-accent' } |
|
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
|
return { icon: MdiTextSearchVariant, color: 'text-yellow-500' } |
|
|
|
|
return { icon: iconMap.lookup, color: 'text-yellow-500' } |
|
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
|
return { icon: MdiTextSearchVariant, color: 'text-sky-500' } |
|
|
|
|
return { icon: iconMap.lookup, color: 'text-sky-500' } |
|
|
|
|
} |
|
|
|
|
return { icon: MdiTextSearchVariant, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap.lookup, color: 'text-grey' } |
|
|
|
|
case UITypes.Rollup: |
|
|
|
|
switch ((relationColumn?.colOptions as LinkToAnotherRecordType)?.type) { |
|
|
|
|
case RelationTypes.MANY_TO_MANY: |
|
|
|
|
return { icon: RollupIcon, color: 'text-accent' } |
|
|
|
|
return { icon: iconMap, color: 'text-accent' } |
|
|
|
|
case RelationTypes.HAS_MANY: |
|
|
|
|
return { icon: RollupIcon, color: 'text-yellow-500' } |
|
|
|
|
return { icon: iconMap, color: 'text-yellow-500' } |
|
|
|
|
case RelationTypes.BELONGS_TO: |
|
|
|
|
return { icon: RollupIcon, color: 'text-sky-500' } |
|
|
|
|
return { icon: iconMap, color: 'text-sky-500' } |
|
|
|
|
} |
|
|
|
|
return { icon: RollupIcon, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap, color: 'text-grey' } |
|
|
|
|
case UITypes.Count: |
|
|
|
|
return { icon: CountIcon, color: 'text-grey' } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { icon: GenericIcon, color: 'text-grey' } |
|
|
|
|
return { icon: iconMap.generic, color: 'text-grey' } |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
export default defineComponent({ |
|
|
|
|