Full update to map css

This commit is contained in:
2025-07-27 17:49:37 -06:00
parent f0289d027e
commit 61176386a1
26 changed files with 1971 additions and 1847 deletions

View File

@@ -5,5 +5,33 @@ export const CONFIG = {
DEFAULT_ZOOM: parseInt(document.querySelector('meta[name="default-zoom"]')?.content) || 11,
REFRESH_INTERVAL: 30000, // 30 seconds
MAX_ZOOM: 20,
MIN_ZOOM: 2
MIN_ZOOM: 2,
domain: null // Will be loaded dynamically
};
// Load domain configuration from server
export async function loadDomainConfig() {
try {
const response = await fetch('/api/config/domain');
if (response.ok) {
const data = await response.json();
CONFIG.domain = data.domain;
updateHomepageLinks();
} else {
console.error('Failed to load domain config:', response.status);
}
} catch (error) {
console.error('Error loading domain config:', error);
}
}
// Update homepage links with the configured domain
function updateHomepageLinks() {
if (CONFIG.domain) {
const homepageUrl = `https://homepage.${CONFIG.domain}`;
const homepageLink = document.getElementById('homepage-link');
if (homepageLink) {
homepageLink.href = homepageUrl;
}
}
}

View File

@@ -428,8 +428,8 @@ function setupApartmentPopupListeners(props) {
// Close the popup first
map.closePopup();
// Open the add modal with pre-filled data
openAddModal(lat, lng);
// Open the add modal but prevent the automatic address lookup
openAddModal(lat, lng, false);
// Pre-fill the form with Edmonton data, focusing on the selected suite
setTimeout(() => {
@@ -470,8 +470,8 @@ function setupSingleUnitPopupListeners() {
// Close the popup first
map.closePopup();
// Open the add modal with pre-filled data
openAddModal(lat, lng);
// Open the add modal but prevent the automatic address lookup
openAddModal(lat, lng, false);
// Pre-fill the form with Edmonton data
setTimeout(() => {
@@ -494,8 +494,14 @@ function setupSingleUnitPopupListeners() {
/**
* Pre-fills the add location form with city data
*/
function prefillAddForm(data) {
async function prefillAddForm(data) {
try {
// Import UI controls dynamically to avoid circular dependencies
const { resetAddressConfirmation } = await import('./ui-controls.js');
// First, reset any existing state
resetAddressConfirmation('add');
// Basic form fields
if (data.address) {
const addressField = document.getElementById('location-address');
@@ -514,8 +520,8 @@ function prefillAddForm(data) {
// Notes field with additional context
const notesField = document.getElementById('location-notes');
if (notesField && data.notes) {
let notes = data.notes;
if (notesField) {
let notes = data.notes || '';
// Add neighborhood information if available
if (data.neighborhood && data.neighborhood.trim()) {
@@ -537,7 +543,7 @@ function prefillAddForm(data) {
notes += `\nSuite: ${data.suite}`;
}
notesField.value = notes;
notesField.value = notes.trim();
}
// Set coordinates (already set by openAddModal, but ensure they're correct)
@@ -555,7 +561,11 @@ function prefillAddForm(data) {
geoField.value = `${data.lat.toFixed(8)};${data.lng.toFixed(8)}`;
}
console.log('Form pre-filled with city data:', data);
// Mark the address as confirmed since it's coming from a trusted source
const { setAddressConfirmed } = await import('./ui-controls.js');
setAddressConfirmed('add', true);
console.log('Form pre-filled and confirmed with city data:', data);
} catch (error) {
console.error('Error pre-filling form:', error);

View File

@@ -470,7 +470,7 @@ export function closeAddModal() {
document.getElementById('location-form').reset();
}
export function openAddModal(lat, lng) {
export function openAddModal(lat, lng, performLookup = true) {
const modal = document.getElementById('add-modal');
const latInput = document.getElementById('location-lat');
const lngInput = document.getElementById('location-lng');
@@ -493,11 +493,13 @@ export function openAddModal(lat, lng) {
// Show modal
modal.classList.remove('hidden');
// Trigger custom event for auto address lookup
const autoLookupEvent = new CustomEvent('autoAddressLookup', {
detail: { mode: 'add', lat, lng }
});
document.dispatchEvent(autoLookupEvent);
// Conditionally perform the auto address lookup
if (performLookup) {
const autoLookupEvent = new CustomEvent('autoAddressLookup', {
detail: { mode: 'add', lat, lng }
});
document.dispatchEvent(autoLookupEvent);
}
}
// Replace the startMovingMarker function

View File

@@ -1,5 +1,5 @@
// Main application entry point
import { CONFIG } from './config.js';
import { CONFIG, loadDomainConfig } from './config.js';
import { hideLoading, showStatus, setViewportDimensions } from './utils.js';
import { checkAuth } from './auth.js';
import { initializeMap } from './map-manager.js';
@@ -24,6 +24,9 @@ document.addEventListener('DOMContentLoaded', async () => {
console.log('DOM loaded, initializing application...');
try {
// Load domain configuration first
await loadDomainConfig();
// First check authentication
await checkAuth();

View File

@@ -20,6 +20,50 @@ export function getAddressConfirmationState() {
};
}
/**
* Sets the address confirmation state and updates the UI accordingly.
* @param {'add' | 'edit'} mode - The form mode.
* @param {boolean} confirmed - The confirmation state to set.
*/
export function setAddressConfirmed(mode, confirmed) {
const button = mode === 'add' ?
document.getElementById('confirm-address-add-btn') :
document.getElementById('confirm-address-edit-btn');
const saveButton = mode === 'add' ?
document.getElementById('save-location-btn') :
document.getElementById('save-edit-location-btn');
if (mode === 'add') {
isAddressConfirmed = confirmed;
} else {
isEditAddressConfirmed = confirmed;
}
if (confirmed) {
if (button) {
button.textContent = '✅ Address Confirmed';
button.classList.remove('btn-secondary');
button.classList.add('btn-success');
button.disabled = false;
}
if (saveButton) {
saveButton.disabled = false;
}
} else {
// This is essentially what resetAddressConfirmation does
if (button) {
button.textContent = '📍 Confirm Address';
button.classList.remove('btn-success');
button.classList.add('btn-secondary');
button.disabled = false;
}
if (saveButton) {
saveButton.disabled = true;
}
}
}
// Add logout function
async function logout() {
try {
@@ -532,7 +576,7 @@ export function setupEventListeners() {
if (marker) {
startMovingMarker(locationData, marker);
} else {
} else {
console.error('Could not find marker for location:', locationData);
showStatus('Could not find marker for this location', 'error');
}