Fix Edit/Delete on notes saved before properties.id existed
The earliest notes (saved before the previous commit added id
tracking) have no properties.id — update/delete target a feature by
that id, so offering Edit/Delete for one without it just 404s
("Could not delete/save the note", the generic fetch-failure alert).
The popup no longer offers Edit/Delete without an id. New
rake gpx:backfill_note_ids assigns one to any pre-existing Note
feature missing it, so already-saved notes become editable again too
— run once against wherever data/gpx actually lives (e.g. inside the
deployed container).
This commit is contained in:
1 parent
b0576f3725
commit
2a22906a68
3 files changed
+35
-1
No files matched your search
+4
-1
@@ -696,7 +696,10 @@ export class GpxPanelControl {
|
||||
this._map.on("click", layerId, (event) => {
|
||||
const feature = event.features[0];
|
||||
if (!feature) return;
|
||||
const editable = feature.properties.category === "Note" && isLoggedIn();
|
||||
// properties.id is what update/delete target by — a note saved before
|
||||
// that existed (see `rake gpx:backfill_note_ids`) doesn't have one
|
||||
// yet, and offering Edit/Delete for it would just 404.
|
||||
const editable = feature.properties.category === "Note" && !!feature.properties.id && isLoggedIn();
|
||||
const popup = new Popup({ closeButton: true, maxWidth: "260px" })
|
||||
.setLngLat(event.lngLat)
|
||||
.setHTML(popupHtml(feature.properties, { editable }))
|
||||
|
||||
Reference in new issue
Block a user