Browse Source

fix: reuse cell components

pull/6573/head
mertmit 1 year ago
parent
commit
61e602c420
  1. 26
      packages/nc-gui/components/smartsheet/grid/Table.vue

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

@ -195,8 +195,6 @@ const isAddNewRecordGridMode = ref(true)
const switchingTab = ref(false) const switchingTab = ref(false)
const showLoading = ref(true)
const isView = false const isView = false
const columnOrder = ref<Pick<ColumnReqType, 'column_order'> | null>(null) const columnOrder = ref<Pick<ColumnReqType, 'column_order'> | null>(null)
@ -973,7 +971,9 @@ eventBus.on(async (event, payload) => {
} }
}) })
async function reloadViewDataHandler(shouldShowLoading: boolean | void) { async function reloadViewDataHandler(_shouldShowLoading: boolean | void) {
isViewDataLoading.value = true
if (predictedNextColumn.value?.length) { if (predictedNextColumn.value?.length) {
const fieldsAvailable = meta.value?.columns?.map((c) => c.title) const fieldsAvailable = meta.value?.columns?.map((c) => c.title)
predictedNextColumn.value = predictedNextColumn.value.filter((c) => !fieldsAvailable?.includes(c.title)) predictedNextColumn.value = predictedNextColumn.value.filter((c) => !fieldsAvailable?.includes(c.title))
@ -981,11 +981,9 @@ async function reloadViewDataHandler(shouldShowLoading: boolean | void) {
// save any unsaved data before reload // save any unsaved data before reload
await saveOrUpdateRecords() await saveOrUpdateRecords()
// set value if spinner should be hidden
showLoading.value = !!shouldShowLoading
await loadData?.() await loadData?.()
// reset to default (showing spinner on load)
showLoading.value = true isViewDataLoading.value = false
} }
useEventListener(scrollWrapper, 'scroll', () => { useEventListener(scrollWrapper, 'scroll', () => {
@ -1168,7 +1166,7 @@ const handleCellClick = (event: MouseEvent, row: number, col: number) => {
@contextmenu="showContextMenu" @contextmenu="showContextMenu"
> >
<thead v-show="hideHeader !== true" ref="tableHeadEl"> <thead v-show="hideHeader !== true" ref="tableHeadEl">
<tr v-if="showSkeleton"> <tr v-if="showSkeleton && isPaginationLoading">
<td <td
v-for="(col, colIndex) of dummyDataForLoading" v-for="(col, colIndex) of dummyDataForLoading"
:key="colIndex" :key="colIndex"
@ -1184,7 +1182,7 @@ const handleCellClick = (event: MouseEvent, row: number, col: number) => {
/> />
</td> </td>
</tr> </tr>
<tr v-else class="nc-grid-header"> <tr v-show="!isPaginationLoading" class="nc-grid-header">
<th class="w-[85px] min-w-[85px]" data-testid="grid-id-column" @dblclick="() => {}"> <th class="w-[85px] min-w-[85px]" data-testid="grid-id-column" @dblclick="() => {}">
<div class="w-full h-full flex pl-5 pr-1 items-center" data-testid="nc-check-all"> <div class="w-full h-full flex pl-5 pr-1 items-center" data-testid="nc-check-all">
<template v-if="!readOnly"> <template v-if="!readOnly">
@ -1341,8 +1339,13 @@ const handleCellClick = (event: MouseEvent, row: number, col: number) => {
></td> ></td>
</tr> </tr>
</template> </template>
<template v-else> <LazySmartsheetRow
<LazySmartsheetRow v-for="(row, rowIndex) of dataRef" ref="rowRefs" :key="rowIndex" :row="row"> v-for="(row, rowIndex) of dataRef"
v-show="!showSkeleton"
ref="rowRefs"
:key="rowIndex"
:row="row"
>
<template #default="{ state }"> <template #default="{ state }">
<tr <tr
class="nc-grid-row !xs:h-14" class="nc-grid-row !xs:h-14"
@ -1476,7 +1479,6 @@ const handleCellClick = (event: MouseEvent, row: number, col: number) => {
</tr> </tr>
</template> </template>
</LazySmartsheetRow> </LazySmartsheetRow>
</template>
<tr <tr
v-if="isAddingEmptyRowAllowed && !isGroupBy" v-if="isAddingEmptyRowAllowed && !isGroupBy"

Loading…
Cancel
Save