Skip to content

Commit

Permalink
client: Improve code selection in note type
Browse files Browse the repository at this point in the history
  • Loading branch information
eliandoran committed Sep 1, 2024
1 parent 13860a3 commit 07170a5
Showing 1 changed file with 22 additions and 15 deletions.
37 changes: 22 additions & 15 deletions src/public/app/widgets/note_type.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);

this.save(noteType.type, noteType.mime);
});

let $typeLink;

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);
}

Expand Down

0 comments on commit 07170a5

Please sign in to comment.