Skip to content

Commit

Permalink
Improve Riparius handling
Browse files Browse the repository at this point in the history
  • Loading branch information
nimmolo committed Aug 9, 2024
1 parent f34c17c commit 33641a0
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 19 deletions.
15 changes: 10 additions & 5 deletions app/javascript/controllers/autocompleter_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -286,11 +286,16 @@ export default class extends Controller {
}
// set the map type so box is editable
this.mapOutlet.map_type = "hybrid"; // only if location_google

let location
if (location = this.mapOutlet.validateLatLngInputs(false)) {
this.mapOutlet.geocodeLatLng(location);
} else if (this.mapOutlet.hasLockBoxBtnTarget) {
// set the map to stop ignoring place input
this.mapOutlet.ignorePlaceInput = false;

// 2024-08-09: Don't geocode lat/lng when switching to location_google.
// This is for custom locations and should pay attention to place_name only.
// let location
// if (location = this.mapOutlet.validateLatLngInputs(false)) {
// this.mapOutlet.tryToGeocode();
// } else
if (this.mapOutlet.hasLockBoxBtnTarget) {
this.mapOutlet.lockBoxBtnTarget.classList.remove("d-none");
}
}
Expand Down
16 changes: 8 additions & 8 deletions app/javascript/controllers/geocode_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ export default class extends Controller {
}

tryToGeocode() {
let location
const location = this.validateLatLngInputs(false)

if (location = this.validateLatLngInputs(false) &&
if (location &&
JSON.stringify(location) !== JSON.stringify(this.lastGeocodedLatLng)) {
this.geocodeLatLng(location)
}
Expand Down Expand Up @@ -75,10 +75,10 @@ export default class extends Controller {
}

tryToGeolocate() {
let address = this.placeInputTarget.value
const address = this.placeInputTarget.value

if (this.ignorePlaceInput === false && address !== ""
&& address !== this.lastGeolocatedAddress) {
if (this.ignorePlaceInput === false &&
address !== "" && address !== this.lastGeolocatedAddress) {
this.geolocatePlaceName(address)
}
}
Expand Down Expand Up @@ -449,9 +449,9 @@ export default class extends Controller {

// ------------------------------- DEBUGGING ------------------------------

helpDebug() {
debugger
}
// helpDebug() {
// debugger
// }

verbose(str) {
// console.log(str);
Expand Down
12 changes: 6 additions & 6 deletions app/javascript/controllers/map_controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -398,11 +398,11 @@ export default class extends GeocodeController {
let id
if (this.hasLocationIdTarget && (id = this.locationIdTarget.value)) {
this.mapLocationIdData()
// Only geocode lat/lng if we have no location_id and not ignoring place
} else if (["location", "hybrid"].includes(this.map_type)) {
// Only geocode lat/lng if we have no location_id and not ignoring place
// ...and only geolocate placeName if we have no lat/lng
if (this.ignorePlaceInput !== false) {
this.tryToGeocode() // multiple possible results
// ...and only geolocate placeName if we have no lat/lng
} else {
this.tryToGeolocate()
}
Expand Down Expand Up @@ -499,7 +499,7 @@ export default class extends GeocodeController {
// Action called by the "Open Map" button only.
// open/close handled by BS collapse
toggleMap() {
// this.verbose("map:toggleMap")
this.verbose("map:toggleMap")
if (this.opened) {
this.opened = false
this.controlWrapTarget.classList.remove("map-open")
Expand Down Expand Up @@ -627,9 +627,9 @@ export default class extends GeocodeController {

// ------------------------------- DEBUGGING ------------------------------

helpDebug() {
debugger
}
// helpDebug() {
// debugger
// }

verbose(str) {
// console.log(str);
Expand Down

0 comments on commit 33641a0

Please sign in to comment.