Browse Source

GeoData: apply formatData in store composable (fixes also type error) and filter out rows with empty cells for primary geo column

pull/4140/head
flisowna 2 years ago
parent
commit
8be4a83586
  1. 6
      packages/nc-gui/components/smartsheet/Map.vue
  2. 9
      packages/nc-gui/composables/useMapViewDataStore.ts

6
packages/nc-gui/components/smartsheet/Map.vue

@ -52,7 +52,7 @@ watch([formattedData, mapMetaData, markersClusterGroupRef], () => {
throw new Error('Cannot find primary geo data column title') throw new Error('Cannot find primary geo data column title')
} }
const primaryGeoDataValue = row[primaryGeoDataColumnTitle] const primaryGeoDataValue = row.row[primaryGeoDataColumnTitle]
const listItems = Object.entries(row) const listItems = Object.entries(row)
.map(([key, val]) => { .map(([key, val]) => {
@ -64,6 +64,10 @@ watch([formattedData, mapMetaData, markersClusterGroupRef], () => {
const popupContent = `<ul>${listItems}</ul>` const popupContent = `<ul>${listItems}</ul>`
if (primaryGeoDataValue == null) {
return
}
const [lat, long] = primaryGeoDataValue.split(';').map(parseFloat) const [lat, long] = primaryGeoDataValue.split(';').map(parseFloat)
addMarker(lat, long, popupContent) addMarker(lat, long, popupContent)

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

@ -3,6 +3,13 @@ import type { ColumnType, MapType, TableType, ViewType } from 'nocodb-sdk'
import { ref, useInjectionState } from '#imports' import { ref, useInjectionState } from '#imports'
import type { Row } from '~/lib' import type { Row } from '~/lib'
const formatData = (list: Row[]) =>
list.map((row) => ({
row: { ...row },
oldRow: { ...row },
rowMeta: {},
}))
const [useProvideMapViewStore, useMapViewStore] = useInjectionState( const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
( (
meta: Ref<TableType | MapType | undefined>, meta: Ref<TableType | MapType | undefined>,
@ -32,7 +39,7 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
const res = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!) const res = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!)
formattedData.value = res.list formattedData.value = formatData(res.list)
} }
async function updateMapMeta(updateObj: Partial<MapType>) { async function updateMapMeta(updateObj: Partial<MapType>) {

Loading…
Cancel
Save