Add notes to a map #20
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Make that when right clicking a map, a right menu context menu opens, and that lets you add an existing note at the map, like a map pin or marker, so that when you click it it displays on a window the linked note.
Now I have a clear picture. Let me start with the backend.
Now the frontend pure helpers service:
Now the cycle guard improvement, then tests:
Implemented issue #20. Here's what landed:
Backend
backend/src/models/Map.js— a map now carries its pins:Coordinates are image pixels, so a pin stays where it was placed whatever the zoom, pan or grid settings are.
backend/src/routes/map.jsPOST /api/map/pin{id*, note*, x, y}— checks the map's owner and that the note belongs to the same campaign; coordinates are rounded and floored at 0. Pinning a note that is pinned already moves that marker instead of adding a twin. →{status:'ok', map}POST /api/map/unpin{id*, pin*}(the pin subdocument_id) →{status:'ok', map}, keeping the ids of the pins that remain.backend/src/routes/note.jsGET /api/note/all?campaign=— every note of the campaign (folders included, nocontent) so the picker reaches notes inside folders and every marker can say what it is.GET /api/note/retrieve/:id— one note with its content, ownership checked.POST /api/note/deletenow also pulls the deleted note off every map'spins(a pin pointing at a gone note would open nothing).Frontend
services/MapPins.js(new, pure): viewport → image pixel (ToImagePoint, returns null off the image), pin → screen pixel (ToScreenPoint), andBuildNoteOptions/OptionLabelwhich label the picker with the note's folder path (Undercity / Temple / The Altar) and sort by that label.MapViewerPane.vue: right clicking the map opens the context menu at the cursor with Pin a note here → a submenu of the campaign's notes; the clicked spot is kept for the action (reaching a submenu moves the mouse). Markers are drawn in a screen-space overlay, so they keep their size at any zoom while the overlay itself is pointer-transparent — panning the map still works everywhere but on a marker (@pointerdown.stopkeeps a marker click from starting a pan). Clicking a marker opens the note; right clicking one offers Open note / Remove pin. Markers follow a note rename (title-updated) and disappear with it (delete-note).PinnedNoteWindow.vue+pinned_noteinWindowDefinitions.js: reads the note through/note/retrieve/:id, renders its markdown, and mounts the note widgets (@roll…) the way the note column does, with loading and "note could not be read" states.ContentSidebar.vue: an updated map entry is written back to the anchored map, so the pins survive switching between the notes and the map pane.campaigns.map.pins.*,windows.pinned-note);AGENTS.mdupdated (data model row, note/map API, §5.1, event listeners).Verification
tests/map-pins.test.js(new, 28 tests) loads the express routers into anode:vmwith a stubbedrequireand the frontend helpers the waymap-viewer.test.jsloadsContent.js. It covers pin placement, coordinate rounding/clamping, the same-campaign and ownership refusals, pin dedup-on-move, unpin keeping the other pins, the picker/retrieve endpoints, delete pulling pins, the coordinate and label helpers, and the viewer wiring.npm test→ 57 passed, 0 failed (29 pre-existing included). I also compiled the three touched/added SFCs with@vue/compiler-sfc(all OK); I did not run the app in a browser — the frontend dependencies are not installed in this tree.Implementation is ready for review: #23