Browse Source

Nc feat: improve lazy loading for field edit or add (#8846)

* feat: improve lazy loading for field edit or add

* fix(nc-gui): use isEdit.value instead of isEdit

* fix(nocodb): validate required params in qr/barcode column create

---------

Co-authored-by: mertmit <mertmit99@gmail.com>
pull/8870/head
Ramesh Mane 5 months ago committed by GitHub
parent
commit
f141049937
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
  1. 8
      packages/nc-gui/components/smartsheet/Details.vue
  2. 8
      packages/nc-gui/components/smartsheet/Form.vue
  3. 2
      packages/nc-gui/components/smartsheet/column/BarcodeOptions.vue
  4. 38
      packages/nc-gui/components/smartsheet/column/EditOrAdd.vue
  5. 2
      packages/nc-gui/components/smartsheet/column/QrCodeOptions.vue
  6. 4
      packages/nc-gui/components/smartsheet/grid/Table.vue
  7. 4
      packages/nc-gui/components/smartsheet/header/Cell.vue
  8. 4
      packages/nc-gui/components/smartsheet/header/VirtualCell.vue
  9. 2
      packages/nc-gui/components/smartsheet/toolbar/KanbanStackEditOrAdd.vue
  10. 4
      packages/nocodb/src/services/columns.service.ts

8
packages/nc-gui/components/smartsheet/Details.vue

@ -60,7 +60,7 @@ watch(openedSubTab, () => {
<div>Fields</div> <div>Fields</div>
</div> </div>
</template> </template>
<SmartsheetDetailsFields /> <LazySmartsheetDetailsFields />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="relation"> <a-tab-pane key="relation">
<template #tab> <template #tab>
@ -69,7 +69,7 @@ watch(openedSubTab, () => {
<div>{{ $t('title.relations') }}</div> <div>{{ $t('title.relations') }}</div>
</div> </div>
</template> </template>
<SmartsheetDetailsErd /> <LazySmartsheetDetailsErd />
</a-tab-pane> </a-tab-pane>
<a-tab-pane key="api"> <a-tab-pane key="api">
@ -79,7 +79,7 @@ watch(openedSubTab, () => {
<div>{{ $t('labels.apiSnippet') }}</div> <div>{{ $t('labels.apiSnippet') }}</div>
</div> </div>
</template> </template>
<SmartsheetDetailsApi v-if="base && meta && view" /> <LazySmartsheetDetailsApi v-if="base && meta && view" />
<div v-else class="h-full w-full flex flex-col justify-center items-center mt-28 mb-4"> <div v-else class="h-full w-full flex flex-col justify-center items-center mt-28 mb-4">
<a-spin size="large" :indicator="indicator" /> <a-spin size="large" :indicator="indicator" />
</div> </div>
@ -92,7 +92,7 @@ watch(openedSubTab, () => {
<div>{{ $t('objects.webhooks') }}</div> <div>{{ $t('objects.webhooks') }}</div>
</div> </div>
</template> </template>
<SmartsheetDetailsWebhooks /> <LazySmartsheetDetailsWebhooks />
</a-tab-pane> </a-tab-pane>
</NcTabs> </NcTabs>
</div> </div>

8
packages/nc-gui/components/smartsheet/Form.vue

@ -1239,7 +1239,8 @@ useEventListener(
{{ $t('general.edit') }} {{ $t('objects.field') }} {{ $t('general.edit') }} {{ $t('objects.field') }}
</NcButton> </NcButton>
<template #overlay> <template #overlay>
<SmartsheetColumnEditOrAddProvider <div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider
v-if="dropdownStates.showEditColumn" v-if="dropdownStates.showEditColumn"
:column="activeColumn" :column="activeColumn"
@submit="editColumnCallback" @submit="editColumnCallback"
@ -1247,6 +1248,7 @@ useEventListener(
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
<SmartsheetFormFieldMenu <SmartsheetFormFieldMenu
@ -1325,13 +1327,15 @@ useEventListener(
</NcButton> </NcButton>
<template #overlay> <template #overlay>
<SmartsheetColumnEditOrAddProvider <div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider
v-if="dropdownStates.showAddColumn" v-if="dropdownStates.showAddColumn"
@submit="addColumnCallback" @submit="addColumnCallback"
@cancel="dropdownStates.showAddColumn = false" @cancel="dropdownStates.showAddColumn = false"
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
</div> </div>

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

@ -37,7 +37,7 @@ onMounted(() => {
} }
vModel.value.fk_barcode_value_column_id = vModel.value.fk_barcode_value_column_id =
(column?.value?.colOptions as Record<string, any>)?.fk_barcode_value_column_id || (column?.value?.colOptions as Record<string, any>)?.fk_barcode_value_column_id ||
(!isEdit ? columnsAllowedAsBarcodeValue.value?.[0]?.id : null) (!isEdit.value ? columnsAllowedAsBarcodeValue.value?.[0]?.id : null)
}) })
watch(columnsAllowedAsBarcodeValue, (newColumnsAllowedAsBarcodeValue) => { watch(columnsAllowedAsBarcodeValue, (newColumnsAllowedAsBarcodeValue) => {

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

@ -471,33 +471,33 @@ const isFullUpdateAllowed = computed(() => {
</div> </div>
<template v-if="!readOnly && formState.uidt"> <template v-if="!readOnly && formState.uidt">
<LazySmartsheetColumnFormulaOptions v-if="formState.uidt === UITypes.Formula" v-model:value="formState" /> <SmartsheetColumnFormulaOptions v-if="formState.uidt === UITypes.Formula" v-model:value="formState" />
<LazySmartsheetColumnQrCodeOptions v-if="formState.uidt === UITypes.QrCode" v-model="formState" /> <SmartsheetColumnQrCodeOptions v-if="formState.uidt === UITypes.QrCode" v-model="formState" />
<LazySmartsheetColumnBarcodeOptions v-if="formState.uidt === UITypes.Barcode" v-model="formState" /> <SmartsheetColumnBarcodeOptions v-if="formState.uidt === UITypes.Barcode" v-model="formState" />
<LazySmartsheetColumnCurrencyOptions v-if="formState.uidt === UITypes.Currency" v-model:value="formState" /> <SmartsheetColumnCurrencyOptions v-if="formState.uidt === UITypes.Currency" v-model:value="formState" />
<LazySmartsheetColumnLongTextOptions v-if="formState.uidt === UITypes.LongText" v-model:value="formState" /> <SmartsheetColumnLongTextOptions v-if="formState.uidt === UITypes.LongText" v-model:value="formState" />
<LazySmartsheetColumnDurationOptions v-if="formState.uidt === UITypes.Duration" v-model:value="formState" /> <SmartsheetColumnDurationOptions v-if="formState.uidt === UITypes.Duration" v-model:value="formState" />
<LazySmartsheetColumnRatingOptions v-if="formState.uidt === UITypes.Rating" v-model:value="formState" /> <SmartsheetColumnRatingOptions v-if="formState.uidt === UITypes.Rating" v-model:value="formState" />
<LazySmartsheetColumnCheckboxOptions v-if="formState.uidt === UITypes.Checkbox" v-model:value="formState" /> <SmartsheetColumnCheckboxOptions v-if="formState.uidt === UITypes.Checkbox" v-model:value="formState" />
<LazySmartsheetColumnLookupOptions v-if="formState.uidt === UITypes.Lookup" v-model:value="formState" /> <SmartsheetColumnLookupOptions v-if="formState.uidt === UITypes.Lookup" v-model:value="formState" />
<LazySmartsheetColumnDateOptions v-if="formState.uidt === UITypes.Date" v-model:value="formState" /> <SmartsheetColumnDateOptions v-if="formState.uidt === UITypes.Date" v-model:value="formState" />
<LazySmartsheetColumnTimeOptions v-if="formState.uidt === UITypes.Time" v-model:value="formState" /> <SmartsheetColumnTimeOptions v-if="formState.uidt === UITypes.Time" v-model:value="formState" />
<LazySmartsheetColumnNumberOptions v-if="formState.uidt === UITypes.Number" v-model:value="formState" /> <SmartsheetColumnNumberOptions v-if="formState.uidt === UITypes.Number" v-model:value="formState" />
<LazySmartsheetColumnDecimalOptions v-if="formState.uidt === UITypes.Decimal" v-model:value="formState" /> <SmartsheetColumnDecimalOptions v-if="formState.uidt === UITypes.Decimal" v-model:value="formState" />
<LazySmartsheetColumnDateTimeOptions <SmartsheetColumnDateTimeOptions
v-if="[UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(formState.uidt)" v-if="[UITypes.DateTime, UITypes.CreatedTime, UITypes.LastModifiedTime].includes(formState.uidt)"
v-model:value="formState" v-model:value="formState"
/> />
<LazySmartsheetColumnRollupOptions v-if="formState.uidt === UITypes.Rollup" v-model:value="formState" /> <SmartsheetColumnRollupOptions v-if="formState.uidt === UITypes.Rollup" v-model:value="formState" />
<LazySmartsheetColumnLinkedToAnotherRecordOptions <SmartsheetColumnLinkedToAnotherRecordOptions
v-if="formState.uidt === UITypes.LinkToAnotherRecord || formState.uidt === UITypes.Links" v-if="formState.uidt === UITypes.LinkToAnotherRecord || formState.uidt === UITypes.Links"
:key="`${formState.uidt}-${formState.id || formState.title}`" :key="`${formState.uidt}-${formState.id || formState.title}`"
v-model:value="formState" v-model:value="formState"
:is-edit="isEdit" :is-edit="isEdit"
/> />
<LazySmartsheetColumnPercentOptions v-if="formState.uidt === UITypes.Percent" v-model:value="formState" /> <SmartsheetColumnPercentOptions v-if="formState.uidt === UITypes.Percent" v-model:value="formState" />
<LazySmartsheetColumnSpecificDBTypeOptions v-if="formState.uidt === UITypes.SpecificDBType" /> <SmartsheetColumnSpecificDBTypeOptions v-if="formState.uidt === UITypes.SpecificDBType" />
<LazySmartsheetColumnUserOptions v-if="formState.uidt === UITypes.User" v-model:value="formState" :is-edit="isEdit" /> <SmartsheetColumnUserOptions v-if="formState.uidt === UITypes.User" v-model:value="formState" :is-edit="isEdit" />
<SmartsheetColumnSelectOptions <SmartsheetColumnSelectOptions
v-if="formState.uidt === UITypes.SingleSelect || formState.uidt === UITypes.MultiSelect" v-if="formState.uidt === UITypes.SingleSelect || formState.uidt === UITypes.MultiSelect"
v-model:value="formState" v-model:value="formState"

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

@ -33,7 +33,7 @@ onMounted(() => {
// set default value // set default value
vModel.value.fk_qr_value_column_id = vModel.value.fk_qr_value_column_id =
(column?.value?.colOptions as Record<string, any>)?.fk_qr_value_column_id || (column?.value?.colOptions as Record<string, any>)?.fk_qr_value_column_id ||
(!isEdit ? columnsAllowedAsQrValue.value?.[0]?.id : null) (!isEdit.value ? columnsAllowedAsQrValue.value?.[0]?.id : null)
}) })
setAdditionalValidations({ setAdditionalValidations({

4
packages/nc-gui/components/smartsheet/grid/Table.vue

@ -1871,7 +1871,8 @@ onKeyStroke('ArrowDown', onDown)
</NcMenu> </NcMenu>
</template> </template>
<template v-else #overlay> <template v-else #overlay>
<SmartsheetColumnEditOrAddProvider <div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider
v-if="addColumnDropdown" v-if="addColumnDropdown"
:preload="preloadColumn" :preload="preloadColumn"
:column-position="columnOrder" :column-position="columnOrder"
@ -1882,6 +1883,7 @@ onKeyStroke('ArrowDown', onDown)
@keydown.stop @keydown.stop
@mounted="preloadColumn = undefined" @mounted="preloadColumn = undefined"
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
</div> </div>

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

@ -204,7 +204,8 @@ const onClick = (e: Event) => {
<div v-else /> <div v-else />
<template #overlay> <template #overlay>
<SmartsheetColumnEditOrAddProvider <div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider
v-if="editColumnDropdown" v-if="editColumnDropdown"
:column="columnOrder ? null : column" :column="columnOrder ? null : column"
:column-position="columnOrder" :column-position="columnOrder"
@ -214,6 +215,7 @@ const onClick = (e: Event) => {
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
</div> </div>

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

@ -237,7 +237,8 @@ const onClick = (e: Event) => {
<div v-if="isExpandedForm && !isExpandedBulkUpdateForm" class="h-[1px]" @dblclick.stop>&nbsp;</div> <div v-if="isExpandedForm && !isExpandedBulkUpdateForm" class="h-[1px]" @dblclick.stop>&nbsp;</div>
<div v-else /> <div v-else />
<template #overlay> <template #overlay>
<SmartsheetColumnEditOrAddProvider <div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider
v-if="editColumnDropdown" v-if="editColumnDropdown"
:column="columnOrder ? null : column" :column="columnOrder ? null : column"
:column-position="columnOrder" :column-position="columnOrder"
@ -247,6 +248,7 @@ const onClick = (e: Event) => {
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
</div> </div>

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

@ -42,6 +42,7 @@ provide(IsKanbanInj, ref(true))
</a-button> </a-button>
</div> </div>
<template #overlay> <template #overlay>
<div class="overflow-auto max-h-[max(80vh,500px)] min-w-[384px]">
<LazySmartsheetColumnEditOrAddProvider <LazySmartsheetColumnEditOrAddProvider
v-if="open" v-if="open"
:column="groupingFieldColumn" :column="groupingFieldColumn"
@ -50,6 +51,7 @@ provide(IsKanbanInj, ref(true))
@click.stop @click.stop
@keydown.stop @keydown.stop
/> />
</div>
</template> </template>
</a-dropdown> </a-dropdown>
</template> </template>

4
packages/nocodb/src/services/columns.service.ts

@ -1648,12 +1648,16 @@ export class ColumnsService {
break; break;
case UITypes.QrCode: case UITypes.QrCode:
validateParams(['fk_qr_value_column_id'], param.column);
await Column.insert(context, { await Column.insert(context, {
...colBody, ...colBody,
fk_model_id: table.id, fk_model_id: table.id,
}); });
break; break;
case UITypes.Barcode: case UITypes.Barcode:
validateParams(['fk_barcode_value_column_id'], param.column);
await Column.insert(context, { await Column.insert(context, {
...colBody, ...colBody,
fk_model_id: table.id, fk_model_id: table.id,

Loading…
Cancel
Save