Browse Source

Revert "geodata: create new row on right-click/tap on map (pass data into expand form dialog - hacky code / needs refactoring) - WIP"

This reverts commit d21525f0c6.
pull/4723/head
flisowna 2 years ago
parent
commit
a19ca14147
  1. 17
      packages/nc-gui/components/cell/GeoData.vue
  2. 15
      packages/nc-gui/components/smartsheet/Map.vue
  3. 6
      packages/nc-gui/components/smartsheet/expanded-form/index.vue

17
packages/nc-gui/components/cell/GeoData.vue

@ -1,6 +1,7 @@
<script lang="ts" setup>
import type { GeoLocationType } from 'nocodb-sdk'
import { useVModel } from '#imports'
// import { InitialGeoPositionData } from '../smartsheet/expanded-form/index.vue';
interface Props {
modelValue?: string | null
@ -8,6 +9,7 @@ interface Props {
lat?: number | null
long?: number | null
} | null
// defaultGeoPosition?: InitialGeoPositionData
}
interface Emits {
@ -20,17 +22,24 @@ const emits = defineEmits<Emits>()
const vModel = useVModel(props, 'modelValue', emits)
// const defaultGeoPosition = useVModel(props, 'defaultGeoPosition')
// let error = $ref<string | undefined>()
let isExpanded = $ref(false)
let isLoading = $ref(false)
const defaultLat = props?.defaultValues?.lat?.toFixed(7)
const defaultLong = props?.defaultValues?.long?.toFixed(7)
// const shouldSetDefaultGeoPosition = defaultGeoPosition.value?.geoColId ===
const [latitude, longitude] = vModel.value ? (vModel.value || '').split(';') : [defaultLat || '', defaultLong || '']
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
const latLongStr = computed(() => {
const [latitude, longitude] = vModel.value ? (vModel.value || '').split(';') : [defaultLat || '', defaultLong || '']
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
return latitude && longitude ? `${latitude}; ${longitude}` : 'Set location'
})

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

@ -44,6 +44,9 @@ const getMapCenterLocalStorageKey = (viewId: string) => `mapView.center.${viewId
const expandForm = (row: RowType, state?: Record<string, any>, clickedLatLongForNewRow?: [number, number]) => {
const rowId = extractPkFromRow(row.row, meta.value!.columns!)
console.log('state in expandForm', state)
console.log('row in expandForm', row)
console.log('clickedLatLongForNewRow', clickedLatLongForNewRow)
if (rowId) {
router.push({
query: {
@ -90,6 +93,7 @@ const addMarker = (lat: number, long: number, row: RowType) => {
console.log('OnNewMarker')
expandForm(row)
})
console.log('onaddMarker', lat, long)
markersClusterGroupRef.value?.addLayer(newMarker)
}
@ -143,11 +147,22 @@ onMounted(async () => {
}
})
// myMap.on('contextmenu', async function (e) {
// console.log('onContext')
// const newRow = await addEmptyRow()
// const lat = e.latlng.lat
// const lng = e.latlng.lng
// addMarker(lat, lng, newRow)
// expandForm(newRow)
// submitForm()
// })
myMap.on('contextmenu', async function (e) {
const newRow = await addEmptyRow()
const lat = e.latlng.lat
const lng = e.latlng.lng
addMarker(lat, lng, newRow)
console.log('oncontextClick', lat, lng, newRow)
expandForm(newRow, undefined, [lat, lng])
})
})

6
packages/nc-gui/components/smartsheet/expanded-form/index.vue

@ -6,6 +6,7 @@ import {
FieldsInj,
IsFormInj,
IsKanbanInj,
IsMapInj,
MetaInj,
ReloadRowDataHookInj,
computedInject,
@ -51,6 +52,9 @@ const state = toRef(props, 'state')
const meta = toRef(props, 'meta')
const newRow = row.value.row.geoColId
// const initialGeoPositionData = toRef(props, 'initialGeoPositionData')
const initialGeoPositionData = ref(props.initialGeoPositionData)
const router = useRouter()
@ -64,6 +68,8 @@ const fields = computedInject(FieldsInj, (_fields) => {
const isKanban = inject(IsKanbanInj, ref(false))
const isMap = inject(IsMapInj, ref(false))
provide(MetaInj, meta)
const { commentsDrawer, changedColumns, state: rowState, isNew, loadRow } = useProvideExpandedFormStore(meta, row)

Loading…
Cancel
Save