mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-07-20 10:11:54 +00:00

When clicking the toolbar of the ComboGrid, the combobox loses focus, and instantly hides the picker. To prevent that, we keep track of the mousedown event on the toolbar (which happily comes before the focusLeave event), and prevent the focusLeave propagation in that case. Then on mouseup, we focus the combobox again, so that the nexct focusLeave can trigger again. Signed-off-by: Dominik Csapak <d.csapak@proxmox.com>
88 lines
1.9 KiB
JavaScript
88 lines
1.9 KiB
JavaScript
Ext.define('PVE.form.ComboBoxSetStoreNode', {
|
|
extend: 'Proxmox.form.ComboGrid',
|
|
config: {
|
|
apiBaseUrl: '/api2/json/nodes/',
|
|
apiSuffix: '',
|
|
},
|
|
|
|
showNodeSelector: false,
|
|
|
|
setNodeName: function(value) {
|
|
let me = this;
|
|
value ||= Proxmox.NodeName;
|
|
|
|
me.getStore().getProxy().setUrl(`${me.apiBaseUrl}${value}${me.apiSuffix}`);
|
|
me.clearValue();
|
|
},
|
|
|
|
nodeChange: function(_field, value) {
|
|
let me = this;
|
|
// disable autoSelect if there is already a selection or we have the picker open
|
|
if (me.getValue() || me.isExpanded) {
|
|
let autoSelect = me.autoSelect;
|
|
me.autoSelect = false;
|
|
me.store.on('afterload', function() {
|
|
me.autoSelect = autoSelect;
|
|
}, { single: true });
|
|
}
|
|
me.setNodeName(value);
|
|
me.fireEvent('nodechanged', value);
|
|
},
|
|
|
|
tbarMouseDown: function() {
|
|
this.mousePressed = true;
|
|
},
|
|
|
|
tbarMouseUp: function() {
|
|
let me = this;
|
|
delete this.mousePressed;
|
|
if (me.focusLeft) {
|
|
me.focus();
|
|
delete me.focusLeft;
|
|
}
|
|
},
|
|
|
|
// conditionally prevent the focusLeave handler to continue, preventing collapsing of the picker
|
|
onFocusLeave: function() {
|
|
let me = this;
|
|
me.focusLeft = true;
|
|
if (!me.mousePressed) {
|
|
me.callParent(arguments);
|
|
}
|
|
|
|
return undefined;
|
|
},
|
|
|
|
initComponent: function() {
|
|
let me = this;
|
|
|
|
if (me.showNodeSelector && PVE.data.ResourceStore.getNodes().length > 1) {
|
|
me.errorHeight = 140;
|
|
Ext.apply(me.listConfig ?? {}, {
|
|
tbar: {
|
|
xtype: 'toolbar',
|
|
listeners: {
|
|
mousedown: me.tbarMouseDown,
|
|
mouseup: me.tbarMouseUp,
|
|
element: 'el',
|
|
scope: me,
|
|
},
|
|
items: [
|
|
{
|
|
xtype: "pveStorageScanNodeSelector",
|
|
autoSelect: false,
|
|
fieldLabel: gettext('Node to scan'),
|
|
listeners: {
|
|
change: (field, value) => me.nodeChange(field, value),
|
|
},
|
|
},
|
|
],
|
|
},
|
|
emptyText: me.listConfig?.emptyText ?? gettext('Nothing found'),
|
|
});
|
|
}
|
|
|
|
me.callParent();
|
|
},
|
|
});
|