[pve-devel] [PATCH manager 2/5] ui: tags: make sorting more natural
Dominik Csapak
d.csapak at proxmox.com
Thu Nov 17 15:56:20 CET 2022
by sorting the lower cased variants, and only if they are identical
sort the original values with 'localeCompare'
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/Utils.js | 6 +++++-
www/manager6/form/TagEdit.js | 4 +++-
2 files changed, 8 insertions(+), 2 deletions(-)
diff --git a/www/manager6/Utils.js b/www/manager6/Utils.js
index e4b6207c6..9ceda0a97 100644
--- a/www/manager6/Utils.js
+++ b/www/manager6/Utils.js
@@ -1941,7 +1941,11 @@ Ext.define('PVE.Utils', {
if (tagstext) {
let tags = (tagstext.split(/[,; ]/) || []).filter(t => !!t);
if (PVE.Utils.shouldSortTags()) {
- tags = tags.sort();
+ tags = tags.sort((a,b) => {
+ let alc = a.toLowerCase();
+ let blc = b.toLowerCase();
+ return alc < blc ? -1 : blc < alc ? 1 : a.localeCompare(b);
+ });
}
text += ' ';
tags.forEach((tag) => {
diff --git a/www/manager6/form/TagEdit.js b/www/manager6/form/TagEdit.js
index 4e3fec384..9015bd653 100644
--- a/www/manager6/form/TagEdit.js
+++ b/www/manager6/form/TagEdit.js
@@ -181,7 +181,9 @@ Ext.define('PVE.panel.TagEditContainer', {
if (tagField.xtype !== 'pveTag') {
return true;
}
- return tagField.tag >= tag;
+ let a = tagField.tag.toLowerCase()
+ let b = tag.toLowerCase();
+ return a > b ? true : a < b ? false : tagField.tag.localeCompare(tag) > 0;
}, 1);
}
let tagField = view.insert(index, {
--
2.30.2
More information about the pve-devel
mailing list