Fixed highlighting for files in folders
While at it also adjusted highlighting so that the folder containing the currently selected file will be highlighted if the selected file is not within the current folder but in one of its sub folders.
This commit is contained in:
parent
8b4aecde35
commit
3db21f1a70
2 changed files with 14 additions and 3 deletions
|
|
@ -146,12 +146,20 @@ $(function() {
|
|||
self.highlightFilename(newValue);
|
||||
});
|
||||
|
||||
self.highlightCurrentFilename = function() {
|
||||
self.highlightFilename(self.printerState.filename());
|
||||
};
|
||||
|
||||
self.highlightFilename = function(filename) {
|
||||
if (filename == undefined) {
|
||||
self.listHelper.selectNone();
|
||||
} else {
|
||||
self.listHelper.selectItem(function(item) {
|
||||
return item.name == filename;
|
||||
if (item.type == "folder") {
|
||||
return _.startsWith(filename, OctoPrint.files.pathForElement(item) + "/");
|
||||
} else {
|
||||
return OctoPrint.files.pathForElement(item) == filename;
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
|
@ -195,6 +203,7 @@ $(function() {
|
|||
self.allItems(files);
|
||||
self.currentPath("");
|
||||
self.listHelper.addFilter("emptyFolder");
|
||||
|
||||
if (!switchToPath) {
|
||||
self.listHelper.updateItems(files);
|
||||
} else {
|
||||
|
|
@ -221,12 +230,13 @@ $(function() {
|
|||
self.totalSpace(response.total);
|
||||
}
|
||||
|
||||
self.highlightFilename(self.printerState.filename());
|
||||
self.highlightCurrentFilename();
|
||||
};
|
||||
|
||||
self.changeFolder = function(data) {
|
||||
self.currentPath(OctoPrint.files.pathForElement(data));
|
||||
self.listHelper.updateItems(data.children);
|
||||
self.highlightCurrentFilename();
|
||||
};
|
||||
|
||||
self.navigateUp = function() {
|
||||
|
|
@ -244,6 +254,7 @@ $(function() {
|
|||
self.currentPath("");
|
||||
self.listHelper.updateItems(self.allItems());
|
||||
}
|
||||
self.highlightCurrentFilename();
|
||||
};
|
||||
|
||||
self.loadFile = function(file, printAfterLoad) {
|
||||
|
|
|
|||
|
|
@ -35,7 +35,7 @@
|
|||
|
||||
<script type="text/html" id="files_template_folder">
|
||||
<div data-bind="click: $root.changeFolder">
|
||||
<div class="title"><i class="icon-folder-open"></i> <span data-bind="text: name"></span></div>
|
||||
<div class="title" data-bind="style: { 'font-weight': $root.listHelper.isSelected($data) ? 'bold' : 'normal' }"><i class="icon-folder-open"></i> <span data-bind="text: name"></span></div>
|
||||
<div class="size">{{ _('Size') }}: <span data-bind="text: formatSize(size)"></span></div>
|
||||
</div>
|
||||
</script>
|
||||
|
|
|
|||
Loading…
Reference in a new issue