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
49d9ade608
  1. 16
      packages/nc-gui/components/cell/GeoData.vue
  2. 14
      packages/nc-gui/components/smartsheet/Cell.vue
  3. 2
      packages/nc-gui/components/smartsheet/Map.vue
  4. 1
      packages/nc-gui/components/smartsheet/expanded-form/index.vue

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

@ -5,6 +5,10 @@ import { useVModel } from '#imports'
interface Props {
modelValue?: string | null
defaultValues?: {
lat?: number | null
long?: number | null
} | null
// defaultGeoPosition?: InitialGeoPositionData
}
@ -26,12 +30,16 @@ let isExpanded = $ref(false)
let isLoading = $ref(false)
// const shouldSetDefaultGeoPosition = defaultGeoPosition.value?.geoColId ===
// const shouldSetDefaultGeoPosition = defaultGeoPosition.value?.geoColId ===
const [latitude, longitude] = (vModel.value || '').split(';')
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
const latLongStr = computed(() => {
const [latitude, longitude] = (vModel.value || '').split(';')
const [latitude, longitude] = vModel.value
? (vModel.value || '').split(';')
: [props?.defaultValues?.lat || '', props?.defaultValues?.long || '']
return latitude && longitude ? `${latitude}; ${longitude}` : 'Set location'
})
@ -99,7 +107,7 @@ const onGetCurrentLocation = () => {
@mousedown.stop
/>
</a-form-item>
defaultGeoPosition: {{ JSON.stringify(defaultGeoPosition) }}
<a-form-item class="inputLng" label="Lng">
<a-input
v-model:value="formState.longitude"

14
packages/nc-gui/components/smartsheet/Cell.vue

@ -1,6 +1,7 @@
<script setup lang="ts">
import type { ColumnType } from 'nocodb-sdk'
import { isSystemColumn } from 'nocodb-sdk'
import type { InitialGeoPositionData } from './expanded-form/index.vue'
import {
ActiveCellInj,
ColumnInj,
@ -46,7 +47,6 @@ import {
useVModel,
} from '#imports'
import { NavigateDir } from '~/lib'
import { InitialGeoPositionData } from './expanded-form/index.vue';
interface Props {
column: ColumnType
@ -131,6 +131,16 @@ const syncAndNavigate = (dir: NavigateDir, e: KeyboardEvent) => {
if (!isForm.value) e.stopImmediatePropagation()
}
// TODO: probably wanna do this more generic / not column-type specific
const defaultValues = computed(() =>
column.value.id === props.defaultGeoPosition?.geoColId
? {
lat: props.defaultGeoPosition?.lat,
long: props.defaultGeoPosition?.long,
}
: null,
)
console.log('column.value in cell', column.value)
</script>
@ -146,7 +156,7 @@ console.log('column.value in cell', column.value)
>
<template v-if="column">
<LazyCellTextArea v-if="isTextArea(column)" v-model="vModel" />
<LazyCellGeoData v-else-if="isGeoData(column)" v-model="vModel" :default-geo-position="props.defaultGeoPosition" />
<LazyCellGeoData v-else-if="isGeoData(column)" v-model="vModel" :default-values="defaultValues" />
<LazyCellCheckbox v-else-if="isBoolean(column, abstractType)" v-model="vModel" />
<LazyCellAttachment v-else-if="isAttachment(column)" v-model="vModel" :row-index="props.rowIndex" />
<LazyCellSingleSelect v-else-if="isSingleSelect(column)" v-model="vModel" :row-index="props.rowIndex" />

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

@ -223,8 +223,6 @@ const count = computed(() => paginationData.value.totalRows)
<template>
<div class="flex flex-col h-full w-full no-underline">
expandedFormDlgInitialGeoPositionData: {{ JSON.stringify(expandedFormDlgInitialGeoPositionData) }}
<div id="mapContainer" ref="mapContainerRef">
<a-tooltip placement="bottom" class="tooltip">
<template #title>

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

@ -162,7 +162,6 @@ export default {
<SmartsheetExpandedFormHeader :view="props.view" @cancel="onClose" />
<div class="!bg-gray-100 rounded flex-1">
FOO geodata: {{ JSON.stringify(initialGeoPositionData) }}
<div class="flex h-full nc-form-wrapper items-stretch min-h-[max(70vh,100%)]">
<div class="flex-1 overflow-auto scrollbar-thin-dull nc-form-fields-container">

Loading…
Cancel
Save