From 7bdb1f43a7f118faac94cbbaddc9f1f56c3ddec9 Mon Sep 17 00:00:00 2001 From: flisowna Date: Mon, 31 Oct 2022 11:14:41 +0400 Subject: [PATCH] add map view store file --- .../nc-gui/composables/useMapViewDataStore.ts | 32 +++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/packages/nc-gui/composables/useMapViewDataStore.ts b/packages/nc-gui/composables/useMapViewDataStore.ts index e69de29bb2..6c8a50d481 100644 --- a/packages/nc-gui/composables/useMapViewDataStore.ts +++ b/packages/nc-gui/composables/useMapViewDataStore.ts @@ -0,0 +1,32 @@ +const { project } = useProject() + +const [useProvideMapViewStore, useMapViewStore] = useInjectionState( +async function loadMapData() { + if ((!project?.value?.id || !meta.value?.id || !viewMeta?.value?.id) && !isPublic.value) return + + // reset formattedData & countByStack to avoid storing previous data after changing grouping field + formattedData.value = new Map() + countByStack.value = new Map() + + let res + + if (isPublic.value) { + res = await fetchSharedViewGroupedData(groupingFieldColumn!.value!.id!) + } else { + res = await api.dbViewRow.groupedDataList( + 'noco', + project.value.id!, + meta.value!.id!, + viewMeta.value!.id!, + groupingFieldColumn!.value!.id!, + {}, + {}, + ) + } + + for (const data of res) { + const key = data.key + formattedData.value.set(key, formatData(data.value.list)) + countByStack.value.set(key, data.value.pageInfo.totalRows || 0) + } +}