Browse Source

chore(gui-v2): cleanup typecheck issues

pull/3158/head
braks 2 years ago
parent
commit
0aac7e9b43
  1. 6
      packages/nc-gui-v2/components/smartsheet-column/LookupOptions.vue
  2. 46
      packages/nc-gui-v2/components/smartsheet/Form.vue
  3. 8
      packages/nc-gui-v2/components/smartsheet/expanded-form/Comments.vue
  4. 9
      packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue
  5. 25
      packages/nc-gui-v2/components/template/Editor.vue
  6. 20
      packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue
  7. 2
      packages/nc-gui-v2/composables/useExpandedFormStore.ts

6
packages/nc-gui-v2/components/smartsheet-column/LookupOptions.vue

@ -1,7 +1,7 @@
<script setup lang="ts">
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes, isSystemColumn } from 'nocodb-sdk'
import { MetaInj } from '~/context'
import { MetaInj } from '#imports'
interface Props {
value: Record<string, any>
@ -39,7 +39,7 @@ const refTables = $computed(() => {
}
return meta.columns
.filter((c: ColumnType) => c.uidt === UITypes.LinkToAnotherRecord && !c.system)
?.filter((c: ColumnType) => c.uidt === UITypes.LinkToAnotherRecord && !c.system)
.map<TableType & { col: LinkToAnotherRecordType; column: ColumnType }>((c: ColumnType) => ({
col: c.colOptions,
column: c,
@ -52,7 +52,7 @@ const refTables = $computed(() => {
})
const columns = $computed(() => {
const selectedTable = refTables.find((t) => t.column.id === vModel.value.fk_relation_column_id)
const selectedTable = refTables?.find((t) => t.column.id === vModel.value.fk_relation_column_id)
if (!selectedTable?.id) {
return []
}

46
packages/nc-gui-v2/components/smartsheet/Form.vue

@ -3,11 +3,26 @@ import Draggable from 'vuedraggable'
import { RelationTypes, UITypes, getSystemColumns, isVirtualCol } from 'nocodb-sdk'
import { message } from 'ant-design-vue'
import type { Permission } from '~/composables/useUIPermission/rolePermissions'
import { computed, inject, onClickOutside, useDebounceFn } from '#imports'
import { ActiveViewInj, IsFormInj, MetaInj } from '~/context'
import { extractSdkResponseErrorMsg } from '~/utils'
provide(IsFormInj, true)
import {
ActiveViewInj,
IsFormInj,
MetaInj,
computed,
extractSdkResponseErrorMsg,
inject,
onClickOutside,
provide,
reactive,
ref,
useDebounceFn,
useGlobal,
useNuxtApp,
useUIPermission,
useViewData,
watch,
} from '#imports'
provide(IsFormInj, ref(true))
// todo: generate hideCols based on default values
const hiddenCols = ['created_at', 'updated_at']
@ -76,7 +91,8 @@ async function submitForm() {
return
}
insertRow(formState)
await insertRow(formState)
submitted.value = true
}
@ -199,17 +215,23 @@ function setFormData() {
formViewData.value = {
...formViewData.value,
submit_another_form: !!(formViewData?.value?.submit_another_form ?? 0),
show_blank_form: !!(formViewData?.value?.show_blank_form ?? 0),
}
// todo: show_blank_form missing from FormType
show_blank_form: !!((formViewData?.value as any)?.show_blank_form ?? 0),
} as any
{
// email me
let data: Record<string, boolean> = {}
try {
data = JSON.parse(formViewData.value.email as string) || {}
} catch (e) {}
data = JSON.parse(formViewData.value?.email || '') || {}
} catch (e) {
// noop
}
data[state.user.value?.email as string] = emailMe.value
formViewData.value.email = JSON.stringify(data)
formViewData.value!.email = JSON.stringify(data)
checkSMTPStatus()
}
@ -265,7 +287,7 @@ const updateColMeta = useDebounceFn(async (col: Record<string, any>) => {
}, 250)
watch(submitted, (v) => {
if (v && formViewData?.value?.show_blank_form) {
if (v && (formViewData?.value as any)?.show_blank_form) {
secondsRemain.value = 5
const intvl = setInterval(() => {
if (--secondsRemain.value < 0) {

8
packages/nc-gui-v2/components/smartsheet/expanded-form/Comments.vue

@ -1,7 +1,5 @@
<script setup lang="ts">
import { nextTick, useExpandedFormStoreOrThrow } from '#imports'
import { enumColor, timeAgo } from '~/utils'
import MdiAccountIcon from '~icons/mdi/account-circle'
import { enumColor, nextTick, ref, timeAgo, useExpandedFormStoreOrThrow, watch } from '#imports'
const { loadCommentsAndLogs, commentsAndLogs, isCommentsLoading, commentsOnly, saveComment, isYou, comment } =
useExpandedFormStoreOrThrow()
@ -10,6 +8,8 @@ const commentsWrapperEl = ref<HTMLDivElement>()
await loadCommentsAndLogs()
const showborder = ref(false)
watch(
commentsAndLogs,
() => {
@ -28,7 +28,7 @@ watch(
<template v-else>
<div v-for="log of commentsAndLogs" :key="log.id" class="flex gap-1 text-xs">
<MdiAccountIcon class="row-span-2" :class="isYou(log.user) ? 'text-pink-300' : 'text-blue-300 '" />
<MdiAccountCircle class="row-span-2" :class="isYou(log.user) ? 'text-pink-300' : 'text-blue-300 '" />
<div class="flex-grow">
<p class="mb-1 caption edited-text text-[10px] text-gray">
{{ isYou(log.user) ? 'You' : log.user == null ? 'Shared base' : log.user }}

9
packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue

@ -32,7 +32,9 @@ const loadBase = async () => {
try {
if (!project.value.id) return
const res = await $api.project.sharedBaseGet(project.value.id)
// todo: response is missing roles in type
const res = (await $api.project.sharedBaseGet(project.value.id)) as any
base = {
uuid: res.uuid,
url: res.url,
@ -47,9 +49,10 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
try {
if (!project.value.id) return
const res = await $api.project.sharedBaseUpdate(project.value.id, {
// todo: return type void?
const res = (await $api.project.sharedBaseUpdate(project.value.id, {
roles: role,
})
})) as any
base = res ?? {}
base!.role = role

25
packages/nc-gui-v2/components/template/Editor.vue

@ -3,14 +3,26 @@ import type { ColumnType, TableType } from 'nocodb-sdk'
import { UITypes, isVirtualCol } from 'nocodb-sdk'
import { Form, message } from 'ant-design-vue'
import { srcDestMappingColumns, tableColumns } from './utils'
import { computed, onMounted } from '#imports'
import { extractSdkResponseErrorMsg, fieldRequiredValidator, getUIDTIcon } from '~/utils'
import { MetaInj, ReloadViewDataHookInj } from '~/context'
import {
MetaInj,
ReloadViewDataHookInj,
computed,
extractSdkResponseErrorMsg,
fieldRequiredValidator,
getUIDTIcon,
nextTick,
onMounted,
reactive,
ref,
useProject,
useTabs,
} from '#imports'
import { TabType } from '~/composables'
interface Props {
quickImportType: 'csv' | 'excel' | 'json'
projectTemplate: Record<string, any>
importData: Record<string, any>[]
importData: Record<string, any>
importColumns: any[]
importOnly: boolean
maxRowsToParse: number
@ -74,6 +86,7 @@ const { sqlUi, project, loadTables } = useProject()
onMounted(() => {
parseAndLoadTemplate()
nextTick(() => {
inputRefs.value[0]?.focus()
})
@ -409,7 +422,7 @@ async function importTemplate() {
await loadTables()
addTab({
...tab,
type: 'table',
type: TabType.TABLE,
})
} catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e))
@ -476,7 +489,7 @@ onMounted(() => {
</p>
</a-form>
<a-collapse v-if="data.tables && data.tables.length" v-model:activeKey="expansionPanel" class="template-collapse" accordion>
<a-collapse-panel v-for="(table, tableIdx) in data.tables" :key="tableIdx">
<a-collapse-panel v-for="(table, tableIdx) of data.tables" :key="tableIdx">
<template #header>
<span class="font-weight-bold text-lg flex items-center gap-2">
<mdi-table class="text-primary" />

20
packages/nc-gui-v2/components/virtual-cell/BelongsTo.vue

@ -3,20 +3,30 @@ import type { ColumnType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import ItemChip from './components/ItemChip.vue'
import ListItems from './components/ListItems.vue'
import { inject, ref, useProvideLTARStore, useSmartsheetRowStoreOrThrow } from '#imports'
import { ActiveCellInj, CellValueInj, ColumnInj, EditModeInj, ReloadViewDataHookInj, RowInj } from '~/context'
import {
ActiveCellInj,
CellValueInj,
ColumnInj,
EditModeInj,
ReloadViewDataHookInj,
RowInj,
inject,
ref,
useProvideLTARStore,
useSmartsheetRowStoreOrThrow,
} from '#imports'
import MdiArrowExpand from '~icons/mdi/arrow-expand'
import MdiPlus from '~icons/mdi/plus'
const column = inject(ColumnInj)
const column = inject(ColumnInj)!
const reloadTrigger = inject(ReloadViewDataHookInj)!
const cellValue = inject(CellValueInj, ref<any>(null))
const row = inject(RowInj)
const row = inject(RowInj)!
const active = inject(ActiveCellInj)
const active = inject(ActiveCellInj)!
const editEnabled = inject(EditModeInj)

2
packages/nc-gui-v2/composables/useExpandedFormStore.ts

@ -20,7 +20,7 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
const { api, isLoading: isCommentsLoading, error: commentsError } = useApi()
const commentsOnly = ref(false)
const commentsAndLogs = ref([])
const commentsAndLogs = ref<any[]>([])
const comment = ref('')
const commentsDrawer = ref(false)
const changedColumns = ref(new Set<string>())

Loading…
Cancel
Save