Fix file listing and download for admin shell

`node.parents` is not returning the parent nodes in a fixed order. Hence, we cannot use it but must travers the tree ourselves.
This commit is contained in:
Sebastian Serth
2023-10-29 22:10:44 +01:00
parent 6ba567a903
commit 442337a22b

View File

@ -148,7 +148,7 @@ $(document).on('turbolinks:load', function () {
} }
// We build the path to the file by concatenating the paths of all parent nodes. // We build the path to the file by concatenating the paths of all parent nodes.
let file_path = node.parents.reverse().map(function (id) { let file_path = getParents(jstree, node.parent).map(function (id) {
return jstree.get_text(id); return jstree.get_text(id);
}).filter(function (text) { }).filter(function (text) {
return text !== false; return text !== false;
@ -157,6 +157,15 @@ $(document).on('turbolinks:load', function () {
return `${node.parent !== '#' ? '/' : ''}${file_path}${node.original.path}`; return `${node.parent !== '#' ? '/' : ''}${file_path}${node.original.path}`;
} }
const getParents = function (jstree, node_id) {
debugger;
if (node_id === '#') {
return ['#'];
}
return getParents(jstree, jstree.get_parent(node_id)).concat([node_id]);
}
const shell = $('#shell'); const shell = $('#shell');
if (!shell.isPresent()) { if (!shell.isPresent()) {