Browse Source

Merge branch 'geodata-prototyping-restart' of github.com:humannocode/nocodb into geodata-prototyping-restart

pull/4749/head
flisowna 2 years ago
parent
commit
81b402dc4d
  1. 3
      packages/nc-gui/components/cell/GeoData.vue
  2. 5
      packages/nc-gui/components/smartsheet/Cell.vue
  3. 10
      packages/nc-gui/components/smartsheet/Map.vue
  4. 11
      packages/nc-gui/components/smartsheet/expanded-form/index.vue
  5. 3
      packages/nc-gui/utils/geoDataUtils.ts

3
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 { latLongToJoinedString } from '~~/utils/geoDataUtils'
interface Props {
modelValue?: string | null
@ -33,7 +34,7 @@ const formState = reactive({
})
const handleFinish = () => {
vModel.value = `${formState.latitude};${formState.longitude}`
vModel.value = latLongToJoinedString(parseFloat(formState.latitude), parseFloat(formState.longitude))
isExpanded = false
}

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

@ -1,7 +1,6 @@
<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,
@ -56,10 +55,6 @@ interface Props {
rowIndex?: number
active?: boolean
virtual?: boolean
// TODO: check whether
// a) this is in general the right approach to pass in default values
// b) if yes: probably we want to make it generic (column type independent)
defaultGeoPosition?: InitialGeoPositionData
}
const props = defineProps<Props>()

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

@ -8,6 +8,7 @@ import { ViewTypes } from 'nocodb-sdk'
import { IsGalleryInj, IsGridInj, IsMapInj, OpenNewRecordFormHookInj, onMounted, provide, ref } from '#imports'
import type { Row as RowType } from '~/lib'
import { latLongToJoinedString } from '~~/utils/geoDataUtils'
provide(IsGalleryInj, ref(false))
provide(IsGridInj, ref(false))
@ -145,7 +146,7 @@ onMounted(async () => {
const lng = e.latlng.lng
const newRow = await addEmptyRow()
if (geoDataFieldColumn.value?.title) {
newRow.row[geoDataFieldColumn.value.title] = `${lat.toFixed(7)};${lng.toFixed(7)}`
newRow.row[geoDataFieldColumn.value.title] = latLongToJoinedString(lat, lng)
}
expandForm(newRow, [lat, lng])
})
@ -196,12 +197,6 @@ watch(view, async (nextView) => {
}
})
const expandedFormDlgInitialGeoPositionData = computed(() => ({
lat: expandedFormClickedLatLongForNewRow.value?.[0],
long: expandedFormClickedLatLongForNewRow.value?.[1],
geoColId: geoDataFieldColumn.value?.id,
}))
const count = computed(() => paginationData.value.totalRows)
</script>
@ -231,7 +226,6 @@ const count = computed(() => paginationData.value.totalRows)
:state="expandedFormRowState"
:meta="meta"
:view="view"
:initial-geo-position-data="expandedFormDlgInitialGeoPositionData"
/>
</Suspense>

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

@ -27,12 +27,6 @@ const props = defineProps<Props>()
const emits = defineEmits(['update:modelValue', 'cancel'])
export interface InitialGeoPositionData {
lat?: number
long?: number
geoColId?: string
}
interface Props {
modelValue?: boolean
row: Row
@ -42,7 +36,6 @@ interface Props {
useMetaFields?: boolean
rowId?: string
view?: ViewType
initialGeoPositionData?: InitialGeoPositionData
}
const row = ref(props.row)
@ -51,9 +44,6 @@ const state = toRef(props, 'state')
const meta = toRef(props, 'meta')
// const initialGeoPositionData = toRef(props, 'initialGeoPositionData')
const initialGeoPositionData = ref(props.initialGeoPositionData)
const router = useRouter()
const fields = computedInject(FieldsInj, (_fields) => {
@ -184,7 +174,6 @@ export default {
:column="col"
:edit-enabled="true"
:active="true"
:default-geo-position="initialGeoPositionData"
@update:model-value="changedColumns.add(col.title)"
/>
</div>

3
packages/nc-gui/utils/geoDataUtils.ts

@ -0,0 +1,3 @@
const latLongToJoinedString = (lat: number, long: number) => `${lat.toFixed(7)};${long.toFixed(7)}`
export { latLongToJoinedString }
Loading…
Cancel
Save