From: Dominik Csapak <d.csapak@proxmox.com>
To: pve-devel@lists.proxmox.com
Subject: [pve-devel] [PATCH manager] ui: fix datacenter tags options inputs
Date: Fri, 18 Nov 2022 09:09:37 +0100 [thread overview]
Message-ID: <20221118080937.407056-1-d.csapak@proxmox.com> (raw)
* dont allow blank for tree shape
* allow completely removing registered tags and user-tag-access properties
* correctly check validity for the listfield
* use correct gettexts
* don't inject empty field in the listfield when setting an empty string
Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
---
www/manager6/dc/OptionView.js | 9 +++++----
www/manager6/dc/RegisteredTagsEdit.js | 18 +++++++++++-------
www/manager6/dc/UserTagAccessEdit.js | 2 +-
www/manager6/form/ListField.js | 8 ++++++--
4 files changed, 23 insertions(+), 14 deletions(-)
diff --git a/www/manager6/dc/OptionView.js b/www/manager6/dc/OptionView.js
index 7f77ea758..5cb5b0b6f 100644
--- a/www/manager6/dc/OptionView.js
+++ b/www/manager6/dc/OptionView.js
@@ -384,6 +384,7 @@ Ext.define('PVE.dc.OptionView', {
fieldLabel: gettext('Tree Shape'),
valueField: 'value',
displayField: 'display',
+ allowBlank: false,
listConfig: {
columns: [
{
@@ -448,12 +449,12 @@ Ext.define('PVE.dc.OptionView', {
return Ext.String.format(gettext('Mode: {0}'), 'free');
}
let mode = value?.['user-allow'] ?? 'free';
- let list = value?.['user-allow-list'].join(',');
- let modeTxt = Ext.String.format(gettext('Mode {0}'), mode);
+ let list = value?.['user-allow-list']?.join(',') ?? '';
+ let modeTxt = Ext.String.format(gettext('Mode: {0}'), mode);
let overrides = PVE.Utils.tagOverrides;
let tags = PVE.Utils.renderTags(list, overrides);
-
- return `${modeTxt}, ${gettext('Pre-defined:')} ${tags}`;
+ let listTxt = tags !== '' ? `, ${gettext('Pre-defiend:')} ${tags}` : '';
+ return `${modeTxt}${listTxt}`;
},
header: gettext('User Tag Access'),
editor: {
diff --git a/www/manager6/dc/RegisteredTagsEdit.js b/www/manager6/dc/RegisteredTagsEdit.js
index 75b4f9ba3..b46326ae8 100644
--- a/www/manager6/dc/RegisteredTagsEdit.js
+++ b/www/manager6/dc/RegisteredTagsEdit.js
@@ -36,25 +36,29 @@ Ext.define('PVE.dc.RegisteredTagsEdit', {
setValues: function(values) {
let allowed_tags = values?.['user-tag-access']?.['user-allow-list'] ?? [];
this.up('pveRegisteredTagEdit').allowed_tags = allowed_tags;
-
- let tags = values?.['registered-tags'] ?? '';
+ let tags = values?.['registered-tags'];
return Proxmox.panel.InputPanel.prototype.setValues.call(this, { tags });
},
onGetValues: function(values) {
- return {
- 'registered-tags': values,
- };
+ if (!values.tags) {
+ return {
+ 'delete': 'registered-tags',
+ };
+ } else {
+ return {
+ 'registered-tags': values.tags,
+ };
+ }
},
items: [
{
name: 'tags',
xtype: 'pveListField',
- emptyText: gettext('No Tags defined'),
- fieldTitle: gettext('Tag'),
maskRe: PVE.Utils.tagCharRegex,
gridConfig: {
height: 200,
scrollable: true,
+ emptyText: gettext('No Tags defined'),
},
listeners: {
change: 'tagChange',
diff --git a/www/manager6/dc/UserTagAccessEdit.js b/www/manager6/dc/UserTagAccessEdit.js
index f22ac9b3d..61c38c074 100644
--- a/www/manager6/dc/UserTagAccessEdit.js
+++ b/www/manager6/dc/UserTagAccessEdit.js
@@ -40,7 +40,7 @@ Ext.define('PVE.dc.UserTagAccessEdit', {
},
onGetValues: function(values) {
if (values === undefined || Object.keys(values).length === 0) {
- return { 'delete': name };
+ return { 'delete': 'user-tag-access' };
}
return {
'user-tag-access': PVE.Parser.printPropertyString(values),
diff --git a/www/manager6/form/ListField.js b/www/manager6/form/ListField.js
index 77e9ebfca..61e37f7e5 100644
--- a/www/manager6/form/ListField.js
+++ b/www/manager6/form/ListField.js
@@ -22,7 +22,8 @@ Ext.define('PVE.form.ListField', {
setValue: function(list) {
let me = this;
- list = Ext.isArray(list) ? list : (list ?? '').split(';');
+ list = Ext.isArray(list) ? list : (list ?? '').split(';').filter(t => t !== '');
+
let store = me.lookup('grid').getStore();
if (list.length > 0) {
store.setData(list.map(item => ({ item })));
@@ -99,6 +100,7 @@ Ext.define('PVE.form.ListField', {
grid.getStore().remove(record);
view.checkChange();
+ view.validate();
},
itemChange: function(field, newValue) {
@@ -108,7 +110,9 @@ Ext.define('PVE.form.ListField', {
}
let column = field.getWidgetColumn();
rec.set(column.dataIndex, newValue);
- field.up('pveListField').checkChange();
+ let list = field.up('pveListField');
+ list.checkChange();
+ list.validate();
},
control: {
--
2.30.2
next reply other threads:[~2022-11-18 8:10 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-11-18 8:09 Dominik Csapak [this message]
2022-11-18 12:10 ` [pve-devel] applied: " Thomas Lamprecht
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20221118080937.407056-1-d.csapak@proxmox.com \
--to=d.csapak@proxmox.com \
--cc=pve-devel@lists.proxmox.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox