render note type dropdown lazily

This commit is contained in:
zadam 2019-08-25 23:09:22 +02:00
parent 8e4e0bd543
commit 02ab59c9e0
2 changed files with 7 additions and 3 deletions

View file

@ -60,6 +60,8 @@ class NoteTypeContext {
constructor(ctx) {
this.ctx = ctx;
ctx.$tabContent.find('.note-type').on('show.bs.dropdown', () => this.renderDropdown());
this.$noteTypeDropdown = ctx.$tabContent.find(".note-type-dropdown");
this.$noteTypeButton = ctx.$tabContent.find(".note-type-button");
this.$noteTypeDesc = ctx.$tabContent.find(".note-type-desc");
@ -71,9 +73,11 @@ class NoteTypeContext {
this.$noteTypeButton.prop("disabled",
() => ["file", "image", "search"].includes(this.ctx.note.type));
this.$noteTypeDropdown.empty();
this.$noteTypeDesc.text(this.findTypeTitle(this.ctx.note.type));
}
renderDropdown() {
this.$noteTypeDropdown.empty();
for (const noteType of NOTE_TYPES.filter(nt => nt.selectable)) {
const $typeLink = $('<a class="dropdown-item">')

View file

@ -37,7 +37,7 @@
&nbsp; &nbsp;
<div class="note-type-wrapper" style="display: flex;">
<div style="display: flex;">
<div class="dropdown note-type">
<button type="button" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false" class="btn btn-sm dropdown-toggle note-type-button">
Type: <span class="note-type-desc"></span>