Browse Source

chore(gui-v2): cleanup typecheck issues

pull/3158/head
braks 2 years ago
parent
commit
cf853e6bc8
  1. 15
      packages/nc-gui-v2/components/smartsheet-column/FormulaOptions.vue
  2. 12
      packages/nc-gui-v2/composables/useColumnCreateStore.ts
  3. 24
      packages/nc-gui-v2/composables/useExpandedFormStore.ts
  4. 16
      packages/nc-gui-v2/composables/useGlobal/state.ts
  5. 2
      packages/nc-gui-v2/composables/useGlobal/types.ts
  6. 33
      packages/nc-gui-v2/composables/useLTARStore.ts
  7. 3
      packages/nc-gui-v2/composables/useViewColumns.ts
  8. 5
      packages/nc-gui-v2/composables/useViewFilters.ts
  9. 5
      packages/nc-gui-v2/composables/useViews.ts

15
packages/nc-gui-v2/components/smartsheet-column/FormulaOptions.vue

@ -4,9 +4,8 @@ import type { ListItem as AntListItem } from 'ant-design-vue'
import jsep from 'jsep'
import type { ColumnType } from 'nocodb-sdk'
import { UITypes, jsepCurlyHook } from 'nocodb-sdk'
import { onMounted, useDebounceFn } from '#imports'
import { MetaInj } from '~/context'
import {
MetaInj,
NcAutocompleteTree,
formulaList,
formulaTypes,
@ -14,8 +13,11 @@ import {
getUIDTIcon,
getWordUntilCaret,
insertAtCursor,
onMounted,
useColumnCreateStoreOrThrow,
useDebounceFn,
validateDateWithUnknownFormat,
} from '@/utils'
} from '#imports'
interface Props {
value: Record<string, any>
@ -615,10 +617,11 @@ onMounted(() => {
</a-form-item>
<div class="text-gray-600 mt-2 mb-4 prose-sm">
Hint: Use {} to reference columns, e.g: {column_name}. For more, please check out
<a class="prose-sm" href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" target="_blank"
>Formulas</a
>.
<a class="prose-sm" href="https://docs.nocodb.com/setup-and-usages/formulas#available-formula-features" target="_blank">
Formulas.
</a>
</div>
<div class="h-[250px] overflow-auto scrollbar-thin-primary">
<a-list ref="sugListRef" :data-source="suggestion" :locale="{ emptyText: 'No suggested formula was found' }">
<template #renderItem="{ item, index }">

12
packages/nc-gui-v2/composables/useColumnCreateStore.ts

@ -1,23 +1,13 @@
import { createInjectionState } from '@vueuse/core'
import clone from 'just-clone'
import { Form, message } from 'ant-design-vue'
import type { ColumnType, TableType } from 'nocodb-sdk'
import { UITypes } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { useColumn } from './useColumn'
import { computed } from '#imports'
import { useNuxtApp } from '#app'
import { extractSdkResponseErrorMsg } from '~/utils/errorUtils'
import { computed, createInjectionState, extractSdkResponseErrorMsg, useNuxtApp } from '#imports'
const useForm = Form.useForm
// enum ColumnAlterType {
// NEW=4,
// EDIT=2,
// RENAME=8,
// DELETE=0,
// }
const columnToValidate = [UITypes.Email, UITypes.URL, UITypes.PhoneNumber]
const [useProvideColumnCreateStore, useColumnCreateStore] = createInjectionState(

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

@ -3,17 +3,22 @@ import type { ColumnType, TableType } from 'nocodb-sdk'
import type { Ref } from 'vue'
import { message } from 'ant-design-vue'
import dayjs from 'dayjs'
import { useApi, useInjectionState, useProject, useProvideSmartsheetRowStore } from '#imports'
import { NOCO } from '~/lib'
import { useNuxtApp } from '#app'
import type { Row } from '~/composables/useViewData'
import { extractPkFromRow, extractSdkResponseErrorMsg } from '~/utils'
import {
NOCO,
extractPkFromRow,
extractSdkResponseErrorMsg,
useApi,
useInjectionState,
useNuxtApp,
useProject,
useProvideSmartsheetRowStore,
} from '#imports'
import type { Row } from '~/composables'
const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((meta: Ref<TableType>, row: Ref<Row>) => {
const { $e, $state, $api } = useNuxtApp()
const { api, isLoading: isCommentsLoading, error: commentsError } = useApi()
// { useGlobalInstance: true },
// state
const commentsOnly = ref(false)
const commentsAndLogs = ref([])
const comment = ref('')
@ -84,11 +89,14 @@ const [useProvideExpandedFormStore, useExpandedFormStore] = useInjectionState((m
await api.utils.commentRow({
fk_model_id: meta.value?.id as string,
row_id: rowId,
// todo: description missing from argument type
description: comment.value,
})
} as any)
comment.value = ''
message.success('Comment added successfully')
await loadCommentsAndLogs()
} catch (e: any) {
message.error(e.message)

16
packages/nc-gui-v2/composables/useGlobal/state.ts

@ -72,7 +72,21 @@ export function useGlobalState(storageKey = 'nocodb-gui-v2'): State {
set: (val) => (storage.value.token = val),
})
const appInfo = ref<AppInfo>({ ncSiteUrl: 'localhost:8080' })
const appInfo = ref<AppInfo>({
ncSiteUrl: 'localhost:8080',
authType: 'jwt',
connectToExternalDB: false,
defaultLimit: 0,
firstUser: true,
githubAuthEnabled: false,
googleAuthEnabled: true,
ncMin: false,
oneClick: false,
projectHasAdmin: false,
teleEnabled: true,
type: 'nocodb',
version: '0.0.0',
})
/** reactive token payload */
const { payload } = useJwt<JwtPayload & User>(token)

2
packages/nc-gui-v2/composables/useGlobal/types.ts

@ -13,7 +13,7 @@ export interface FeedbackForm {
export interface AppInfo {
ncSiteUrl: string
authType: 'jwt' | 'masterKey' | 'none'
authType: 'jwt' | 'none'
connectToExternalDB: boolean
defaultLimit: number
firstUser: boolean

33
packages/nc-gui-v2/composables/useLTARStore.ts

@ -1,10 +1,18 @@
import type { ColumnType, LinkToAnotherRecordType, PaginatedType, TableType } from 'nocodb-sdk'
import type { ComputedRef, Ref } from 'vue'
import { Modal, message } from 'ant-design-vue'
import { useInjectionState, useMetas, useProject } from '#imports'
import { NOCO } from '~/lib'
import {
NOCO,
computed,
extractSdkResponseErrorMsg,
reactive,
ref,
useInjectionState,
useMetas,
useNuxtApp,
useProject,
} from '#imports'
import type { Row } from '~/composables'
import { extractSdkResponseErrorMsg } from '~/utils'
interface DataApiResponse {
list: Record<string, any>
@ -13,13 +21,13 @@ interface DataApiResponse {
/** Store for managing Link to another cells */
const [useProvideLTARStore, useLTARStore] = useInjectionState(
(column: Ref<Required<ColumnType>>, row?: Ref<Row>, isNewRow: ComputedRef<boolean> | Ref<boolean>, reloadData = () => {}) => {
(column: Ref<Required<ColumnType>>, row: Ref<Row>, isNewRow: ComputedRef<boolean> | Ref<boolean>, reloadData = () => {}) => {
// state
const { metas, getMeta } = useMetas()
const { project } = useProject()
const { $api } = useNuxtApp()
const childrenExcludedList: Ref<DataApiResponse | undefined> = ref()
const childrenList: Ref<DataApiResponse | undefined> = ref()
const childrenExcludedList = ref<DataApiResponse | undefined>()
const childrenList = ref<DataApiResponse | undefined>()
const childrenExcludedListPagination = reactive({
page: 1,
query: '',
@ -95,12 +103,13 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
colOptions.type as 'mm' | 'hm',
column?.value?.title,
{
limit: childrenExcludedListPagination.size,
offset: childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1),
limit: String(childrenExcludedListPagination.size),
offset: String(childrenExcludedListPagination.size * (childrenExcludedListPagination.page - 1)),
// todo: where clause is missing from type
where:
childrenExcludedListPagination.query &&
`(${relatedTablePrimaryValueProp.value},like,${childrenExcludedListPagination.query})`,
},
} as any,
)
}
} catch (e: any) {
@ -120,10 +129,10 @@ const [useProvideLTARStore, useLTARStore] = useInjectionState(
colOptions.type as 'mm' | 'hm',
column?.value?.title,
{
limit: childrenListPagination.size,
offset: childrenListPagination.size * (childrenListPagination.page - 1),
limit: String(childrenListPagination.size),
offset: String(childrenListPagination.size * (childrenListPagination.page - 1)),
where: childrenListPagination.query && `(${relatedTablePrimaryValueProp.value},like,${childrenListPagination.query})`,
},
} as any,
)
} catch (e: any) {
message.error(`Failed to load children list: ${await extractSdkResponseErrorMsg(e)}`)

3
packages/nc-gui-v2/composables/useViewColumns.ts

@ -113,7 +113,8 @@ export function useViewColumns(
const showSystemFields = computed({
get() {
return view?.value?.show_system_fields || false
// todo: show_system_fields missing from ViewType
return (view?.value as any)?.show_system_fields || false
},
set(v: boolean) {
if (view?.value?.id) {

5
packages/nc-gui-v2/composables/useViewFilters.ts

@ -78,10 +78,11 @@ export function useViewFilters(
fk_parent_id: parentId,
})
} else {
filters.value[i] = await $api.dbTableFilter.create(view?.value?.id as string, {
// todo: return type of dbTableFilter is void?
filters.value[i] = (await $api.dbTableFilter.create(view?.value?.id as string, {
...filter,
fk_parent_id: parentId,
})
})) as any
}
reloadData?.()
}

5
packages/nc-gui-v2/composables/useViews.ts

@ -1,16 +1,17 @@
import type { TableType, ViewType } from 'nocodb-sdk'
import type { MaybeRef } from '@vueuse/core'
import { useNuxtApp } from '#app'
import { unref, useNuxtApp, watch } from '#imports'
export function useViews(meta: MaybeRef<TableType | undefined>) {
let views = $ref<ViewType[]>([])
const { $api } = useNuxtApp()
const loadViews = async () => {
const _meta = unref(meta)
if (_meta && _meta.id) {
const response = (await $api.dbView.list(_meta.id)).list
const response = (await $api.dbView.list(_meta.id)).list as ViewType[]
if (response) {
views = response.sort((a, b) => a.order! - b.order!)
}

Loading…
Cancel
Save