Browse Source

fix: exact number of skeltons on initial load

pull/6486/head
sreehari jayaraj 1 year ago
parent
commit
cceb2b8486
  1. 15
      packages/nc-gui/components/virtual-cell/Links.vue
  2. 14
      packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

15
packages/nc-gui/components/virtual-cell/Links.vue

@ -64,6 +64,20 @@ const textVal = computed(() => {
} }
}) })
const toatlRecordsLinked = computed(() => {
if (isForm?.value) {
return state.value?.[colTitle.value]?.length
}
const parsedValue = +value?.value || 0
if (!parsedValue) {
return 0
} else if (parsedValue === 1) {
return 1
} else {
return parsedValue
}
})
const onAttachRecord = () => { const onAttachRecord = () => {
childListDlg.value = false childListDlg.value = false
listItemsDlg.value = true listItemsDlg.value = true
@ -121,6 +135,7 @@ const localCellValue = computed<any[]>(() => {
<LazyVirtualCellComponentsListChildItems <LazyVirtualCellComponentsListChildItems
v-model="childListDlg" v-model="childListDlg"
:items="toatlRecordsLinked"
:column="relatedTableDisplayColumn" :column="relatedTableDisplayColumn"
:cell-value="localCellValue" :cell-value="localCellValue"
@attach-record="onAttachRecord" @attach-record="onAttachRecord"

14
packages/nc-gui/components/virtual-cell/components/ListChildItems.vue

@ -22,6 +22,7 @@ interface Prop {
modelValue?: boolean modelValue?: boolean
cellValue: any cellValue: any
column: any column: any
items: number
} }
const props = defineProps<Prop>() const props = defineProps<Prop>()
@ -135,6 +136,10 @@ onKeyStroke('Escape', () => {
displayed displayed
*/ */
const skeltonCount = computed(() => { const skeltonCount = computed(() => {
if (props.items < 10 && childrenListPagination.page === 1) {
return props.items
}
if (childrenListCount.value < 10 && childrenListPagination.page === 1) { if (childrenListCount.value < 10 && childrenListPagination.page === 1) {
return childrenListCount.value || 10 return childrenListCount.value || 10
} }
@ -146,6 +151,13 @@ const skeltonCount = computed(() => {
return 10 return 10
}) })
const totalItemsToShow = computed(() => {
if (isChildrenLoading) {
return props.items
}
return childrenListCount.value
})
const isDataExist = computed<boolean>(() => { const isDataExist = computed<boolean>(() => {
return childrenList.value?.pageInfo?.totalRows || (isNew.value && state.value?.[colTitle.value]?.length) return childrenList.value?.pageInfo?.totalRows || (isNew.value && state.value?.[colTitle.value]?.length)
}) })
@ -283,7 +295,7 @@ const linkOrUnLink = (rowRef: Record<string, string>, id: string) => {
<div class="flex flex-row justify-between bg-white relative pt-1"> <div class="flex flex-row justify-between bg-white relative pt-1">
<div v-if="!isForm" class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50"> <div v-if="!isForm" class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50">
{{ childrenListCount || 0 }} {{ $t('objects.records') }} {{ childrenListCount !== 0 ? $t('general.are') : '' }} {{ totalItemsToShow || 0 }} {{ $t('objects.records') }} {{ totalItemsToShow !== 0 ? $t('general.are') : '' }}
{{ $t('general.linked') }} {{ $t('general.linked') }}
</div> </div>
<div v-else class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50"> <div v-else class="flex items-center justify-center px-2 rounded-md text-gray-500 bg-brand-50">

Loading…
Cancel
Save