Browse Source

cleanup

pull/5247/head
Daniel Spaude 2 years ago
parent
commit
39a88352eb
No known key found for this signature in database
GPG Key ID: 654A3D1FA4F35FFE
  1. 74
      packages/nc-gui/components/smartsheet/Map.vue
  2. 63
      packages/nc-gui/components/smartsheet/SharedMapMarkerPopup.vue

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

@ -3,24 +3,13 @@ import 'leaflet/dist/leaflet.css'
import L, { LatLng } from 'leaflet'
import 'leaflet.markercluster'
import { ViewTypes } from 'nocodb-sdk'
// import * as Vue from 'vue'
// import MyPopupComponent from './MyPopupComponent'
// import { defineComponent, ref } from 'vue'
// import Vue from 'vue'
import { IsPublicInj, OpenNewRecordFormHookInj, latLongToJoinedString, onMounted, provide, ref } from '#imports'
import type { Row, Row as RowType } from '~/lib'
// import { LazySmartsheetMyPopupComponent } from '~~/.nuxt/components'
// Vue.config.ignoredElements.push('my-popup-component')
const route = useRoute()
// const popupIsOpen = ref(false)
const popupIsOpen = ref(false)
const popupContainer = ref()
const popUpRow = ref<Row>()
const fields = inject(FieldsInj, ref([]))
console.log('FOO fields', fields)
const router = useRouter()
@ -97,7 +86,6 @@ const expandedFormOnRowIdDlg = computed({
},
})
// const addMarker = (lat: number, long: number, row: RowType, popupContent: string) => {
const addMarker = (lat: number, long: number, row: RowType) => {
if (markersClusterGroupRef.value == null) {
throw new Error('Marker cluster is null')
@ -113,36 +101,6 @@ const addMarker = (lat: number, long: number, row: RowType) => {
}
})
markersClusterGroupRef.value?.addLayer(newMarker)
// if (newMarker && isPublic.value) {
// // newMarker.setPopupContent(popupContainer.value!)
// popUpRow.value = row
// newMarker.bindPopup(popupContainer.value!)
// // newMarker.bindPopup(popupContent)
// // const vm = new Vue({
// // render: (h: any) =>
// // h(LazySmartsheetMyPopupComponent, {
// // props: {
// // title: 'Marker Title',
// // description: 'Marker Description',
// // },
// // }),
// // })
// // newMarker.bindPopup(vm.$el, { maxWidth: 300 })
// newMarker.on('popupopen', () => {
// popupIsOpen.value = true
// // vm.$mount()
// })
// newMarker.on('popupclose', () => {
// popupIsOpen.value = false
// // vm.$destroy()
// })
// }
}
const resetZoomAndCenterBasedOnLocalStorage = () => {
@ -238,25 +196,7 @@ watch([formattedData, mapMetaData, markersClusterGroupRef], () => {
if (primaryGeoDataValue == null) {
return
}
// const listItems = Object.entries(row.row)
// .filter(([key, val]) => val !== null && key !== 'Id')
// .map(([key, val]) => {
// let prettyVal = val
// if (val !== null && (typeof val === 'object' || Array.isArray(val))) {
// prettyVal = JSON.stringify(val)
// } else if (typeof val === 'string' && (val.startsWith('http://') || val.startsWith('https://'))) {
// prettyVal = `<a href="${val}" target="_blank">${val}</a>`
// }
// return `<li><b>${key}</b>: <br/>${prettyVal}</li>`
// })
// .join('')
// const popupContent = `<ul class="popup-content">${listItems}</ul>`
const [lat, long] = primaryGeoDataValue.split(';').map(parseFloat)
// addMarker(lat, long, row, popupContent)
addMarker(lat, long, row)
})
})
@ -268,22 +208,12 @@ watch(view, async (nextView) => {
}
})
// @cancel="emit('closed')"
const count = computed(() => paginationData.value.totalRows)
</script>
<template>
<a-modal
v-model:visible="popupIsOpen"
:class="{ active: popupIsOpen }"
:footer="null"
centered
:closable="false"
@close="popupIsOpen = false"
>
<!-- <div v-if="popupIsOpen" ref="popupContainer"> -->
<LazySmartsheetMyPopupComponent v-if="popUpRow" :fields="fields" :row="popUpRow"></LazySmartsheetMyPopupComponent>
<!-- </div> -->
<a-modal v-model:visible="popupIsOpen" :footer="null" centered :closable="false" @close="popupIsOpen = false">
<LazySmartsheetSharedMapMarkerPopup v-if="popUpRow" :fields="fields" :row="popUpRow"></LazySmartsheetSharedMapMarkerPopup>
</a-modal>
<div class="flex flex-col h-full w-full no-underline" data-testid="nc-map-wrapper">

