display-edit field: add emptyText getter and setter to support data-bind

To access the underlying fields a reference to them is now explicitly
saved after component initialisation.

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@proxmox.com>
 [ TL: switch over from saving the xtype to query in the getter or
   setter to directly savign a reference to the underlying fields. ]
Signed-off-by: Thomas Lamprecht <t.lamprecht@proxmox.com>
This commit is contained in:
Fiona Ebner 2024-11-26 17:29:15 +01:00 committed by Thomas Lamprecht
parent c806b73ff7
commit ac10db95ef

View File

@ -41,6 +41,15 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
vm.get('value'); vm.get('value');
}, },
setEmptyText: function(emptyText) {
let me = this;
me.editField.setEmptyText(emptyText);
},
getEmptyText: function() {
let me = this;
return me.editField.getEmptyText();
},
layout: 'fit', layout: 'fit',
defaults: { defaults: {
hideLabel: true, hideLabel: true,
@ -99,6 +108,11 @@ Ext.define('Proxmox.form.field.DisplayEdit', {
me.callParent(); me.callParent();
// save a reference to make it easier when one needs to operate on the underlying fields,
// like when creating a passthrough getter/setter to allow easy data-binding.
me.editField = me.down(editConfig.xtype);
me.displayField = me.down(displayConfig.xtype);
me.getViewModel().set('editable', me.editable); me.getViewModel().set('editable', me.editable);
}, },