Browse Source

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

pull/4723/head
flisowna 2 years ago
parent
commit
d21525f0c6
  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,7 +1,6 @@
<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
@ -9,7 +8,6 @@ interface Props {
lat?: number | null
long?: number | null
} | null
// defaultGeoPosition?: InitialGeoPositionData
}
interface Emits {
@ -22,24 +20,17 @@ 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 shouldSetDefaultGeoPosition = defaultGeoPosition.value?.geoColId ===
const defaultLat = props?.defaultValues?.lat?.toFixed(7)
const defaultLong = props?.defaultValues?.long?.toFixed(7)
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
const [latitude, longitude] = vModel.value ? (vModel.value || '').split(';') : [defaultLat || '', defaultLong || '']
const latLongStr = computed(() => {
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
const [latitude, longitude] = vModel.value ? (vModel.value || '').split(';') : [defaultLat || '', defaultLong || '']
return latitude && longitude ? `${latitude}; ${longitude}` : 'Set location'
})

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

@ -44,9 +44,6 @@ 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: {
@ -93,7 +90,6 @@ const addMarker = (lat: number, long: number, row: RowType) => {
console.log('OnNewMarker')
expandForm(row)
})
console.log('onaddMarker', lat, long)
markersClusterGroupRef.value?.addLayer(newMarker)
}
@ -147,22 +143,11 @@ 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,7 +6,6 @@ import {
FieldsInj,
IsFormInj,
IsKanbanInj,
IsMapInj,
MetaInj,
ReloadRowDataHookInj,
computedInject,
@ -52,9 +51,6 @@ 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()
@ -68,8 +64,6 @@ 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