From 10f8da8015072b695d980be480edbb67b7f5f8d8 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 22 Dec 2024 17:33:00 +0200 Subject: [PATCH] refactor(client/ts): use context_menu in note_type_chooser --- src/public/app/services/note_types.ts | 17 ++--------------- .../app/widgets/dialogs/note_type_chooser.ts | 16 +++++++++------- 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/public/app/services/note_types.ts b/src/public/app/services/note_types.ts index 472004dab..cb491b4c4 100644 --- a/src/public/app/services/note_types.ts +++ b/src/public/app/services/note_types.ts @@ -1,23 +1,10 @@ import server from "./server.js"; import froca from "./froca.js"; import { t } from "./i18n.js"; - -interface NoteTypeSeparator { - title: "----" -} - -export interface NoteType { - title: string; - command?: string; - type: string; - uiIcon: string; - templateNoteId?: string; -} - -type NoteTypeItem = NoteType | NoteTypeSeparator; +import { MenuItem } from "../menus/context_menu.js"; async function getNoteTypeItems(command?: string) { - const items: NoteTypeItem[] = [ + const items: MenuItem[] = [ { title: t("note_types.text"), command: command, type: "text", uiIcon: "bx bx-note" }, { title: t("note_types.code"), command: command, type: "code", uiIcon: "bx bx-code" }, { title: t("note_types.saved-search"), command: command, type: "search", uiIcon: "bx bx-file-find" }, diff --git a/src/public/app/widgets/dialogs/note_type_chooser.ts b/src/public/app/widgets/dialogs/note_type_chooser.ts index 57995e315..6af7c4e3b 100644 --- a/src/public/app/widgets/dialogs/note_type_chooser.ts +++ b/src/public/app/widgets/dialogs/note_type_chooser.ts @@ -1,5 +1,6 @@ +import { MenuCommandItem } from "../../menus/context_menu.js"; import { t } from "../../services/i18n.js"; -import noteTypesService, { NoteType } from "../../services/note_types.js"; +import noteTypesService from "../../services/note_types.js"; import BasicWidget from "../basic_widget.js"; const TPL = ` @@ -9,7 +10,7 @@ const TPL = ` /* note type chooser needs to be higher than other dialogs from which it is triggered, e.g. "add link"*/ z-index: 1100 !important; } - + .note-type-chooser-dialog .note-type-dropdown { position: relative; font-size: large; @@ -67,7 +68,7 @@ export default class NoteTypeChooserDialog extends BasicWidget { } doRender() { - this.$widget = $(TPL); + this.$widget = $(TPL); // TODO: Remove once we import bootstrap the right way //@ts-ignore this.modal = bootstrap.Modal.getOrCreateInstance(this.$widget); @@ -126,12 +127,13 @@ export default class NoteTypeChooserDialog extends BasicWidget { for (const noteType of noteTypes) { if (noteType.title === '----') { this.$noteTypeDropdown.append($('