Browse Source

WIP updating without refresh records number in toolbar

pull/4723/head
flisowna 2 years ago
parent
commit
09359286dd
  1. 9
      packages/nc-gui/components/smartsheet/toolbar/MapRowsLimits.vue
  2. 27
      packages/nc-gui/composables/useMapViewDataStore.ts

9
packages/nc-gui/components/smartsheet/toolbar/MapRowsLimits.vue

@ -1,9 +1,10 @@
<script setup lang="ts"> <script setup lang="ts">
import { ActiveViewInj, MetaInj, inject, useViewData } from '#imports' // import { ActiveViewInj, MetaInj, inject, useViewData } from '#imports'
const meta = inject(MetaInj)
const view = inject(ActiveViewInj) // const meta = inject(MetaInj)
const { syncCount, paginationData } = useViewData(meta!, view!) // const view = inject(ActiveViewInj)
const { syncCount, paginationData } = useMapViewStoreOrThrow()
const count = computed(() => { const count = computed(() => {
return paginationData.value.totalRows return paginationData.value.totalRows

27
packages/nc-gui/composables/useMapViewDataStore.ts

@ -6,6 +6,10 @@ import type { Row } from '~/lib'
export const geodataToggleState = reactive({ show: false }) export const geodataToggleState = reactive({ show: false })
const reloadTrigger = inject(ReloadRowDataHookInj, createEventHook())
// const { project, isSharedBase } = useProject()
const formatData = (list: Row[]) => const formatData = (list: Row[]) =>
list.map((row) => ({ list.map((row) => ({
row: { ...row }, row: { ...row },
@ -13,9 +17,6 @@ const formatData = (list: Row[]) =>
rowMeta: {}, rowMeta: {},
})) }))
const appInfoDefaultLimit = 1000
const paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit })
const [useProvideMapViewStore, useMapViewStore] = useInjectionState( const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
( (
meta: Ref<TableType | undefined>, meta: Ref<TableType | undefined>,
@ -36,7 +37,11 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
const view = inject(ActiveViewInj) const view = inject(ActiveViewInj)
const { syncCount } = useViewData(meta, view!) // const { syncCount } = useViewData(meta, view!)
const appInfoDefaultLimit = 1000
const paginationData = ref<PaginatedType>({ page: 1, pageSize: appInfoDefaultLimit })
const queryParams = computed(() => ({ const queryParams = computed(() => ({
// offset: ((paginationData.value.page ?? 0) - 1) * (paginationData.value.pageSize ?? appInfoDefaultLimit), // offset: ((paginationData.value.page ?? 0) - 1) * (paginationData.value.pageSize ?? appInfoDefaultLimit),
@ -44,6 +49,16 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
where: where?.value ?? '', where: where?.value ?? '',
})) }))
async function syncCount() {
const { count } = await $api.dbViewRow.count(
NOCO,
project?.value?.title as string,
meta?.value?.id as string,
viewMeta?.value?.id as string,
)
paginationData.value.totalRows = count
}
async function loadMapMeta() { async function loadMapMeta() {
if (!viewMeta?.value?.id || !meta?.value?.columns) return if (!viewMeta?.value?.id || !meta?.value?.columns) return
mapMetaData.value = await $api.dbView.mapRead(viewMeta.value.id) mapMetaData.value = await $api.dbView.mapRead(viewMeta.value.id)
@ -59,7 +74,7 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
where: where?.value, where: where?.value,
}) })
syncCount() // syncCount()
formattedData.value = formatData(res.list) formattedData.value = formatData(res.list)
} }
@ -139,6 +154,8 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
addEmptyRow, addEmptyRow,
insertRow, insertRow,
geodataToggleState, geodataToggleState,
syncCount,
paginationData,
} }
}, },
) )

Loading…
Cancel
Save