Skip to content

Commit 384b59a

Browse files
committed
Minor improvements
1 parent 38ab208 commit 384b59a

3 files changed

Lines changed: 45 additions & 33 deletions

File tree

src/components/MapComponent.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -103,11 +103,10 @@ defineExpose({
103103
<div class="map-wrapper">
104104
<div id="map" class="map-container"></div>
105105

106-
<DataCabinet v-if="map" :map="map as Map" :areaValues="areaValues" />
106+
<DataCabinet v-if="map" :areaValues="areaValues" />
107107

108108
<ProcessingResults
109109
v-if="geoJsonResults.length > 0 || projects.length > 0"
110-
:map="map as Map"
111110
:geoJsonResults="geoJsonResults"
112111
@clearResults="clearResults"
113112
/>

src/components/ProcessingResults.vue

Lines changed: 16 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
:icon="mdiChevronDown"
1313
>
1414
</v-icon>
15-
<span class="text-white title"> Results ({{ geoJsonResults.length }}) </span>
15+
<span class="text-white title">Results ({{ geoJsonResults.length }})</span>
1616
</div>
1717
<span v-else class="text-white title">Results</span>
1818
<v-spacer />
@@ -102,7 +102,7 @@
102102
</template>
103103

104104
<script setup lang="ts">
105-
import { ref, onMounted, onUnmounted, onBeforeUnmount, computed, watch } from 'vue'
105+
import { ref, computed, watch } from 'vue'
106106
import useMap from '../composables/useMap'
107107
import useNotifier from '../composables/useNotifier'
108108
import useAreaOfInterest from '../composables/useAreaOfInterest'
@@ -137,7 +137,20 @@ const hasMoreResults = computed(() => {
137137
138138
watch(
139139
() => props.geoJsonResults,
140-
(results) => (isOpen.value = results.length > 0),
140+
(results) => {
141+
const hasResults = results.length > 0
142+
isOpen.value = hasResults
143+
//
144+
if (!hasResults) {
145+
selectedFeature.value = null
146+
}
147+
// Map click handler to detect feature clicks and show properties
148+
if (map.value) {
149+
const action = hasResults ? 'on' : 'un'
150+
map.value[action]('singleclick', handleMapClick)
151+
}
152+
},
153+
{ immediate: true },
141154
)
142155
143156
const sortedResults = computed(() => {
@@ -278,24 +291,6 @@ const fitMapToResult = (result: Feature) => {
278291
fitToExtent(map.value!, extent, null)
279292
}
280293
281-
onMounted(() => {
282-
// Add map click handler to detect feature clicks and show properties
283-
if (map.value) {
284-
map.value.on('singleclick', handleMapClick)
285-
}
286-
})
287-
288-
onBeforeUnmount(() => {
289-
selectedFeature.value = null
290-
})
291-
292-
// Clean up map click handler when component is unmounted
293-
onUnmounted(() => {
294-
if (map.value) {
295-
map.value.un('singleclick', handleMapClick)
296-
}
297-
})
298-
299294
const clearResultsHandler = () => {
300295
// Clear results and zoom back to S2 grid
301296
clearResults(map.value!)

src/components/ProjectSelectionDialog.vue

Lines changed: 28 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,31 @@
11
<template lang="html">
2-
<v-dialog v-if="projects.length > 0" width="auto" max-height="500">
3-
<template v-slot:activator="{ props: activatorProps }">
4-
<v-btn variant="outlined" density="comfortable" color="primary" v-bind="activatorProps">
2+
<v-dialog
3+
v-if="projects.length > 0"
4+
v-model="isActive"
5+
width="auto"
6+
max-height="70%"
7+
max-width="50%"
8+
min-width="300px"
9+
>
10+
<template #activator="{ props: activatorProps }">
11+
<v-btn
12+
variant="outlined"
13+
color="primary"
14+
size="small"
15+
class="pa-0"
16+
title="Show previous results from batch processing"
17+
v-bind="activatorProps"
18+
>
519
Load
620
</v-btn>
721
</template>
8-
<template v-slot:default="{ isActive }">
22+
<template #default>
923
<v-card title="Load Project">
1024
<v-list density="compact" color="transparent" class="pa-0">
1125
<v-list-item
1226
v-for="project in sortedProjects"
1327
:key="project"
14-
@click.stop="
15-
queryProcess(project)
16-
isActive.value = false
17-
"
28+
@click.prevent="queryProcess(project)"
1829
>
1930
<v-label class="text-capitalize mb-1">{{ project }}</v-label>
2031
</v-list-item>
@@ -23,26 +34,33 @@
2334
<v-card-actions>
2435
<v-spacer></v-spacer>
2536

26-
<v-btn text="Close Dialog" @click="isActive.value = false"></v-btn>
37+
<v-btn text="Close" @click="closeDialog"></v-btn>
2738
</v-card-actions>
2839
</v-card>
2940
</template>
3041
</v-dialog>
3142
</template>
3243

3344
<script setup lang="ts">
34-
import { computed } from 'vue'
45+
import { computed, ref } from 'vue'
3546
import useProcessing from '../composables/useProcessing'
3647
import useMap from '../composables/useMap'
3748
3849
const { projects, loadProject } = useProcessing()
3950
const { displayGeoJSON, fitMapToBbox } = useMap()
4051
52+
const isActive = ref(false)
53+
4154
const sortedProjects = computed(() => {
4255
return projects.value.slice().reverse()
4356
})
4457
58+
const closeDialog = () => {
59+
isActive.value = false
60+
}
61+
4562
const queryProcess = async (id: string) => {
63+
closeDialog()
4664
const polygons = await loadProject(id)
4765
displayGeoJSON(polygons)
4866
fitMapToBbox(polygons.bbox)

0 commit comments

Comments
 (0)