From 07170a5a3956b012065d1a8cfc0f852e2f3edc33 Mon Sep 17 00:00:00 2001 From: Elian Doran Date: Sun, 1 Sep 2024 16:56:25 +0300 Subject: [PATCH] client: Improve code selection in note type --- src/public/app/widgets/note_type.js | 33 +++++++++++++++++------------ 1 file changed, 20 insertions(+), 13 deletions(-) diff --git a/src/public/app/widgets/note_type.js b/src/public/app/widgets/note_type.js index b26977ead..66e699eff 100644 --- a/src/public/app/widgets/note_type.js +++ b/src/public/app/widgets/note_type.js @@ -70,25 +70,32 @@ export default class NoteTypeWidget extends NoteContextAwareWidget { this.$noteTypeDropdown.empty(); for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) { - const $typeLink = $('') - .attr("data-note-type", noteType.type) - .append(' ') - .append($('').text(noteType.title)) - .on('click', e => { - const type = $typeLink.attr('data-note-type'); - const noteType = NOTE_TYPES.find(nt => nt.type === type); + let $typeLink; - this.save(noteType.type, noteType.mime); - }); + if (noteType.type !== "code") { + $typeLink = $('') + .attr("data-note-type", noteType.type) + .append(' ') + .append($('').text(noteType.title)) + .on('click', e => { + const type = $typeLink.attr('data-note-type'); + const noteType = NOTE_TYPES.find(nt => nt.type === type); + this.save(noteType.type, noteType.mime); + }); + } else { + this.$noteTypeDropdown + .append(''); + $typeLink = $('') + .attr("data-note-type", noteType.type) + .append(' ') + .append($('').text(noteType.title)); + } + if (this.note.type === noteType.type) { $typeLink.addClass("selected"); } - if (noteType.type === 'code') { - this.$noteTypeDropdown.append(''); - } - this.$noteTypeDropdown.append($typeLink); }