63
packages/nc-gui/components/smartsheet/MyPopupComponent.vue → packages/nc-gui/components/smartsheet/SharedMapMarkerPopup.vue

@ -1,9 +1,6 @@
<script lang="ts" setup>
import type { ColumnType, TableType } from 'nocodb-sdk'
// import { isVirtualCol } from 'nocodb-sdk'
import type { Ref } from 'vue'
// import type { Row } from '~/lib'
// const props =
import { ViewTypes, isVirtualCol } from 'nocodb-sdk'
import {
@ -45,7 +42,7 @@ const view = inject(ActiveViewInj, ref())
const reloadViewMetaHook = inject(ReloadViewMetaHookInj)
const reloadViewDataHook = inject(ReloadViewDataHookInj)
const { loadData, paginationData, loadGalleryData, galleryData, changePage, addEmptyRow } = useViewData(meta, view)
const { loadData, paginationData, loadGalleryData, galleryData, changePage } = useViewData(meta, view)
provide(IsFormInj, ref(false))
provide(IsGalleryInj, ref(true))
@ -108,7 +105,6 @@ onMounted(async () => {
await loadGalleryData()
})
// provide view data reload hook as fallback to row data reload
provide(ReloadRowDataHookInj, reloadViewDataHook)
watch(view, async (nextView) => {
@ -118,43 +114,9 @@ watch(view, async (nextView) => {
}
})
// defineProps({
// // popupIsOpen: {
// // type: Boolean,
// // required: true,
// // },
// popUpRow: {
// type: Object,
// required: true,
// },
// fields: {
// type: Array,
// required: true,
// },
// // abstractType: {
// // type: String,
// // required: true,
// // },
// })
const currentRow = toRef(props, 'row')
// const { meta } = useSmartsheetStoreOrThrow()
// const rowStore = useProvideSmartsheetRowStore(meta as Ref<TableType>, currentRow)
const { row } = useProvideSmartsheetRowStore(meta as Ref<TableType>, currentRow)
// console.log('rowStore', row.value.row)
// const { currentRow: row } = useSmartsheetRowStoreOrThrow()
// const cellValueByColum = (column: ColumnType) => {
// return {
// get() {
// return props.row?.row[column.id!]
// },
// set() {},
// }
// }
</script>
<template>
@ -217,27 +179,4 @@ const { row } = useProvideSmartsheetRowStore(meta as Ref<TableType>, currentRow)
</div>
</a-card>
</LazySmartsheetRow>
<!-- <div ref="popupContainer">
<div v-for="col in fields" :key="col.id">
<div
v-if="!isRowEmpty(row, col) || isLTAR(col.uidt)"
class="flex flex-col space-y-1 px-4 mb-6 bg-gray-50 rounded-lg w-full"
>
<div class="flex flex-row w-full justify-start border-b-1 border-gray-100 py-2.5">
<div class="w-full text-gray-600">
<LazySmartsheetHeaderVirtualCell v-if="isVirtualCol(col)" :column="col" :hide-menu="true" />
<LazySmartsheetHeaderCell v-else :column="col" :hide-menu="true" />
</div>
</div>
<div class="flex flex-row w-full pb-3 pt-2 pl-2 items-center justify-start">
<LazySmartsheetVirtualCell v-if="isVirtualCol(col)" v-model="row.row[col.title]" :column="col" :row="row" />
<LazySmartsheetCell v-else v-model="row.row[col.title]" :column="col" :edit-enabled="false" :read-only="true" />
</div>
</div>
</div>
</div> -->
</template>
Loading…
Cancel
Save