gui: Use case insensitive sort with folders on top in Restore Versions (#7980)

Currently, the default sorting of the file list in the Restore Versions
modal in both case sensitive, and it also does not distinguish between
files and folders. With this change, which uses a slightly modified code
from the fancytree itself (with added folder prioritisation), the sort
becomes case insensitive and also always places folders on top. This is
to make it behave more similar to what file managers do in the commonly
used operating systems (including popular Linux desktop environments).

Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com>
This commit is contained in:
tomasz1986
2021-09-29 08:05:01 +02:00
committed by GitHub
parent b0460079c1
commit b75d083035
@@ -2420,6 +2420,14 @@ angular.module('syncthing.core')
debugLevel: 2,
source: buildTree($scope.restoreVersions.versions),
renderColumns: function (event, data) {
// Case insensitive sort with folders on top.
var cmp = function(a, b) {
var x = (a.isFolder() ? "0" : "1") + a.title.toLowerCase(),
y = (b.isFolder() ? "0" : "1") + b.title.toLowerCase();
return x === y ? 0 : x > y ? 1 : -1;
};
data.tree.getRootNode().sortChildren(cmp, true);
var node = data.node,
$tdList = $(node.tr).find(">td"),
template;