From 704b641ed091a6f3867c5bbf191800e00b82b5ce Mon Sep 17 00:00:00 2001 From: braks <78412429+bcakmakoglu@users.noreply.github.com> Date: Mon, 8 Aug 2022 20:58:08 +0200 Subject: [PATCH] chore(gui-v2): fix types in components --- .../nc-gui-v2/components/cell/Currency.vue | 8 +-- packages/nc-gui-v2/components/cell/Json.vue | 59 +++++++++++-------- packages/nc-gui-v2/components/cell/Url.vue | 6 +- .../components/cell/attachment/Modal.vue | 5 -- .../components/dashboard/settings/UIAcl.vue | 14 +++-- .../nc-gui-v2/components/general/Language.vue | 11 ++-- .../smartsheet-column/AdvancedOptions.vue | 6 +- .../smartsheet-column/RollupOptions.vue | 38 ++++++------ .../smartsheet-toolbar/FieldsMenu.vue | 54 +++++++---------- .../components/smartsheet/sidebar/MenuTop.vue | 8 +-- .../tabs/auth/user-management/ShareBase.vue | 49 ++++++++------- .../components/virtual-cell/BelongsTo.vue | 18 ++++-- .../components/virtual-cell/HasMany.vue | 25 ++++---- .../components/virtual-cell/ManyToMany.vue | 24 ++++---- .../components/ListChildItems.vue | 22 +++---- .../virtual-cell/components/ListItems.vue | 13 ++-- .../nc-gui-v2/components/webhook/List.vue | 8 +-- .../composables/useColumnCreateStore.ts | 1 + 18 files changed, 189 insertions(+), 180 deletions(-) diff --git a/packages/nc-gui-v2/components/cell/Currency.vue b/packages/nc-gui-v2/components/cell/Currency.vue index c385621f4c..85cdd3cf63 100644 --- a/packages/nc-gui-v2/components/cell/Currency.vue +++ b/packages/nc-gui-v2/components/cell/Currency.vue @@ -26,14 +26,12 @@ const currencyMeta = computed(() => { }) const currency = computed(() => { - if (!vModel.value) return null - try { - return isNaN(vModel.value) + return !vModel.value || isNaN(vModel.value) ? vModel.value - : new Intl.NumberFormat(currencyMeta?.value?.currency_locale || 'en-US', { + : new Intl.NumberFormat(currencyMeta.value.currency_locale || 'en-US', { style: 'currency', - currency: currencyMeta?.value?.currency_code || 'USD', + currency: currencyMeta.value.currency_code || 'USD', }).format(vModel.value) } catch (e) { return vModel.value diff --git a/packages/nc-gui-v2/components/cell/Json.vue b/packages/nc-gui-v2/components/cell/Json.vue index cf98c46c49..98b8944b29 100644 --- a/packages/nc-gui-v2/components/cell/Json.vue +++ b/packages/nc-gui-v2/components/cell/Json.vue @@ -1,9 +1,7 @@ @@ -86,16 +91,20 @@ watch(editEnabled, () => {
- - + + + +
Cancel
+
Save
+ { :disable-deep-compare="true" @update:model-value="localValue = $event" /> + {{ error.toString() }}
+ {{ vModel }} diff --git a/packages/nc-gui-v2/components/cell/Url.vue b/packages/nc-gui-v2/components/cell/Url.vue index 64cf7f17de..a5686bfef2 100644 --- a/packages/nc-gui-v2/components/cell/Url.vue +++ b/packages/nc-gui-v2/components/cell/Url.vue @@ -12,14 +12,14 @@ const { modelValue: value } = defineProps() const emit = defineEmits(['update:modelValue']) -const column = inject(ColumnInj) +const column = inject(ColumnInj)! const editEnabled = inject(EditModeInj, ref(false)) const vModel = computed({ get: () => value, set: (val) => { - if (!column?.value?.meta?.validate || (val && isValidURL(val))) { + if (!column.value.meta?.validate || (val && isValidURL(val))) { emit('update:modelValue', val) } }, @@ -32,7 +32,7 @@ const focus: VNodeRef = (el) => (el as HTMLInputElement)?.focus() diff --git a/packages/nc-gui-v2/components/cell/attachment/Modal.vue b/packages/nc-gui-v2/components/cell/attachment/Modal.vue index 5e7e2b70ac..c17763bdce 100644 --- a/packages/nc-gui-v2/components/cell/attachment/Modal.vue +++ b/packages/nc-gui-v2/components/cell/attachment/Modal.vue @@ -4,11 +4,6 @@ import { useAttachmentCell } from './utils' import { useSortable } from './sort' import { ref, useDropZone, useUIPermission } from '#imports' import { isImage, openLink } from '~/utils' -import MaterialSymbolsAttachFile from '~icons/material-symbols/attach-file' -import MdiCloseCircle from '~icons/mdi/close-circle' -import MdiDownload from '~icons/mdi/download' -import MaterialSymbolsFileCopyOutline from '~icons/material-symbols/file-copy-outline' -import IcOutlineInsertDriveFile from '~icons/ic/outline-insert-drive-file' const { isUIAllowed } = useUIPermission() diff --git a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue index 41c4d41f93..e5f17f339e 100644 --- a/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue +++ b/packages/nc-gui-v2/components/dashboard/settings/UIAcl.vue @@ -1,18 +1,20 @@ @@ -64,7 +70,7 @@ const columns = $computed(() => {
- +
{{ table.column.title }}
({{ relationNames[table.col.type] }} {{ table.title || table.table_name }})
@@ -79,7 +85,7 @@ const columns = $computed(() => { size="small" @change="onDataTypeChange" > - + {{ column.title }} @@ -87,12 +93,10 @@ const columns = $computed(() => {
- + {{ func.text }}
- - diff --git a/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue b/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue index ff4ec2a87e..74c592ba37 100644 --- a/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue +++ b/packages/nc-gui-v2/components/smartsheet-toolbar/FieldsMenu.vue @@ -1,21 +1,11 @@ @@ -80,11 +69,12 @@ const onMove = (event: { moved: { newIndex: number } }) => {
- - + + {{ $t('objects.fields') }} - + +
@@ -101,7 +91,7 @@ const onMove = (event: { moved: { newIndex: number } }) => { {{ field.title }}
- +
diff --git a/packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue b/packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue index 621e618b2f..8506b8d8df 100644 --- a/packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue +++ b/packages/nc-gui-v2/components/smartsheet/sidebar/MenuTop.vue @@ -6,9 +6,9 @@ import { notification } from 'ant-design-vue' import type { Ref } from 'vue' import Sortable from 'sortablejs' import RenameableMenuItem from './RenameableMenuItem.vue' -import { inject, onMounted, ref, useApi, useTabs, watch } from '#imports' +import { inject, onMounted, ref, useApi, useRouter, watch } from '#imports' import { extractSdkResponseErrorMsg } from '~/utils' -import { ActiveViewInj, MetaInj, ViewListInj } from '~/context' +import { ActiveViewInj, ViewListInj } from '~/context' interface Emits { (event: 'openModal', data: { type: ViewTypes; title?: string }): void @@ -22,10 +22,6 @@ const activeView = inject(ActiveViewInj, ref()) const views = inject>(ViewListInj, ref([])) -const meta = inject(MetaInj) - -const { addTab } = useTabs() - const { api } = useApi() const router = useRouter() diff --git a/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue b/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue index db4d128caf..cdd6506c1c 100644 --- a/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue +++ b/packages/nc-gui-v2/components/tabs/auth/user-management/ShareBase.vue @@ -1,13 +1,8 @@ @@ -31,7 +37,7 @@ await loadRelatedTableMeta()
- diff --git a/packages/nc-gui-v2/components/virtual-cell/HasMany.vue b/packages/nc-gui-v2/components/virtual-cell/HasMany.vue index 151a9d374a..2207f0ea3a 100644 --- a/packages/nc-gui-v2/components/virtual-cell/HasMany.vue +++ b/packages/nc-gui-v2/components/virtual-cell/HasMany.vue @@ -4,24 +4,27 @@ import type { Ref } from 'vue' import ItemChip from './components/ItemChip.vue' import ListChildItems from './components/ListChildItems.vue' import ListItems from './components/ListItems.vue' -import { useProvideLTARStore } from '#imports' +import { inject, ref, useProvideLTARStore } from '#imports' import { CellValueInj, ColumnInj, ReloadViewDataHookInj, RowInj } from '~/context' -import MdiExpandIcon from '~icons/mdi/arrow-expand' -import MdiPlusIcon from '~icons/mdi/plus' -const column = inject(ColumnInj) -const cellValue = inject(CellValueInj) -const row = inject(RowInj) -const reloadTrigger = inject(ReloadViewDataHookInj) +const column = inject(ColumnInj)! + +const cellValue = inject(CellValueInj)! + +const row = inject(RowInj)! + +const reloadTrigger = inject(ReloadViewDataHookInj)! const listItemsDlg = ref(false) + const childListDlg = ref(false) -const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( +const { loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( column as Ref>, row, - () => reloadTrigger?.trigger(), + reloadTrigger.trigger, ) + await loadRelatedTableMeta() @@ -34,11 +37,11 @@ await loadRelatedTableMeta()
- - +
diff --git a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue index a08a3c80d9..de005cffeb 100644 --- a/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue +++ b/packages/nc-gui-v2/components/virtual-cell/ManyToMany.vue @@ -4,23 +4,25 @@ import type { Ref } from 'vue' import ItemChip from './components/ItemChip.vue' import ListChildItems from './components/ListChildItems.vue' import ListItems from './components/ListItems.vue' -import { useProvideLTARStore } from '#imports' +import { inject, ref, useProvideLTARStore } from '#imports' import { CellValueInj, ColumnInj, ReloadViewDataHookInj, RowInj } from '~/context' -import MdiExpandIcon from '~icons/mdi/arrow-expand' -import MdiPlusIcon from '~icons/mdi/plus' -const column = inject(ColumnInj) -const row = inject(RowInj) -const cellValue = inject(CellValueInj) -const reloadTrigger = inject(ReloadViewDataHookInj) +const column = inject(ColumnInj)! + +const row = inject(RowInj)! + +const cellValue = inject(CellValueInj)! + +const reloadTrigger = inject(ReloadViewDataHookInj)! const listItemsDlg = ref(false) + const childListDlg = ref(false) -const { relatedTableMeta, loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( +const { loadRelatedTableMeta, relatedTablePrimaryValueProp, unlink } = useProvideLTARStore( column as Ref>, row, - () => reloadTrigger?.trigger(), + reloadTrigger.trigger, ) await loadRelatedTableMeta() @@ -37,8 +39,8 @@ await loadRelatedTableMeta()
- - + +
diff --git a/packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue b/packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue index df612cc0ae..8d5a297026 100644 --- a/packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue +++ b/packages/nc-gui-v2/components/virtual-cell/components/ListChildItems.vue @@ -1,10 +1,8 @@ @@ -36,12 +35,13 @@ const unlinkRow = async (row: Record) => {
-
- + + +
- + Link to '{{ meta.title }}'
@@ -56,8 +56,8 @@ const unlinkRow = async (row: Record) => {
- - + +
diff --git a/packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue b/packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue index c4d92762bf..82ae0ae503 100644 --- a/packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue +++ b/packages/nc-gui-v2/components/virtual-cell/components/ListItems.vue @@ -1,9 +1,9 @@ @@ -40,7 +39,7 @@ const linkRow = async (row: Record) => { size="small" >
- + Add new record