Browse Source

refactor(gui): group imports

Signed-off-by: Pranav C <pranavxc@gmail.com>
pull/4504/head
Pranav C 2 years ago
parent
commit
49098822ac
  1. 2
      packages/nc-gui/components/account/SignupSettings.vue
  2. 17
      packages/nc-gui/components/smartsheet/Grid.vue
  3. 2
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  4. 18
      packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue
  5. 6
      packages/nc-gui/components/smartsheet/header/Cell.vue
  6. 21
      packages/nc-gui/components/smartsheet/header/Menu.vue
  7. 6
      packages/nc-gui/components/smartsheet/header/VirtualCell.vue
  8. 11
      packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue
  9. 2
      packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue
  10. 8
      packages/nc-gui/components/virtual-cell/QrCode.vue
  11. 13
      packages/nc-gui/utils/columnUtils.ts

2
packages/nc-gui/components/account/SignupSettings.vue

@ -51,6 +51,6 @@ loadSettings()
<style scoped> <style scoped>
:deep(.ant-checkbox-wrapper) { :deep(.ant-checkbox-wrapper) {
@apply !flex-row-reverse !flex !justify-start gap-4; @apply !flex-row-reverse !flex !justify-start gap-4;
justify-content: start; justify-content: flex-start;
} }
</style> </style>

17
packages/nc-gui/components/smartsheet/Grid.vue

