Skip to content

Build your personal knowledge base with Trilium Notes

feat(geomap): leave a new marker to be named as any new note is

Elian Doran6ff77f544746
diff --git a/apps/client/src/widgets/collections/geomap/api.spec.ts b/apps/client/src/widgets/collections/geomap/api.spec.ts
index c239763987..03d4cfda44 100644
--- a/apps/client/src/widgets/collections/geomap/api.spec.ts
+++ b/apps/client/src/widgets/collections/geomap/api.spec.ts
@@ -17,10 +17,6 @@ vi.mock("../../../services/note_create", () => ({
default: { createNote: vi.fn(async () => ({ note: { noteId: "created" }, branch: null })) }
}));
-// i18next is not initialized under test, so t() returns nothing. The key stands in for the text,
-// which is enough to tell the stock name from a name the place brought with it.
-vi.mock("../../../services/i18n", () => ({ t: (key: string) => key }));
-
vi.mock("../../../services/attributes", () => ({ default: { setLabel: vi.fn(async () => {}) } }));
vi.mock("../../../services/note_deletion", () => ({ deleteNoteOrBranch: vi.fn(async () => {}) }));
vi.mock("../../../services/dialog", () => ({
@@ -35,7 +31,7 @@ const confirmDelete = vi.mocked(dialog.confirmDeleteNoteBoxWithNote);
beforeEach(() => vi.clearAllMocks());
describe("geo map api", () => {
- it("creates a placed note under the stock name, located where the click landed", async () => {
+ it("leaves a placed note to be named as any new note is, where the click landed", async () => {
const parent = buildNote({ title: "The map" });
const created = await createNewNote(parent, {
@@ -48,8 +44,10 @@ describe("geo map api", () => {
expect(created).toEqual({ noteId: "created" });
expect(createNote).toHaveBeenCalledWith(parent.noteId, expect.objectContaining({
type: "text",
+ // No name is sent, which is what leaves the naming where every other new note's is: the
+ // server's, and so a `#titleTemplate` on the map's if it carries one.
+ title: undefined,
// Nothing is asked first — the name is typed over in the pane, not answered in a modal.
- title: "relation_map.default_new_note_title",
activate: false,
attributes: expect.arrayContaining([
{ type: "label", name: "geolocation", value: "48.85,2.36" },
@@ -76,7 +74,7 @@ describe("geo map api", () => {
}));
});
- it("gives a note kept from a bare point the name a placed marker gets", async () => {
+ it("leaves a note kept from a bare point to be named as a placed one is", async () => {
const parent = buildNote({ title: "The map" });
// A point read out of the search bar is called by its own coordinates, which is no title.
@@ -85,7 +83,7 @@ describe("geo map api", () => {
expect(created).toEqual({ noteId: "created" });
expect(createNote).toHaveBeenCalledWith(parent.noteId, expect.objectContaining({
- title: "relation_map.default_new_note_title",
+ title: undefined,
attributes: expect.arrayContaining([
{ type: "label", name: "geolocation", value: "45.796,24.147" }
])
diff --git a/apps/client/src/widgets/collections/geomap/api.ts b/apps/client/src/widgets/collections/geomap/api.ts
index 069947aab3..f7ad99359f 100644
--- a/apps/client/src/widgets/collections/geomap/api.ts
+++ b/apps/client/src/widgets/collections/geomap/api.ts
@@ -92,11 +92,11 @@ export async function importGpxTrack(parentNote: FNote, file: File) {
*
* No title is asked for first. A modal between the click and the note was the wrong way round: it
* blocked the map to ask for the one thing the detail pane is made for editing. The note is created
- * under the stock name instead, and the caller opens the pane on it with that name selected — naming
- * the place is typing over it (see index.tsx).
+ * unnamed instead, and the caller opens the pane on it with the name it was given selected —
+ * naming the place is typing over it (see index.tsx).
*/
export async function createNewNote(parentNote: FNote, e: GeoMouseEvent) {
- return createNoteAt(parentNote, [ e.latlng.lat, e.latlng.lng ], t("relation_map.default_new_note_title"));
+ return createNoteAt(parentNote, [ e.latlng.lat, e.latlng.lng ]);
}
/**
@@ -111,7 +111,7 @@ export async function createNewNote(parentNote: FNote, e: GeoMouseEvent) {
* takes instead, and the pane opens on it the same way (see `keepPlaceAsMarker` in index).
*/
export async function createNoteForPlace(parentNote: FNote, place: PlaceToKeep) {
- const title = place.unnamed ? t("relation_map.default_new_note_title") : place.name;
+ const title = place.unnamed ? undefined : place.name;
return createNoteAt(parentNote, [ place.lat, place.lng ], title);
}
@@ -124,7 +124,15 @@ interface PlaceToKeep {
unnamed?: boolean;
}
-async function createNoteAt(parentNote: FNote, [ lat, lng ]: [number, number], title: string) {
+/**
+ * Creates a located note under the map.
+ *
+ * A note with no name of its own is created without one rather than under a name of the map's
+ * choosing, which is what leaves the naming to the server: an unnamed note takes the name every
+ * new note takes — the one the tree's + button gives — and a map labelled `#titleTemplate` names
+ * its markers by that instead.
+ */
+async function createNoteAt(parentNote: FNote, [ lat, lng ]: [number, number], title?: string) {
const { note } = await note_create.createNote(parentNote.noteId, {
title,
content: "",
diff --git a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
index 2c20ce385c..d04cb78d88 100644
--- a/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
+++ b/apps/server/src/assets/doc_notes/en/User Guide/User Guide/Collections/Geo Map.html
@@ -88,10 +88,12 @@
above everything else, and taking it flies the map to that exact spot and
marks it, so it can be kept as a marker in the same way a searched place
can.</p>
-<p>A point has no name of its own, only the coordinates it was typed as. The
- note kept from one is therefore created under the same stock name a marker
- placed with the <em>Add marker</em> button gets, and opens with that title
- selected, ready to be typed over.</p>
+<p>A point has no name of its own. It only has the coordinates you typed. The
+ note is therefore given the same name as any other new note, which is the name
+ you also get from the <em>Add marker</em> button and from the + button in the
+ note tree. The note opens with that name selected, so you can type over it. If
+ the map has a <a class="reference-link" href="#root/_help_47ZrP6FNuoG8">titleTemplate</a> label,
+ the marker is named by that template instead.</p>
<p>The forms understood are:</p>
<ul>
<li>A plain pair, <code spellcheck="false">45.9432, 24.9668</code> — what both Google Maps and
diff --git a/docs/User Guide/User Guide/Collections/Geo Map.md b/docs/User Guide/User Guide/Collections/Geo Map.md
index 2a7bd59a5d..5d8cbb3113 100644
--- a/docs/User Guide/User Guide/Collections/Geo Map.md
+++ b/docs/User Guide/User Guide/Collections/Geo Map.md
@@ -62,7 +62,7 @@ The search prefers what the map is showing. Places inside the current view are l
Coordinates typed or pasted into the search bar are offered as a _Go to_ row above everything else, and taking it flies the map to that exact spot and marks it, so it can be kept as a marker in the same way a searched place can.
-A point has no name of its own, only the coordinates it was typed as. The note kept from one is therefore created under the same stock name a marker placed with the _Add marker_ button gets, and opens with that title selected, ready to be typed over.
+A point has no name of its own. It only has the coordinates you typed. The note is therefore given the same name as any other new note, which is the name you also get from the _Add marker_ button and from the + button in the note tree. The note opens with that name selected, so you can type over it. If the map has a <a class="reference-link" href="../Advanced%20Usage/Default%20Note%20Title.md">titleTemplate</a> label, the marker is named by that template instead.
The forms understood are: