Browse Source

refactor(nc-gui): use sql ui of useProject

pull/3847/head
braks 2 years ago
parent
commit
e1cd1a9e7e
  1. 10
      packages/nc-gui/components/smartsheet/Cell.vue
  2. 10
      packages/nc-gui/components/smartsheet/header/CellIcon.ts
  3. 13
      packages/nc-gui/utils/cell.ts

10
packages/nc-gui/components/smartsheet/Cell.vue

@ -1,6 +1,6 @@
<script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk'
import { SqlUiFactory, isVirtualCol, UITypes } from 'nocodb-sdk'
import { isVirtualCol, UITypes } from 'nocodb-sdk'
import {
ActiveCellInj,
ColumnInj,
@ -82,15 +82,11 @@ const isLocked = inject(IsLockedInj, ref(false))
const { currentRow } = useSmartsheetRowStoreOrThrow()
const { project } = useProject()
const { sqlUi } = useProject()
const abstractType = computed(() => {
// kludge: CY test hack; column.value is being received NULL during attach cell delete operation
return (column.value && isVirtualCol(column.value)) || !column.value
? null
: SqlUiFactory.create(
project.value?.bases?.[0]?.type ? { client: project.value.bases[0].type } : { client: 'mysql2' },
).getAbstractType(column.value)
return (column.value && isVirtualCol(column.value)) || !column.value ? null : sqlUi.value.getAbstractType(column.value)
})
const syncValue = useDebounceFn(() => {

10
packages/nc-gui/components/smartsheet/header/CellIcon.ts

@ -1,6 +1,6 @@
import type { ColumnType } from 'nocodb-sdk'
import type { PropType } from '@vue/runtime-core'
import { SqlUiFactory, isVirtualCol } from 'nocodb-sdk'
import { isVirtualCol } from 'nocodb-sdk'
import {
ColumnInj,
computed,
@ -120,15 +120,11 @@ export default defineComponent({
const column = inject(ColumnInj, columnMeta)
const { project } = useProject()
const { sqlUi } = useProject()
const abstractType = computed(() => {
// kludge: CY test hack; column is being received NULL during attach cell delete operation
return (column.value && isVirtualCol(column.value)) || !column.value
? null
: SqlUiFactory.create(
project.value?.bases?.[0]?.type ? { client: project.value.bases[0].type } : { client: 'mysql2' },
).getAbstractType(column.value)
return (column.value && isVirtualCol(column.value)) || !column.value ? null : sqlUi.value.getAbstractType(column.value)
})
return () => {

13
packages/nc-gui/utils/cell.ts

@ -1,14 +1,5 @@
import type { ColumnType, ProjectType } from 'nocodb-sdk'
import { SqlUiFactory, UITypes, isVirtualCol } from 'nocodb-sdk'
export const abstractType = (column: ColumnType, project: ProjectType) => {
// kludge: CY test hack; column.value is being received NULL during attach cell delete operation
return (column && isVirtualCol(column)) || !column
? null
: SqlUiFactory.create(project.bases?.[0]?.type ? { client: project.bases[0].type } : { client: 'mysql2' }).getAbstractType(
column,
)
}
import type { ColumnType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
export const dataTypeLow = (column: ColumnType) => column.dt?.toLowerCase()
export const isBoolean = (abstractType: any) => abstractType === 'boolean'

Loading…
Cancel
Save