[pve-devel] [PATCH manager 3/5] ui: tags: hide already set tags in dropdown
Dominik Csapak
d.csapak at proxmox.com
Thu Nov 17 15:56:21 CET 2022
on every change, collect all tags and update the filter of all tag
fields
Signed-off-by: Dominik Csapak <d.csapak at proxmox.com>
---
www/manager6/form/Tag.js | 2 +-
www/manager6/form/TagEdit.js | 18 ++++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/www/manager6/form/Tag.js b/www/manager6/form/Tag.js
index 9da0db951..8d003ca97 100644
--- a/www/manager6/form/Tag.js
+++ b/www/manager6/form/Tag.js
@@ -76,7 +76,7 @@ Ext.define('Proxmox.form.Tag', {
});
}
me.picker.getStore()?.clearFilter();
- let taglist = PVE.Utils.tagList.map(v => ({ tag: v }));
+ let taglist = PVE.Utils.tagList.filter(v => !me.filter.includes(v)).map(v => ({ tag: v }));
if (taglist.length < 1) {
return;
}
diff --git a/www/manager6/form/TagEdit.js b/www/manager6/form/TagEdit.js
index 9015bd653..3806bbdf3 100644
--- a/www/manager6/form/TagEdit.js
+++ b/www/manager6/form/TagEdit.js
@@ -27,6 +27,7 @@ Ext.define('PVE.panel.TagEditContainer', {
newtags.forEach((tag) => {
me.addTag(tag);
});
+ me.updateFilter();
view.suspendLayout = false;
view.updateLayout();
if (!force) {
@@ -168,6 +169,19 @@ Ext.define('PVE.panel.TagEditContainer', {
me.getView().updateLayout();
},
+ updateFilter: function() {
+ let me = this;
+ let tags = [];
+ me.forEachTag(cmp => {
+ if (cmp.tag) {
+ tags.push(cmp.tag);
+ }
+ });
+ me.forEachTag(cmp => {
+ cmp.updateFilter(tags);
+ });
+ },
+
addTag: function(tag, isNew) {
let me = this;
let view = me.getView();
@@ -191,6 +205,9 @@ Ext.define('PVE.panel.TagEditContainer', {
tag,
mode: vm.get('editMode') ? 'editable' : 'normal',
listeners: {
+ change: (field, newTag) => {
+ me.updateFilter();
+ },
destroy: function() {
vm.set('tagCount', vm.get('tagCount') - 1);
},
@@ -198,6 +215,7 @@ Ext.define('PVE.panel.TagEditContainer', {
});
if (isNew) {
+ me.updateFilter();
tagField.selectText();
}
--
2.30.2
More information about the pve-devel
mailing list