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

Fiona Ebner f.ebner at proxmox.com
Tue Nov 26 16:12:58 CET 2024


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

Signed-off-by: Fiona Ebner <f.ebner at proxmox.com>
---
 src/form/DisplayEdit.js | 16 ++++++++++++++++
 1 file changed, 16 insertions(+)

diff --git a/src/form/DisplayEdit.js b/src/form/DisplayEdit.js
index fe1b83b..3f6a9bb 100644
--- a/src/form/DisplayEdit.js
+++ b/src/form/DisplayEdit.js
@@ -7,6 +7,7 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 	data: {
 	    editable: false,
 	    value: undefined,
+	    emptyText: undefined,
 	},
     },
 
@@ -41,6 +42,19 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 	vm.get('value');
     },
 
+    setEmptyText: function(emptyText) {
+	let me = this;
+	let vm = me.getViewModel();
+
+	me.emptyText = emptyText;
+	vm.set('emptyText', emptyText);
+    },
+    getEmptyText: function() {
+	let me = this;
+	let vm = me.getViewModel();
+	return vm.get('emptyText');
+    },
+
     layout: 'fit',
     defaults: {
 	hideLabel: true,
@@ -77,11 +91,13 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
 	    hidden: '{editable}',
 	    disabled: '{editable}',
 	    value: '{value}',
+	    // doesn't have a setEmptyText() method, so don't bind that
 	});
 	Ext.applyIf(editConfig.bind, {
 	    hidden: '{!editable}',
 	    disabled: '{!editable}',
 	    value: '{value}',
+	    emptyText: '{emptyText}',
 	});
 
 	// avoid glitch, start off correct even before viewmodel fixes it
-- 
2.39.5





More information about the pbs-devel mailing list