Make the map editor accept a click, and unclutter its panel
This commit is contained in:
@@ -45,7 +45,7 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Legend for asset type mode - shows subtypes when a type is selected -->
|
<!-- Legend for asset type mode - shows subtypes when a type is selected -->
|
||||||
<div class="map-legend" v-if="!pickerMode && assetTypeMode">
|
<div class="map-legend" v-if="!pickerMode && assetTypeMode && hasLegendEntries">
|
||||||
<!-- Show subtype legend when a specific type is selected -->
|
<!-- Show subtype legend when a specific type is selected -->
|
||||||
<template v-if="selectedAssetType && Object.keys(visibleSubtypes).length">
|
<template v-if="selectedAssetType && Object.keys(visibleSubtypes).length">
|
||||||
<span
|
<span
|
||||||
@@ -120,6 +120,14 @@ const props = defineProps({
|
|||||||
|
|
||||||
const emit = defineEmits(['markerClick', 'positionPicked'])
|
const emit = defineEmits(['markerClick', 'positionPicked'])
|
||||||
|
|
||||||
|
// An empty legend still drew its bar and border, which looked like a stray input
|
||||||
|
// box under the toolbar. It renders only when it has something in it.
|
||||||
|
const hasLegendEntries = computed(() => {
|
||||||
|
if (props.selectedAssetType && Object.keys(visibleSubtypes.value).length) return true
|
||||||
|
if (Object.keys(visibleAssetTypes.value).length) return true
|
||||||
|
return overlayLegend.value.length > 0
|
||||||
|
})
|
||||||
|
|
||||||
const mapContainer = ref(null)
|
const mapContainer = ref(null)
|
||||||
let map = null
|
let map = null
|
||||||
let imageOverlay = null
|
let imageOverlay = null
|
||||||
@@ -296,17 +304,22 @@ function initMap() {
|
|||||||
map.setView([MAP_HEIGHT / 2, MAP_WIDTH / 2], initialZoom)
|
map.setView([MAP_HEIGHT / 2, MAP_WIDTH / 2], initialZoom)
|
||||||
map.setMaxBounds(bounds)
|
map.setMaxBounds(bounds)
|
||||||
|
|
||||||
// Picker mode: click to set position
|
// Bound UNCONDITIONALLY, and handleMapClick ignores the click when picker mode
|
||||||
if (props.pickerMode) {
|
// is off. Binding it only when pickerMode was true AT MOUNT meant a map that
|
||||||
map.on('click', handleMapClick)
|
// becomes a picker later never got a click handler at all: the map editor
|
||||||
|
// opens with nothing selected, so clicking to place a marker did nothing, for
|
||||||
|
// the whole life of the page. The asset forms only worked because their picker
|
||||||
|
// is mounted inside a modal that is already in picker mode.
|
||||||
|
map.on('click', handleMapClick)
|
||||||
|
|
||||||
// Show initial position if provided
|
if (props.pickerMode && props.initialPosition) {
|
||||||
if (props.initialPosition) {
|
setPickerPosition(props.initialPosition.left, props.initialPosition.top)
|
||||||
setPickerPosition(props.initialPosition.left, props.initialPosition.top)
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
renderMarkers()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Existing markers are drawn in picker mode too: placing a marker relative to
|
||||||
|
// the ones already on the floor is the whole task. The forms pass no markers,
|
||||||
|
// so this costs them nothing.
|
||||||
|
renderMarkers()
|
||||||
}
|
}
|
||||||
|
|
||||||
function handleMapClick(e) {
|
function handleMapClick(e) {
|
||||||
|
|||||||
@@ -518,13 +518,27 @@ function cancelEdit() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
.panel-header {
|
.panel-header {
|
||||||
|
/* The heading takes its own row and the three controls share the next one(s).
|
||||||
|
All four on a single row inside a 320px panel squeezed the search box until
|
||||||
|
its placeholder read "Search na". */
|
||||||
display: flex;
|
display: flex;
|
||||||
justify-content: space-between;
|
flex-wrap: wrap;
|
||||||
|
gap: 0.5rem;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
padding: 1rem;
|
padding: 1rem;
|
||||||
border-bottom: 1px solid var(--border);
|
border-bottom: 1px solid var(--border);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.panel-header h3 {
|
||||||
|
flex: 1 1 100%;
|
||||||
|
}
|
||||||
|
|
||||||
|
.panel-header .form-control {
|
||||||
|
/* Shrinkable and equal, so nothing gets crushed to fit a sibling. */
|
||||||
|
flex: 1 1 8rem;
|
||||||
|
min-width: 0;
|
||||||
|
}
|
||||||
|
|
||||||
.panel-header h3 {
|
.panel-header h3 {
|
||||||
margin: 0;
|
margin: 0;
|
||||||
font-size: 1rem;
|
font-size: 1rem;
|
||||||
|
|||||||
Reference in New Issue
Block a user