From b75d0830355f55607baab5e1b30ceab438b6f6ac Mon Sep 17 00:00:00 2001 From: tomasz1986 Date: Wed, 29 Sep 2021 15:05:01 +0900 Subject: [PATCH] gui: Use case insensitive sort with folders on top in Restore Versions (#7980) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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 --- gui/default/syncthing/core/syncthingController.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/gui/default/syncthing/core/syncthingController.js b/gui/default/syncthing/core/syncthingController.js index 8bc487264..21293f08e 100755 --- a/gui/default/syncthing/core/syncthingController.js +++ b/gui/default/syncthing/core/syncthingController.js @@ -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;