2017-10-08 00:17:10 +02:00
|
|
|
const Folder = require('lib/models/folder.js').Folder;
|
|
|
|
const ListWidget = require('tkwidgets/ListWidget.js');
|
|
|
|
|
|
|
|
class FolderListWidget extends ListWidget {
|
|
|
|
|
|
|
|
constructor() {
|
|
|
|
super();
|
|
|
|
this.selectedFolderId_ = 0;
|
|
|
|
|
2017-10-15 13:38:22 +02:00
|
|
|
this.updateIndexFromSelectedFolderId_ = false;
|
|
|
|
|
2017-10-09 20:05:01 +02:00
|
|
|
this.itemRenderer = (item) => {
|
2017-10-22 14:45:56 +02:00
|
|
|
return item.title; //+ ' ' + item.id;
|
2017-10-09 20:05:01 +02:00
|
|
|
};
|
2017-10-08 00:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
get selectedFolderId() {
|
|
|
|
return this.selectedFolderId_;
|
|
|
|
}
|
|
|
|
|
|
|
|
set selectedFolderId(v) {
|
2017-10-15 13:38:22 +02:00
|
|
|
this.updateIndexFromSelectedFolderId_ = true;
|
2017-10-08 00:17:10 +02:00
|
|
|
this.selectedFolderId_ = v;
|
2017-10-15 13:38:22 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
render() {
|
|
|
|
if (this.updateIndexFromSelectedFolderId_) {
|
|
|
|
const index = this.itemIndexByKey('id', this.selectedFolderId_);
|
|
|
|
this.currentIndex = index >= 0 ? index : 0;
|
|
|
|
this.updateIndexFromSelectedFolderId_ = false;
|
|
|
|
}
|
|
|
|
|
|
|
|
super.render();
|
2017-10-08 00:17:10 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = FolderListWidget;
|