@ -11,11 +11,13 @@ import {
IsGridInj, IsGridInj,
IsLockedInj, IsLockedInj,
MetaInj, MetaInj,
NavigateDir,
OpenNewRecordFormHookInj, OpenNewRecordFormHookInj,
PaginationDataInj, PaginationDataInj,
ReadonlyInj, ReadonlyInj,
ReloadRowDataHookInj, ReloadRowDataHookInj,
ReloadViewDataHookInj, ReloadViewDataHookInj,
SmartsheetStoreEvents,
computed, computed,
createEventHook, createEventHook,
enumColor, enumColor,
@ -42,7 +44,6 @@ import {
watch, watch,
} from '#imports' } from '#imports'
import type { Row } from '~/lib' import type { Row } from '~/lib'
import { NavigateDir, SmartsheetStoreEvents } from '~/lib'
const { t } = useI18n() const { t } = useI18n()
@ -545,17 +546,17 @@ watch(
{ immediate: true }, { immediate: true },
) )
const columnPosition = ref<Pick<ColumnReqType, 'column_order'> | null>(null) const columnOrder = ref<Pick<ColumnReqType, 'column_order'> | null>(null)
eventBus.on(async (event, payload) => { eventBus.on(async (event, payload) => {
if (event === SmartsheetStoreEvents.FIELD_ADD) { if (event === SmartsheetStoreEvents.FIELD_ADD) {
columnPosition.value = payload columnOrder.value = payload
addColumnDropdown.value = true addColumnDropdown.value = true
} }
}) })
const closeAddColumnMenu = () => { const closeAddColumnDropdown = () => {
columnPosition.value = null columnOrder.value = null
addColumnDropdown.value = false addColumnDropdown.value = false
} }
</script> </script>
@ -633,9 +634,9 @@ const closeAddColumnMenu = () => {
<template #overlay> <template #overlay>
<SmartsheetColumnEditOrAddProvider <SmartsheetColumnEditOrAddProvider
v-if="addColumnDropdown" v-if="addColumnDropdown"
:column-position="columnPosition" :column-position="columnOrder"
@submit="closeAddColumnMenu" @submit="closeAddColumnDropdown"
@cancel="closeAddColumnMenu" @cancel="closeAddColumnDropdown"
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />

2
packages/nc-gui/components/smartsheet/column/EditOrAdd.vue

@ -1,5 +1,4 @@
<script lang="ts" setup> <script lang="ts" setup>
import { useEventListener } from '@vueuse/core'
import type { ColumnReqType } from 'nocodb-sdk' import type { ColumnReqType } from 'nocodb-sdk'
import { UITypes, isVirtualCol } from 'nocodb-sdk' import { UITypes, isVirtualCol } from 'nocodb-sdk'
import { import {
@ -14,6 +13,7 @@ import {
ref, ref,
uiTypes, uiTypes,
useColumnCreateStoreOrThrow, useColumnCreateStoreOrThrow,
useEventListener,
useI18n, useI18n,
useMetas, useMetas,
useNuxtApp, useNuxtApp,

18
packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue

@ -1,5 +1,6 @@
<script setup lang="ts"> <script setup lang="ts">
import { AllowedColumnTypesForQrCode, UITypes } from 'nocodb-sdk' import type { UITypes } from 'nocodb-sdk'
import { AllowedColumnTypesForQrCode } from 'nocodb-sdk'
import type { SelectProps } from 'ant-design-vue' import type { SelectProps } from 'ant-design-vue'
import { useVModel } from '#imports' import { useVModel } from '#imports'
@ -50,10 +51,17 @@ setAdditionalValidations({
<template> <template>
<a-row> <a-row>
<a-col :span="24"> <a-col :span="24">
<a-form-item class="flex w-1/2 pb-2 nc-qr-code-value-column-select" :label="$t('labels.qrCodeValueColumn')" <a-form-item
v-bind="validateInfos.fk_qr_value_column_id"> class="flex w-1/2 pb-2 nc-qr-code-value-column-select"
<a-select v-model:value="vModel.fk_qr_value_column_id" :options="columnsAllowedAsQrValue" :label="$t('labels.qrCodeValueColumn')"
placeholder="Select a column for the QR code value" @click.stop /> v-bind="validateInfos.fk_qr_value_column_id"
>
<a-select
v-model:value="vModel.fk_qr_value_column_id"
:options="columnsAllowedAsQrValue"
placeholder="Select a column for the QR code value"
@click.stop
/>
</a-form-item> </a-form-item>
</a-col> </a-col>
</a-row> </a-row>

6
packages/nc-gui/components/smartsheet/header/Cell.vue

@ -25,7 +25,7 @@ const addField = async (payload) => {
editColumnDropdown.value = true editColumnDropdown.value = true
} }
const closeAddColumnMenu = () => { const closeAddColumnDropdown = () => {
columnOrder.value = null columnOrder.value = null
editColumnDropdown.value = false editColumnDropdown.value = false
} }
@ -73,8 +73,8 @@ const closeAddColumnMenu = () => {
:column="columnOrder ? null : column" :column="columnOrder ? null : column"
:column-position="columnOrder" :column-position="columnOrder"
class="w-full" class="w-full"
@submit="closeAddColumnMenu" @submit="closeAddColumnDropdown"
@cancel="closeAddColumnMenu" @cancel="closeAddColumnDropdown"
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />

21
packages/nc-gui/components/smartsheet/header/Menu.vue

@ -1,24 +1,25 @@
<script lang="ts" setup> <script lang="ts" setup>
import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk' import type { LinkToAnotherRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes } from 'nocodb-sdk' import { RelationTypes, UITypes } from 'nocodb-sdk'
import { import {
ActiveViewInj,
ColumnInj, ColumnInj,
IsLockedInj, IsLockedInj,
MetaInj, MetaInj,
Modal, Modal,
ReloadViewDataHookInj, ReloadViewDataHookInj,
SmartsheetStoreEvents,
defineEmits, defineEmits,
defineProps, defineProps,
extractSdkResponseErrorMsg, extractSdkResponseErrorMsg,
getUniqueColumnName,
inject, inject,
message, message,
useI18n, useI18n,
useMetas, useMetas,
useNuxtApp, useNuxtApp,
useSmartsheetStoreOrThrow,
} from '#imports' } from '#imports'
import { useSmartsheetStoreOrThrow } from '~/composables/useSmartsheetStore'
import { ActiveViewInj } from '~/context'
import { SmartsheetStoreEvents } from '~/lib'
const { virtual = false } = defineProps<{ virtual?: boolean }>() const { virtual = false } = defineProps<{ virtual?: boolean }>()
@ -92,21 +93,11 @@ const sortByColumn = async (direction: 'asc' | 'desc') => {
}) })
eventBus.emit(SmartsheetStoreEvents.SORT_RELOAD) eventBus.emit(SmartsheetStoreEvents.SORT_RELOAD)
reloadDataHook?.trigger() reloadDataHook?.trigger()
} catch (e: any) { } catch (e) {
message.error(await extractSdkResponseErrorMsg(e)) message.error(await extractSdkResponseErrorMsg(e))
} }
} }
const getUniqueColumnName = (initName: string, columns: ColumnType[]) => {
let name = initName
let i = 1
while (columns.find((c) => c.title === name)) {
name = `${initName}_${i}`
i++
}
return name
}
const duplicateColumn = async () => { const duplicateColumn = async () => {
let columnCreatePayload = {} let columnCreatePayload = {}

6
packages/nc-gui/components/smartsheet/header/VirtualCell.vue

@ -107,7 +107,7 @@ const addField = async (payload) => {
editColumnDropdown.value = true editColumnDropdown.value = true
} }
const closeAddColumnMenu = () => { const closeAddColumnDropdown = () => {
columnOrder.value = null columnOrder.value = null
editColumnDropdown.value = false editColumnDropdown.value = false
} }
@ -151,8 +151,8 @@ const closeAddColumnMenu = () => {
:column="columnOrder ? null : column" :column="columnOrder ? null : column"
:column-position="columnOrder" :column-position="columnOrder"
class="w-full" class="w-full"
@submit="closeAddColumnMenu" @submit="closeAddColumnDropdown"
@cancel="closeAddColumnMenu" @cancel="closeAddColumnDropdown"
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />

11
packages/nc-gui/components/smartsheet/toolbar/FieldListAutoCompleteDropdown.vue

@ -51,9 +51,14 @@ const filterOption = (input: string, option: any) => option.label.toLowerCase()?
</script> </script>
<template> <template>
<a-select v-model:value="localValue" :dropdown-match-select-width="false" show-search <a-select
:placeholder="$t('placeholder.selectField')" :filter-option="filterOption" v-model:value="localValue"
dropdown-class-name="nc-dropdown-toolbar-field-list"> :dropdown-match-select-width="false"
show-search
:placeholder="$t('placeholder.selectField')"
:filter-option="filterOption"
dropdown-class-name="nc-dropdown-toolbar-field-list"
>
<a-select-option v-for="option in options" :key="option.value" :label="option.label" :value="option.value"> <a-select-option v-for="option in options" :key="option.value" :label="option.label" :value="option.value">
<div class="flex gap-2 items-center items-center h-full"> <div class="flex gap-2 items-center items-center h-full">
<component :is="option.icon" class="min-w-5 !mx-0" /> <component :is="option.icon" class="min-w-5 !mx-0" />

2
packages/nc-gui/components/smartsheet/toolbar/FieldsMenu.vue

@ -16,10 +16,10 @@ import {
resolveComponent, resolveComponent,
useMenuCloseOnEsc, useMenuCloseOnEsc,
useNuxtApp, useNuxtApp,
useSmartsheetStoreOrThrow,
useViewColumns, useViewColumns,
watch, watch,
} from '#imports' } from '#imports'
import { useSmartsheetStoreOrThrow } from '~/composables/useSmartsheetStore'
const meta = inject(MetaInj, ref()) const meta = inject(MetaInj, ref())

8
packages/nc-gui/components/virtual-cell/QrCode.vue

@ -30,8 +30,12 @@ const { showEditNonEditableFieldWarning, showClearNonEditableFieldWarning } = us
</script> </script>
<template> <template>
<a-modal v-model:visible="modalVisible" wrap-class-name="nc-qr-code-large" :body-style="{ padding: '0px' }" <a-modal
@ok="handleModalOkClick"> v-model:visible="modalVisible"
wrap-class-name="nc-qr-code-large"
:body-style="{ padding: '0px' }"
@ok="handleModalOkClick"
>
<template #footer> <template #footer>
<div class="mr-4" data-testid="nc-qr-code-large-value-label">{{ qrValue }}</div> <div class="mr-4" data-testid="nc-qr-code-large-value-label">{{ qrValue }}</div>
</template> </template>

13
packages/nc-gui/utils/columnUtils.ts

@ -1,7 +1,6 @@
import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk' import type { ColumnType, LinkToAnotherRecordType } from 'nocodb-sdk'
import { RelationTypes, UITypes } from 'nocodb-sdk' import { RelationTypes, UITypes } from 'nocodb-sdk'
import LinkVariant from '~icons/mdi/link-variant' import LinkVariant from '~icons/mdi/link-variant'
import TableColumnPlusBefore from '~icons/mdi/table-column-plus-before'
import QrCodeScan from '~icons/mdi/qrcode-scan' import QrCodeScan from '~icons/mdi/qrcode-scan'
import FormatColorText from '~icons/mdi/format-color-text' import FormatColorText from '~icons/mdi/format-color-text'
import TextSubject from '~icons/mdi/text-subject' import TextSubject from '~icons/mdi/text-subject'
@ -181,4 +180,14 @@ const isColumnRequiredAndNull = (col: ColumnType, row: Record<string, any>) => {
return isColumnRequired(col) && (row[col.title!] === undefined || row[col.title!] === null) return isColumnRequired(col) && (row[col.title!] === undefined || row[col.title!] === null)
} }
export { uiTypes, getUIDTIcon, isColumnRequiredAndNull, isColumnRequired, isVirtualColRequired } const getUniqueColumnName = (initName: string, columns: ColumnType[]) => {
let name = initName
let i = 1
while (columns.find((c) => c.title === name)) {
name = `${initName}_${i}`
i++
}
return name
}
export { uiTypes, getUIDTIcon, getUniqueColumnName, isColumnRequiredAndNull, isColumnRequired, isVirtualColRequired }

Loading…
Cancel
Save