diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json
index f2cceb725..822e7ef92 100644
--- a/apps/client/src/translations/en/translation.json
+++ b/apps/client/src/translations/en/translation.json
@@ -1755,7 +1755,8 @@
"created_on": "Created on ",
"last_modified": "Last modified on ",
"note_type_switcher_label": "Switch from {{type}} to:",
- "note_type_switcher_others": "More note types"
+ "note_type_switcher_others": "More note types",
+ "note_type_switcher_templates": "Templates"
},
"search_result": {
"no_notes_found": "No notes have been found for given search parameters.",
diff --git a/apps/client/src/widgets/layout/InlineTitle.tsx b/apps/client/src/widgets/layout/InlineTitle.tsx
index 0d12e384f..5029a5ebd 100644
--- a/apps/client/src/widgets/layout/InlineTitle.tsx
+++ b/apps/client/src/widgets/layout/InlineTitle.tsx
@@ -6,6 +6,9 @@ import { ComponentChild } from "preact";
import { useEffect, useMemo, useRef, useState } from "preact/hooks";
import { Trans } from "react-i18next";
+import FNote from "../../entities/fnote";
+import attributes from "../../services/attributes";
+import froca from "../../services/froca";
import { t } from "../../services/i18n";
import { ViewScope } from "../../services/link";
import { NOTE_TYPES, NoteTypeMapping } from "../../services/note_types";
@@ -168,24 +171,60 @@ function NoteTypeSwitcher() {
onClick={() => switchNoteType(note.noteId, noteType)}
/>
))}
-
- {restNoteTypes.map(noteType => (
- switchNoteType(note.noteId, noteType)}
- >{noteType.title}
- ))}
-
+
+
>
)}
);
}
+function MoreNoteTypes({ noteId, restNoteTypes }: { noteId: string, restNoteTypes: NoteTypeMapping[] }) {
+ return (
+
+ {restNoteTypes.map(noteType => (
+ switchNoteType(noteId, noteType)}
+ >{noteType.title}
+ ))}
+
+ );
+}
+
+function TemplateNoteTypes({ noteId }: { noteId: string }) {
+ const [ templates, setTemplates ] = useState([]);
+
+ async function refreshTemplates() {
+ const templateNoteIds = await server.get("search-templates");
+ const templateNotes = await froca.getNotes(templateNoteIds);
+ setTemplates(templateNotes);
+ }
+
+ useEffect(() => {
+ refreshTemplates();
+ }, []);
+
+ return (
+
+ {templates.map(template => (
+ attributes.setRelation(noteId, "template", template.noteId)}
+ >{template.title}
+ ))}
+
+ );
+}
+
function switchNoteType(noteId: string, { type, mime }: NoteTypeMapping) {
return server.put(`notes/${noteId}/type`, { type, mime });
}