|
|
|
@ -1,6 +1,6 @@
|
|
|
|
|
import type { ComputedRef, Ref } from 'vue' |
|
|
|
|
import type { ColumnType, MapType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
|
import { ref, useApi, useInjectionState } from '#imports' |
|
|
|
|
import type { MapType, TableType, ViewType } from 'nocodb-sdk' |
|
|
|
|
import { ref, useInjectionState } from '#imports' |
|
|
|
|
import type { Row } from '~/lib' |
|
|
|
|
|
|
|
|
|
const [useProvideMapViewStore, useMapViewStore] = useInjectionState( |
|
|
|
@ -10,58 +10,58 @@ const [useProvideMapViewStore, useMapViewStore] = useInjectionState(
|
|
|
|
|
) => { |
|
|
|
|
const formattedData = ref<Row[]>() |
|
|
|
|
|
|
|
|
|
const { api } = useApi() |
|
|
|
|
const { project } = useProject() |
|
|
|
|
// const { api } = useApi()
|
|
|
|
|
// const { project } = useProject()
|
|
|
|
|
// const { $e, $api } = useNuxtApp()
|
|
|
|
|
const { $api } = useNuxtApp() |
|
|
|
|
|
|
|
|
|
const mapMetaData = ref<MapType>({}) |
|
|
|
|
|
|
|
|
|
const geoDataField = ref<string>('') |
|
|
|
|
// const geoDataField = ref<string>('')
|
|
|
|
|
|
|
|
|
|
const geoDataFieldColumn = ref<ColumnType | undefined>() |
|
|
|
|
// const geoDataFieldColumn = ref<ColumnType | undefined>()
|
|
|
|
|
|
|
|
|
|
async function loadMapData() { |
|
|
|
|
async function loadMapMeta() { |
|
|
|
|
if (!viewMeta?.value?.id || !meta?.value?.columns) return |
|
|
|
|
mapMetaData.value = await $api.dbView.mapRead(viewMeta.value.id) |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
formattedData.value = [] |
|
|
|
|
|
|
|
|
|
const res = await api.dbViewRow.list( |
|
|
|
|
'noco', |
|
|
|
|
project.value.id!, |
|
|
|
|
meta.value!.id!, |
|
|
|
|
viewMeta.value!.id!, |
|
|
|
|
geoDataFieldColumn!.value!.id, |
|
|
|
|
) |
|
|
|
|
async function loadMapData() { |
|
|
|
|
// if (!viewMeta?.value?.id || !meta?.value?.columns) return
|
|
|
|
|
|
|
|
|
|
geoDataFieldColumn.value = |
|
|
|
|
(meta.value.columns as ColumnType[]).filter((f) => f.id === mapMetaData.value.fk_geo_data_col_id)[0] || {} |
|
|
|
|
// formattedData.value = []
|
|
|
|
|
|
|
|
|
|
geoDataField.value = geoDataFieldColumn.value.title! |
|
|
|
|
// const res = await api.dbViewRow.list('noco', project.value.id!, meta.value!.id!, viewMeta.value!.id!)
|
|
|
|
|
|
|
|
|
|
const { fk_geo_data_col_id, meta: stack_meta } = mapMetaData.value |
|
|
|
|
// // geoDataFieldColumn.value =
|
|
|
|
|
// // (meta.value.columns as ColumnType[]).filter((f) => f.id === mapMetaData.value.fk_geo_data_col_id)[0] || {}
|
|
|
|
|
|
|
|
|
|
const stackMetaObj: any.value = stack_meta ? JSON.parse(stack_meta as string) : {} |
|
|
|
|
// geoDataField.value = geoDataFieldColumn!.value!.title!
|
|
|
|
|
|
|
|
|
|
console.log('column geodata', stackMetaObj.value[fk_geo_data_col_id]) |
|
|
|
|
// if ((!project?.value?.id || !meta.value?.id || !viewMeta?.value?.id) && !isPublic.value) return
|
|
|
|
|
// // const { fk_geo_data_col_id, meta: geo_meta } = mapMetaData.value
|
|
|
|
|
|
|
|
|
|
// reset formattedData & countByStack to avoid storing previous data after changing grouping field
|
|
|
|
|
// // const geoMetaObj: any.value = geo_meta ? JSON.parse(geo_meta as string) : {}
|
|
|
|
|
|
|
|
|
|
// // console.log('column geodata', stackMetaObj.value[fk_geo_data_col_id])
|
|
|
|
|
// // if ((!project?.value?.id || !meta.value?.id || !viewMeta?.value?.id) && !isPublic.value) return
|
|
|
|
|
|
|
|
|
|
// alert('in loadMapData')
|
|
|
|
|
// debugger
|
|
|
|
|
// // reset formattedData & countByStack to avoid storing previous data after changing grouping field
|
|
|
|
|
|
|
|
|
|
// // alert('in loadMapData')
|
|
|
|
|
// // debugger
|
|
|
|
|
|
|
|
|
|
console.log('res in mapviewdatastore', res) |
|
|
|
|
// console.log('res in mapviewdatastore', res)
|
|
|
|
|
|
|
|
|
|
// for (const data of res.list) {
|
|
|
|
|
// formattedData.value = data.value
|
|
|
|
|
// }
|
|
|
|
|
formattedData.value = res.list |
|
|
|
|
// // for (const data of res.list) {
|
|
|
|
|
// // formattedData.value = data.value
|
|
|
|
|
// // }
|
|
|
|
|
// formattedData.value = res.list
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
return { |
|
|
|
|
formattedData, |
|
|
|
|
loadMapData, |
|
|
|
|
loadMapMeta, |
|
|
|
|
mapMetaData, |
|
|
|
|
} |
|
|
|
|
}, |
|
|
|
|