Fix note UX: unreachable wiki link, white Save hover, stale icon preview, invisible new points
- "Nearby on Wikipedia" linked to KIWIX_URL, a Docker-internal hostname (http://kiwix:8080) no real browser can resolve. Split it: KIWIX_URL stays server-side-only for the reachability check, and the link itself is built from KIWIX_PUBLIC_PORT (kiwix-serve's newly published host port) plus whatever host the visitor already used to reach maptool — works regardless of which hostname/IP that is. - The Save button went white on hover in GTK-themed Chrome: the browser's native button skin was painting over the custom background because appearance wasn't reset. - The map preview marker for a pending note always showed a plain red pin no matter which icon was picked in the form. NoteSaveForm now reports icon changes via onIconChange so NotesControl can update the marker's glyph live. - Saving a note (or a Measure "Save as note") left the new/grown .geojson file unchecked and invisible until manually toggled on. notifyGpxStoreChanged now carries the affected path so GpxPanelControl auto-shows it.
This commit is contained in:
1 parent
4f022ec43a
commit
9997a8a8c0
7 files changed
+103
-17
No files matched your search
+15
-3
@@ -45,9 +45,10 @@ export function generateNoteId() {
|
||||
// container it's given (each caller owns where that sits in its own panel);
|
||||
// hidden until open() is called.
|
||||
export class NoteSaveForm {
|
||||
constructor(container, { onSaved, onCancel } = {}) {
|
||||
constructor(container, { onSaved, onCancel, onIconChange } = {}) {
|
||||
this._onSaved = onSaved;
|
||||
this._onCancel = onCancel;
|
||||
this._onIconChange = onIconChange;
|
||||
|
||||
this._el = document.createElement("div");
|
||||
this._el.className = "notes-panel__form";
|
||||
@@ -85,6 +86,7 @@ export class NoteSaveForm {
|
||||
button.addEventListener("click", () => {
|
||||
this._selectedIcon = button.dataset.icon;
|
||||
this._iconPicker.querySelectorAll(".notes-panel__icon-option").forEach((b) => b.classList.toggle("active", b === button));
|
||||
this._onIconChange?.(this._selectedIcon);
|
||||
});
|
||||
});
|
||||
this._target.addEventListener("change", () => {
|
||||
@@ -106,6 +108,7 @@ export class NoteSaveForm {
|
||||
this._body.value = "";
|
||||
this._selectedIcon = "";
|
||||
this._iconPicker.querySelectorAll(".notes-panel__icon-option").forEach((b, i) => b.classList.toggle("active", i === 0));
|
||||
this._onIconChange?.(this._selectedIcon);
|
||||
// An icon only makes sense on a single point — Measure's "Save as
|
||||
// note" can hand this a LineString/Polygon, which has no one spot for
|
||||
// a badge glyph to sit at.
|
||||
@@ -173,7 +176,8 @@ export class NoteSaveForm {
|
||||
try {
|
||||
const response = await fetch("/api/gpx/notes", { method: "POST", body: requestBody });
|
||||
if (!response.ok) throw new Error(`save failed: ${response.status}`);
|
||||
notifyGpxStoreChanged();
|
||||
const { path } = await response.json();
|
||||
notifyGpxStoreChanged(path);
|
||||
this.close();
|
||||
this._onSaved?.();
|
||||
} catch (err) {
|
||||
@@ -219,6 +223,11 @@ export class NotesControl {
|
||||
this._hint.hidden = false;
|
||||
this._removeMarker();
|
||||
},
|
||||
// Keeps the map preview in sync with the icon picker — it used to
|
||||
// always show a plain red pin no matter which icon got picked.
|
||||
onIconChange: (icon) => {
|
||||
if (this._marker) this._marker.getElement().innerHTML = icon && POI_ICONS[icon] ? POI_ICONS[icon] : NOTE_PIN_ICON;
|
||||
},
|
||||
});
|
||||
|
||||
this._button.addEventListener("click", () => this._setActive(!this._active));
|
||||
@@ -226,7 +235,10 @@ export class NotesControl {
|
||||
this._onClick = (event) => {
|
||||
if (!this._active || this._form.isOpen) return;
|
||||
this._hint.hidden = true;
|
||||
this._marker = new Marker({ color: "#c0392b" }).setLngLat(event.lngLat).addTo(this._map);
|
||||
const el = document.createElement("div");
|
||||
el.className = "notes-panel__preview-marker";
|
||||
el.innerHTML = NOTE_PIN_ICON;
|
||||
this._marker = new Marker({ element: el }).setLngLat(event.lngLat).addTo(this._map);
|
||||
this._form.open({ type: "Point", coordinates: [event.lngLat.lng, event.lngLat.lat] });
|
||||
};
|
||||
map.on("click", this._onClick);
|
||||
|
||||
Reference in new issue
Block a user