mirror of
https://github.com/laurent22/joplin.git
synced 2024-12-27 10:32:58 +02:00
a96734f5be
This reverts commit 0b6f5581f0
.
It causes too many conflicts with pull requests.
37 lines
837 B
JavaScript
37 lines
837 B
JavaScript
const Note = require('lib/models/Note.js');
|
|
const ListWidget = require('tkwidgets/ListWidget.js');
|
|
|
|
class NoteListWidget extends ListWidget {
|
|
constructor() {
|
|
super();
|
|
this.selectedNoteId_ = 0;
|
|
|
|
this.updateIndexFromSelectedNoteId_ = false;
|
|
|
|
this.itemRenderer = note => {
|
|
let label = Note.displayTitle(note); // + ' ' + note.id;
|
|
if (note.is_todo) {
|
|
label = `[${note.todo_completed ? 'X' : ' '}] ${label}`;
|
|
}
|
|
return label;
|
|
};
|
|
}
|
|
|
|
set selectedNoteId(v) {
|
|
this.updateIndexFromSelectedNoteId_ = true;
|
|
this.selectedNoteId_ = v;
|
|
}
|
|
|
|
render() {
|
|
if (this.updateIndexFromSelectedNoteId_) {
|
|
const index = this.itemIndexByKey('id', this.selectedNoteId_);
|
|
this.currentIndex = index >= 0 ? index : 0;
|
|
this.updateIndexFromSelectedNoteId_ = false;
|
|
}
|
|
|
|
super.render();
|
|
}
|
|
}
|
|
|
|
module.exports = NoteListWidget;
|