1
0
mirror of https://github.com/laurent22/joplin.git synced 2024-12-18 09:35:20 +02:00
joplin/CliClient/app/gui/NoteListWidget.js
2017-10-09 18:05:01 +00:00

27 lines
573 B
JavaScript

const Note = require('lib/models/note.js').Note;
const ListWidget = require('tkwidgets/ListWidget.js');
class NoteListWidget extends ListWidget {
constructor() {
super();
this.selectedNoteId_ = 0;
this.itemRenderer = (item) => {
return item.title;
};
}
get selectedNoteId() {
return this.selectedNoteId_;
}
set selectedNoteId(v) {
if (v === this.selectedNoteId_) return;
this.selectedNoteId_ = v;
const index = this.itemIndexByKey('id', this.selectedNoteId_);
this.currentIndex = index >= 0 ? index : 0;
}
}
module.exports = NoteListWidget;