[pbs-devel] [PATCH v3 widget-toolkit] form: display-edit: support emptyText

Fiona Ebner f.ebner at proxmox.com
Tue Nov 26 17:29:15 CET 2024


To access the edit field, its xtype is now tracked.

First user is intended to be the path field for datastores where the
emptyText should dynamically be for a relative or absolute path.

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---

Changes in v3:
* fix typo in variable name

Changes in v2:
* avoid tracking emptyText state twice, pass directly to edit field.

 src/form/DisplayEdit.js | 14 ++++++++++++++
 1 file changed, 14 insertions(+)

diff --git a/src/form/DisplayEdit.js b/src/form/DisplayEdit.js
index fe1b83b..01d6a05 100644
--- a/src/form/DisplayEdit.js
+++ b/src/form/DisplayEdit.js
@@ -12,6 +12,9 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 
     displayType: 'displayfield',
 
+    // internal only, use editConfig to set the xtype
+    _editType: 'textfield',
+
     editConfig: {},
     editable: false,
     setEditable: function(editable) {
@@ -41,6 +44,15 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 	vm.get('value');
     },
 
+    setEmptyText: function(emptyText) {
+	let me = this;
+	me.down(me._editType).setEmptyText(emptyText);
+    },
+    getEmptyText: function() {
+	let me = this;
+	return me.down(me._editType).getEmptyText();
+    },
+
     layout: 'fit',
     defaults: {
 	hideLabel: true,
@@ -64,6 +76,8 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 	});
 	Ext.applyIf(editConfig, displayConfig);
 
+	me._editType = editConfig.xtype;
+
 	if (me.initialConfig && me.initialConfig.displayConfig) {
 	    Ext.applyIf(displayConfig, me.initialConfig.displayConfig);
 	    delete displayConfig.displayConfig;
-- 
2.39.5





More information about the pbs-devel mailing list