Browse Source

WebUI: Fix incorrect subcategory sorting

PR #19833.
Closes #19756.
adaptive-webui-private-19844
Bartu Özen 1 year ago committed by GitHub
parent
commit
5db2c2c2be
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 16
      src/webui/www/private/scripts/client.js

16
src/webui/www/private/scripts/client.js

@ -488,7 +488,21 @@ window.addEvent('load', function() { @@ -488,7 +488,21 @@ window.addEvent('load', function() {
Object.each(category_list, function(category) {
sortedCategories.push(category.name);
});
sortedCategories.sort();
sortedCategories.sort(function(category1, category2) {
for (let i = 0; i < Math.min(category1.length, category2.length); ++i) {
if (category1[i] === "/" && category2[i] !== "/") {
return -1;
}
else if (category1[i] !== "/" && category2[i] === "/") {
return 1;
}
else if (category1[i] !== category2[i]) {
return category1[i].localeCompare(category2[i]);
}
}
return category1.length - category2.length;
});
for (let i = 0; i < sortedCategories.length; ++i) {
const categoryName = sortedCategories[i];

Loading…
Cancel
Save