develop #3

Merged
kbe merged 227 commits from develop into main 2025-09-16 14:35:23 +00:00
Showing only changes of commit 55b39e93bf - Show all commits

View File

@@ -11,6 +11,7 @@ export default class extends Controller {
connect() { connect() {
this.geocodeTimeout = null this.geocodeTimeout = null
this.isManualGeocodingInProgress = false
// Initialize map links if we have an address and coordinates already exist // Initialize map links if we have an address and coordinates already exist
if (this.hasAddressTarget && this.addressTarget.value.trim() && if (this.hasAddressTarget && this.addressTarget.value.trim() &&
@@ -195,6 +196,7 @@ export default class extends Controller {
const address = this.addressTarget.value.trim() const address = this.addressTarget.value.trim()
try { try {
this.isManualGeocodingInProgress = true
this.showLocationLoading() this.showLocationLoading()
const result = await this.performGeocode(address) const result = await this.performGeocode(address)
@@ -214,6 +216,7 @@ export default class extends Controller {
} catch (error) { } catch (error) {
this.showLocationError("Erreur lors de la recherche de l'adresse.") this.showLocationError("Erreur lors de la recherche de l'adresse.")
} finally { } finally {
this.isManualGeocodingInProgress = false
this.hideLocationLoading() this.hideLocationLoading()
} }
} }
@@ -236,9 +239,11 @@ export default class extends Controller {
this.updateMapLinks() this.updateMapLinks()
console.log(`Auto-geocoded "${address}" to ${result.lat}, ${result.lng}`) console.log(`Auto-geocoded "${address}" to ${result.lat}, ${result.lng}`)
// Show info if coordinates are approximate // Show success message based on accuracy
if (result.accuracy === 'approximate') { if (result.accuracy === 'exact') {
this.showApproximateLocationInfo(result.display_name) this.showGeocodingSuccess("Adresse géolocalisée avec précision", result.display_name)
} else {
this.showGeocodingSuccess("Adresse géolocalisée approximativement", result.display_name)
} }
} else { } else {
// If auto-geocoding fails, show a subtle warning // If auto-geocoding fails, show a subtle warning
@@ -274,10 +279,17 @@ export default class extends Controller {
const searchAddress = strategies[i] const searchAddress = strategies[i]
console.log(`Geocoding attempt ${i + 1}: "${searchAddress}"`) console.log(`Geocoding attempt ${i + 1}: "${searchAddress}"`)
// Show progress for manual geocoding (not auto-geocoding)
if (this.isManualGeocodingInProgress) {
const strategyNames = ['adresse complète', 'rue et ville', 'ville seulement']
this.showGeocodingProgress(strategyNames[i] || `stratégie ${i + 1}`, `${i + 1}/${strategies.length}`)
}
try { try {
const result = await this.tryGeocode(searchAddress) const result = await this.tryGeocode(searchAddress)
if (result) { if (result) {
console.log(`Geocoding successful with strategy ${i + 1}`) console.log(`Geocoding successful with strategy ${i + 1}`)
this.hideMessage("geocoding-progress")
return result return result
} }
} catch (error) { } catch (error) {
@@ -290,6 +302,8 @@ export default class extends Controller {
} }
} }
this.hideMessage("geocoding-progress")
console.log('All geocoding strategies failed') console.log('All geocoding strategies failed')
return null return null
} }
@@ -528,6 +542,21 @@ export default class extends Controller {
setTimeout(() => this.hideMessage("approximate-location-info"), 6000) setTimeout(() => this.hideMessage("approximate-location-info"), 6000)
} }
// Show geocoding success with location details
showGeocodingSuccess(title, location) {
this.hideMessage("geocoding-success")
const message = `${title}<br><small class="opacity-75">${location}</small>`
this.showMessage("geocoding-success", message, "success")
setTimeout(() => this.hideMessage("geocoding-success"), 5000)
}
// Show geocoding progress with strategy info
showGeocodingProgress(strategy, attempt) {
this.hideMessage("geocoding-progress")
const message = `Recherche en cours... (${attempt}/${strategy})`
this.showMessage("geocoding-progress", message, "loading")
}
// Message template configurations // Message template configurations
getMessageTemplate(type) { getMessageTemplate(type) {
const templates = { const templates = {
@@ -632,5 +661,7 @@ export default class extends Controller {
this.hideMessage("location-error") this.hideMessage("location-error")
this.hideMessage("geocoding-warning") this.hideMessage("geocoding-warning")
this.hideMessage("approximate-location-info") this.hideMessage("approximate-location-info")
this.hideMessage("geocoding-success")
this.hideMessage("geocoding-progress")
} }
} }