client: Improve code selection in note type

This commit is contained in:
Elian Doran 2024-09-01 16:56:25 +03:00
parent 13860a3f16
commit 07170a5a39
No known key found for this signature in database

View File

@ -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 = $('<a class="dropdown-item">')
.attr("data-note-type", noteType.type)
.append('<span class="check">&check;</span> ')
.append($('<span>').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 = $('<a class="dropdown-item">')
.attr("data-note-type", noteType.type)
.append('<span class="check">&check;</span> ')
.append($('<span>').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('<div class="dropdown-divider"></div>');
$typeLink = $('<a class="dropdown-item disabled">')
.attr("data-note-type", noteType.type)
.append('<span class="check">&check;</span> ')
.append($('<strong>').text(noteType.title));
}
if (this.note.type === noteType.type) {
$typeLink.addClass("selected");
}
if (noteType.type === 'code') {
this.$noteTypeDropdown.append('<div class="dropdown-divider"></div>');
}
this.$noteTypeDropdown.append($typeLink);
}