diff --git a/apps/client/src/translations/cn/translation.json b/apps/client/src/translations/cn/translation.json index cd1b86123..d26594bfc 100644 --- a/apps/client/src/translations/cn/translation.json +++ b/apps/client/src/translations/cn/translation.json @@ -234,7 +234,7 @@ "modal_title": "选择笔记类型", "close": "关闭", "modal_body": "选择新笔记的类型或模板:", - "templates": "模板:" + "templates": "模板" }, "password_not_set": { "title": "密码未设置", diff --git a/apps/client/src/translations/de/translation.json b/apps/client/src/translations/de/translation.json index 5cb7dfa07..ef6bb1dec 100644 --- a/apps/client/src/translations/de/translation.json +++ b/apps/client/src/translations/de/translation.json @@ -233,7 +233,7 @@ "modal_title": "Wähle den Notiztyp aus", "close": "Schließen", "modal_body": "Wähle den Notiztyp / die Vorlage der neuen Notiz:", - "templates": "Vorlagen:" + "templates": "Vorlagen" }, "password_not_set": { "title": "Das Passwort ist nicht festgelegt", diff --git a/apps/client/src/translations/en/translation.json b/apps/client/src/translations/en/translation.json index 4060745ab..9aec664fd 100644 --- a/apps/client/src/translations/en/translation.json +++ b/apps/client/src/translations/en/translation.json @@ -238,7 +238,8 @@ "modal_title": "Choose note type", "close": "Close", "modal_body": "Choose note type / template of the new note:", - "templates": "Templates:" + "templates": "Templates", + "builtin_templates": "Built-in Templates" }, "password_not_set": { "title": "Password is not set", diff --git a/apps/client/src/translations/es/translation.json b/apps/client/src/translations/es/translation.json index 6043ea6bc..9de765399 100644 --- a/apps/client/src/translations/es/translation.json +++ b/apps/client/src/translations/es/translation.json @@ -236,7 +236,7 @@ "modal_title": "Elija el tipo de nota", "close": "Cerrar", "modal_body": "Elija el tipo de nota/plantilla de la nueva nota:", - "templates": "Plantillas:" + "templates": "Plantillas" }, "password_not_set": { "title": "La contraseña no está establecida", diff --git a/apps/client/src/translations/fr/translation.json b/apps/client/src/translations/fr/translation.json index 53836b014..86f2faf5c 100644 --- a/apps/client/src/translations/fr/translation.json +++ b/apps/client/src/translations/fr/translation.json @@ -233,7 +233,7 @@ "modal_title": "Choisissez le type de note", "close": "Fermer", "modal_body": "Choisissez le type de note/le modèle de la nouvelle note :", - "templates": "Modèles :" + "templates": "Modèles" }, "password_not_set": { "title": "Le mot de passe n'est pas défini", diff --git a/apps/client/src/translations/ro/translation.json b/apps/client/src/translations/ro/translation.json index e4d6288ba..c78c34b45 100644 --- a/apps/client/src/translations/ro/translation.json +++ b/apps/client/src/translations/ro/translation.json @@ -896,7 +896,7 @@ "note_type_chooser": { "modal_body": "Selectați tipul notiței/șablonul pentru noua notiță:", "modal_title": "Selectați tipul notiței", - "templates": "Șabloane:", + "templates": "Șabloane", "close": "Închide", "change_path_prompt": "Selectați locul unde să se creeze noua notiță:", "search_placeholder": "căutare cale notiță după nume (cea implicită dacă este necompletat)" diff --git a/apps/client/src/translations/sr/translation.json b/apps/client/src/translations/sr/translation.json index c6eeb8bff..5dbef4546 100644 --- a/apps/client/src/translations/sr/translation.json +++ b/apps/client/src/translations/sr/translation.json @@ -238,7 +238,7 @@ "modal_title": "Izaberite tip beleške", "close": "Zatvori", "modal_body": "Izaberite tip beleške / šablon za novu belešku:", - "templates": "Šabloni:" + "templates": "Šabloni" }, "password_not_set": { "title": "Lozinka nije podešena", diff --git a/apps/client/src/translations/tw/translation.json b/apps/client/src/translations/tw/translation.json index 4140719b7..fbc9aa1c9 100644 --- a/apps/client/src/translations/tw/translation.json +++ b/apps/client/src/translations/tw/translation.json @@ -213,7 +213,7 @@ "note_type_chooser": { "modal_title": "選擇筆記類型", "modal_body": "選擇新筆記的類型或模板:", - "templates": "模板:" + "templates": "模板" }, "password_not_set": { "title": "密碼未設定", diff --git a/apps/client/src/widgets/dialogs/note_type_chooser.ts b/apps/client/src/widgets/dialogs/note_type_chooser.ts deleted file mode 100644 index 34a89aff6..000000000 --- a/apps/client/src/widgets/dialogs/note_type_chooser.ts +++ /dev/null @@ -1,204 +0,0 @@ -import type { CommandNames } from "../../components/app_context.js"; -import type { MenuCommandItem } from "../../menus/context_menu.js"; -import { t } from "../../services/i18n.js"; -import noteTypesService from "../../services/note_types.js"; -import noteAutocompleteService from "../../services/note_autocomplete.js"; -import BasicWidget from "../basic_widget.js"; -import { Dropdown, Modal } from "bootstrap"; - -const TPL = /*html*/` -`; - -export interface ChooseNoteTypeResponse { - success: boolean; - noteType?: string; - templateNoteId?: string; - notePath?: string; -} - -type Callback = (data: ChooseNoteTypeResponse) => void; - -export default class NoteTypeChooserDialog extends BasicWidget { - private resolve: Callback | null; - private dropdown!: Dropdown; - private modal!: Modal; - private $noteTypeDropdown!: JQuery; - private $autoComplete!: JQuery; - private $originalFocused: JQuery | null; - private $originalDialog: JQuery | null; - - constructor() { - super(); - - this.resolve = null; - this.$originalFocused = null; // element focused before the dialog was opened, so we can return to it afterward - this.$originalDialog = null; - } - - doRender() { - this.$widget = $(TPL); - this.modal = Modal.getOrCreateInstance(this.$widget[0]); - - this.$autoComplete = this.$widget.find(".choose-note-path"); - this.$noteTypeDropdown = this.$widget.find(".note-type-dropdown"); - this.dropdown = Dropdown.getOrCreateInstance(this.$widget.find(".note-type-dropdown-trigger")[0]); - - this.$widget.on("hidden.bs.modal", () => { - if (this.resolve) { - this.resolve({ success: false }); - } - - if (this.$originalFocused) { - this.$originalFocused.trigger("focus"); - this.$originalFocused = null; - } - - glob.activeDialog = this.$originalDialog; - }); - - this.$noteTypeDropdown.on("click", ".dropdown-item", (e) => this.doResolve(e)); - - this.$noteTypeDropdown.on("focus", ".dropdown-item", (e) => { - this.$noteTypeDropdown.find(".dropdown-item").each((i, el) => { - $(el).toggleClass("active", el === e.target); - }); - }); - - this.$noteTypeDropdown.on("keydown", ".dropdown-item", (e) => { - if (e.key === "Enter") { - this.doResolve(e); - e.preventDefault(); - return false; - } - }); - - this.$noteTypeDropdown.parent().on("hide.bs.dropdown", (e) => { - // prevent closing dropdown by clicking outside - // TODO: Check if this actually works. - //@ts-ignore - if (e.clickEvent) { - e.preventDefault(); - } else { - this.modal.hide(); - } - }); - } - - async refresh() { - noteAutocompleteService - .initNoteAutocomplete(this.$autoComplete, { - allowCreatingNotes: false, - hideGoToSelectedNoteButton: true, - allowJumpToSearchNotes: false, - }) - } - - async chooseNoteTypeEvent({ callback }: { callback: Callback }) { - this.$originalFocused = $(":focus"); - - await this.refresh(); - - const noteTypes = await noteTypesService.getNoteTypeItems(); - - this.$noteTypeDropdown.empty(); - - for (const noteType of noteTypes) { - if (noteType.title === "----") { - this.$noteTypeDropdown.append($('