From e31ad66aafcab929c1f0db64707ef58442d4893d Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Sun, 14 Aug 2022 07:31:41 +0200 Subject: [PATCH] chore(gui-v2): cleanup typecheck issues --- .../nc-gui-v2/components/cell/DatePicker.vue | 15 ++--- .../nc-gui-v2/components/cell/YearPicker.vue | 15 +++-- .../components/general/ColorPicker.vue | 14 ++--- .../smartsheet-toolbar/MoreActions.vue | 60 ++++++++++--------- 4 files changed, 55 insertions(+), 49 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/DatePicker.vue b/packages/nc-gui-v2/components/cell/DatePicker.vue index 3b95868d8d..3b17503d6b 100644 --- a/packages/nc-gui-v2/components/cell/DatePicker.vue +++ b/packages/nc-gui-v2/components/cell/DatePicker.vue @@ -1,19 +1,18 @@ @@ -63,7 +64,7 @@ watch( :bordered="false" class="!w-full px-1" :format="dateFormat" - :placeholder="isDateInvalid ? 'Invalid date' : !readOnlyMode ? 'Select date' : ''" + :placeholder="placeholder" :allow-clear="!editEnabled" :input-read-only="true" :dropdown-class-name="randomClass" diff --git a/packages/nc-gui-v2/components/cell/YearPicker.vue b/packages/nc-gui-v2/components/cell/YearPicker.vue index 940fe3a4e9..039331df24 100644 --- a/packages/nc-gui-v2/components/cell/YearPicker.vue +++ b/packages/nc-gui-v2/components/cell/YearPicker.vue @@ -1,17 +1,16 @@ @@ -61,7 +62,7 @@ watch( picker="year" :bordered="false" class="!w-full px-1" - :placeholder="isYearInvalid ? 'Invalid year' : !readOnlyMode ? 'Select year' : ''" + :placeholder="placeholder" :allow-clear="!editEnabled" :input-read-only="true" :open="editEnabled ? false : open" @@ -72,5 +73,3 @@ watch( - - diff --git a/packages/nc-gui-v2/components/general/ColorPicker.vue b/packages/nc-gui-v2/components/general/ColorPicker.vue index 7511b0f9a9..d0d810a522 100644 --- a/packages/nc-gui-v2/components/general/ColorPicker.vue +++ b/packages/nc-gui-v2/components/general/ColorPicker.vue @@ -4,7 +4,7 @@ import { enumColor } from '@/utils' import { computed, ref, watch } from '#imports' interface Props { - modelValue: string | any + modelValue?: string | any colors?: string[] rowSize?: number advanced?: boolean @@ -28,18 +28,18 @@ const vModel = computed({ }, }) -const picked = ref(props.modelValue || enumColor.light[0]) +const picked = ref>(props.modelValue || enumColor.light[0]) -const selectColor = (color: Record) => { - picked.value = color.hex ? color.hex : color - vModel.value = color.hex ? color.hex : color +const selectColor = (color: string | Record) => { + picked.value = typeof color === 'string' ? color : color.hex ? color.hex : color + vModel.value = typeof color === 'string' ? color : color.hex ? color.hex : color } const compare = (colorA: string, colorB: string) => colorA.toLowerCase() === colorB.toLowerCase() watch(picked, (n, _o) => { if (!props.pickButton) { - vModel.value = n.hex ? n.hex : n + vModel.value = typeof n === 'string' ? n : n.hex ? n.hex : n } }) @@ -48,7 +48,7 @@ watch(picked, (n, _o) => { import * as XLSX from 'xlsx' -import { ExportTypes } from 'nocodb-sdk' +// todo: export types is missing EXCEL +// import { ExportTypes } from 'nocodb-sdk' import FileSaver from 'file-saver' import { message } from 'ant-design-vue' -import { useNuxtApp } from '#app' -import { useProject } from '#imports' -import { ActiveViewInj, MetaInj } from '~/context' -import { extractSdkResponseErrorMsg } from '~/utils' -import MdiFlashIcon from '~icons/mdi/flash-outline' -import MdiMenuDownIcon from '~icons/mdi/menu-down' -import MdiDownloadIcon from '~icons/mdi/download-outline' -import MdiUploadIcon from '~icons/mdi/upload-outline' -import MdiHookIcon from '~icons/mdi/hook' -import MdiViewListIcon from '~icons/mdi/view-list-outline' +import { + ActiveViewInj, + MetaInj, + extractSdkResponseErrorMsg, + inject, + ref, + useNuxtApp, + useProject, + useUIPermission, +} from '#imports' + +enum ExportTypes { + EXCEL = 'excel', + CSV = 'csv', +} const sharedViewListDlg = ref(false) @@ -22,14 +28,6 @@ const isView = false // TODO: pending for shared view -// interface Props { -// publicViewId?: string -// queryParams?: Record -// reqPayload?: Record -// } - -// const { publicViewId, queryParams, reqPayload } = defineProps() - const { project } = useProject() const { $api } = useNuxtApp() @@ -44,7 +42,7 @@ const quickImportDialog = ref(false) const { isUIAllowed } = useUIPermission() -const exportFile = async (exportType: ExportTypes.EXCEL | ExportTypes.CSV) => { +const exportFile = async (exportType: ExportTypes) => { let offset = 0 let c = 1 const responseType = exportType === ExportTypes.EXCEL ? 'base64' : 'blob' @@ -114,52 +112,59 @@ const exportFile = async (exportType: ExportTypes.EXCEL | ExportTypes.CSV) => { - + + {{ $t('general.more') }} - + + + - + {{ $t('activity.downloadCSV') }} + - + {{ $t('activity.downloadExcel') }} + - + {{ $t('activity.uploadCSV') }} + - + {{ $t('activity.listSharedView') }} + - + {{ $t('objects.webhooks') }} @@ -168,6 +173,7 @@ const exportFile = async (exportType: ExportTypes.EXCEL | ExportTypes.CSV) => { +