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"> <script setup lang="ts">
import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType, TableType } from 'nocodb-sdk'
import { UITypes, isSystemColumn } from 'nocodb-sdk' import { UITypes, isSystemColumn } from 'nocodb-sdk'
import { MetaInj } from '~/context' import { MetaInj } from '#imports'
interface Props { interface Props {
value: Record<string, any> value: Record<string, any>
@ -39,7 +39,7 @@ const refTables = $computed(() => {
} }
return meta.columns 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) => ({ .map<TableType & { col: LinkToAnotherRecordType; column: ColumnType }>((c: ColumnType) => ({
col: c.colOptions, col: c.colOptions,
column: c, column: c,
@ -52,7 +52,7 @@ const refTables = $computed(() => {
}) })
const columns = $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) { if (!selectedTable?.id) {
return [] 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 { RelationTypes, UITypes, getSystemColumns, isVirtualCol } from 'nocodb-sdk'
import { message } from 'ant-design-vue' import { message } from 'ant-design-vue'
import type { Permission } from '~/composables/useUIPermission/rolePermissions' import type { Permission } from '~/composables/useUIPermission/rolePermissions'
import { computed, inject, onClickOutside, useDebounceFn } from '#imports' import {
import { ActiveViewInj, IsFormInj, MetaInj } from '~/context' ActiveViewInj,
import { extractSdkResponseErrorMsg } from '~/utils' IsFormInj,
MetaInj,
provide(IsFormInj, true) 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 // todo: generate hideCols based on default values
const hiddenCols = ['created_at', 'updated_at'] const hiddenCols = ['created_at', 'updated_at']
@ -76,7 +91,8 @@ async function submitForm() {
return return
} }
insertRow(formState) await insertRow(formState)
submitted.value = true submitted.value = true
} }
@ -199,17 +215,23 @@ function setFormData() {
formViewData.value = { formViewData.value = {
...formViewData.value, ...formViewData.value,
submit_another_form: !!(formViewData?.value?.submit_another_form ?? 0), 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 // email me
let data: Record<string, boolean> = {} let data: Record<string, boolean> = {}
try { try {
data = JSON.parse(formViewData.value.email as string) || {} data = JSON.parse(formViewData.value?.email || '') || {}
} catch (e) {} } catch (e) {
// noop
}
data[state.user.value?.email as string] = emailMe.value data[state.user.value?.email as string] = emailMe.value
formViewData.value.email = JSON.stringify(data)
formViewData.value!.email = JSON.stringify(data)
checkSMTPStatus() checkSMTPStatus()
} }
@ -265,7 +287,7 @@ const updateColMeta = useDebounceFn(async (col: Record<string, any>) => {
}, 250) }, 250)
watch(submitted, (v) => { watch(submitted, (v) => {
if (v && formViewData?.value?.show_blank_form) { if (v && (formViewData?.value as any)?.show_blank_form) {
secondsRemain.value = 5 secondsRemain.value = 5
const intvl = setInterval(() => { const intvl = setInterval(() => {
if (--secondsRemain.value < 0) { if (--secondsRemain.value < 0) {

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

@ -1,7 +1,5 @@
<script setup lang="ts"> <script setup lang="ts">
import { nextTick, useExpandedFormStoreOrThrow } from '#imports' import { enumColor, nextTick, ref, timeAgo, useExpandedFormStoreOrThrow, watch } from '#imports'
import { enumColor, timeAgo } from '~/utils'
import MdiAccountIcon from '~icons/mdi/account-circle'
const { loadCommentsAndLogs, commentsAndLogs, isCommentsLoading, commentsOnly, saveComment, isYou, comment } = const { loadCommentsAndLogs, commentsAndLogs, isCommentsLoading, commentsOnly, saveComment, isYou, comment } =
useExpandedFormStoreOrThrow() useExpandedFormStoreOrThrow()
@ -10,6 +8,8 @@ const commentsWrapperEl = ref<HTMLDivElement>()
await loadCommentsAndLogs() await loadCommentsAndLogs()
const showborder = ref(false)
watch( watch(
commentsAndLogs, commentsAndLogs,
() => { () => {
@ -28,7 +28,7 @@ watch(
<template v-else> <template v-else>
<div v-for="log of commentsAndLogs" :key="log.id" class="flex gap-1 text-xs"> <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"> <div class="flex-grow">
<p class="mb-1 caption edited-text text-[10px] text-gray"> <p class="mb-1 caption edited-text text-[10px] text-gray">
{{ isYou(log.user) ? 'You' : log.user == null ? 'Shared base' : log.user }} {{ 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 { try {
if (!project.value.id) return 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 = { base = {
uuid: res.uuid, uuid: res.uuid,
url: res.url, url: res.url,
@ -47,9 +49,10 @@ const createShareBase = async (role = ShareBaseRole.Viewer) => {
try { try {
if (!project.value.id) return 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, roles: role,
}) })) as any
base = res ?? {} base = res ?? {}
base!.role = role 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 { UITypes, isVirtualCol } from 'nocodb-sdk'
import { Form, message } from 'ant-design-vue' import { Form, message } from 'ant-design-vue'
import { srcDestMappingColumns, tableColumns } from './utils' import { srcDestMappingColumns, tableColumns } from './utils'
import { computed, onMounted } from '#imports' import {
import { extractSdkResponseErrorMsg, fieldRequiredValidator, getUIDTIcon } from '~/utils' MetaInj,
import { MetaInj, ReloadViewDataHookInj } from '~/context' ReloadViewDataHookInj,
computed,
extractSdkResponseErrorMsg,
fieldRequiredValidator,
getUIDTIcon,
nextTick,
onMounted,
reactive,
ref,
useProject,
useTabs,
} from '#imports'
import { TabType } from '~/composables'
interface Props { interface Props {
quickImportType: 'csv' | 'excel' | 'json' quickImportType: 'csv' | 'excel' | 'json'
projectTemplate: Record<string, any> projectTemplate: Record<string, any>
importData: Record<string, any>[] importData: Record<string, any>
importColumns: any[] importColumns: any[]
importOnly: boolean importOnly: boolean
maxRowsToParse: number maxRowsToParse: number
@ -74,6 +86,7 @@ const { sqlUi, project, loadTables } = useProject()
onMounted(() => { onMounted(() => {
parseAndLoadTemplate() parseAndLoadTemplate()
nextTick(() => { nextTick(() => {
inputRefs.value[0]?.focus() inputRefs.value[0]?.focus()
}) })
@ -409,7 +422,7 @@ async function importTemplate() {
await loadTables() await loadTables()
addTab({ addTab({
...tab, ...tab,
type: 'table', type: TabType.TABLE,
}) })
} catch (e: any) { } catch (e: any) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
@ -476,7 +489,7 @@ onMounted(() => {
</p> </p>
</a-form> </a-form>
<a-collapse v-if="data.tables && data.tables.length" v-model:activeKey="expansionPanel" class="template-collapse" accordion> <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> <template #header>
<span class="font-weight-bold text-lg flex items-center gap-2"> <span class="font-weight-bold text-lg flex items-center gap-2">
<mdi-table class="text-primary" /> <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 type { Ref } from 'vue'
import ItemChip from './components/ItemChip.vue' import ItemChip from './components/ItemChip.vue'
import ListItems from './components/ListItems.vue' import ListItems from './components/ListItems.vue'
import { inject, ref, useProvideLTARStore, useSmartsheetRowStoreOrThrow } from '#imports' import {
import { ActiveCellInj, CellValueInj, ColumnInj, EditModeInj, ReloadViewDataHookInj, RowInj } from '~/context' ActiveCellInj,
CellValueInj,
ColumnInj,
EditModeInj,
ReloadViewDataHookInj,
RowInj,
inject,
ref,
useProvideLTARStore,
useSmartsheetRowStoreOrThrow,
} from '#imports'
import MdiArrowExpand from '~icons/mdi/arrow-expand' import MdiArrowExpand from '~icons/mdi/arrow-expand'
import MdiPlus from '~icons/mdi/plus' import MdiPlus from '~icons/mdi/plus'
const column = inject(ColumnInj) const column = inject(ColumnInj)!
const reloadTrigger = inject(ReloadViewDataHookInj)! const reloadTrigger = inject(ReloadViewDataHookInj)!
const cellValue = inject(CellValueInj, ref<any>(null)) 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) 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 { api, isLoading: isCommentsLoading, error: commentsError } = useApi()
const commentsOnly = ref(false) const commentsOnly = ref(false)
const commentsAndLogs = ref([]) const commentsAndLogs = ref<any[]>([])
const comment = ref('') const comment = ref('')
const commentsDrawer = ref(false) const commentsDrawer = ref(false)
const changedColumns = ref(new Set<string>()) const changedColumns = ref(new Set<string>())

Loading…
Cancel
Save