diff --git a/app/javascript/controllers/event_form_controller.js b/app/javascript/controllers/event_form_controller.js
index 567e289..df1d144 100644
--- a/app/javascript/controllers/event_form_controller.js
+++ b/app/javascript/controllers/event_form_controller.js
@@ -11,6 +11,7 @@ export default class extends Controller {
connect() {
this.geocodeTimeout = null
+ this.isManualGeocodingInProgress = false
// Initialize map links if we have an address and coordinates already exist
if (this.hasAddressTarget && this.addressTarget.value.trim() &&
@@ -195,6 +196,7 @@ export default class extends Controller {
const address = this.addressTarget.value.trim()
try {
+ this.isManualGeocodingInProgress = true
this.showLocationLoading()
const result = await this.performGeocode(address)
@@ -214,6 +216,7 @@ export default class extends Controller {
} catch (error) {
this.showLocationError("Erreur lors de la recherche de l'adresse.")
} finally {
+ this.isManualGeocodingInProgress = false
this.hideLocationLoading()
}
}
@@ -236,9 +239,11 @@ export default class extends Controller {
this.updateMapLinks()
console.log(`Auto-geocoded "${address}" to ${result.lat}, ${result.lng}`)
- // Show info if coordinates are approximate
- if (result.accuracy === 'approximate') {
- this.showApproximateLocationInfo(result.display_name)
+ // Show success message based on accuracy
+ if (result.accuracy === 'exact') {
+ this.showGeocodingSuccess("Adresse géolocalisée avec précision", result.display_name)
+ } else {
+ this.showGeocodingSuccess("Adresse géolocalisée approximativement", result.display_name)
}
} else {
// If auto-geocoding fails, show a subtle warning
@@ -274,10 +279,17 @@ export default class extends Controller {
const searchAddress = strategies[i]
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 {
const result = await this.tryGeocode(searchAddress)
if (result) {
console.log(`Geocoding successful with strategy ${i + 1}`)
+ this.hideMessage("geocoding-progress")
return result
}
} catch (error) {
@@ -290,6 +302,8 @@ export default class extends Controller {
}
}
+ this.hideMessage("geocoding-progress")
+
console.log('All geocoding strategies failed')
return null
}
@@ -528,6 +542,21 @@ export default class extends Controller {
setTimeout(() => this.hideMessage("approximate-location-info"), 6000)
}
+ // Show geocoding success with location details
+ showGeocodingSuccess(title, location) {
+ this.hideMessage("geocoding-success")
+ const message = `${title}
${location}`
+ 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
getMessageTemplate(type) {
const templates = {
@@ -632,5 +661,7 @@ export default class extends Controller {
this.hideMessage("location-error")
this.hideMessage("geocoding-warning")
this.hideMessage("approximate-location-info")
+ this.hideMessage("geocoding-success")
+ this.hideMessage("geocoding-progress")
}
}