mirror of
https://git.proxmox.com/git/pve-manager
synced 2025-05-13 11:37:06 +00:00

Besides fitting more with the declarative style of ExtJS, this has the interesting side effect of allowing comboboxes to work with ExtJS6
51 lines
1.2 KiB
JavaScript
51 lines
1.2 KiB
JavaScript
/* Key-Value ComboBox
|
|
*
|
|
* config properties:
|
|
* comboItems: an array of Key - Value pairs
|
|
* deleteEmpty: if set to true (default), an empty value received from the
|
|
* comboBox will reset the property to its default value
|
|
*/
|
|
Ext.define('PVE.form.KVComboBox', {
|
|
extend: 'Ext.form.field.ComboBox',
|
|
alias: 'widget.pveKVComboBox',
|
|
|
|
deleteEmpty: true,
|
|
comboItems: undefined,
|
|
displayField: 'value',
|
|
valueField: 'key',
|
|
queryMode: 'local',
|
|
|
|
// overide framework function to implement deleteEmpty behaviour
|
|
getSubmitData: function() {
|
|
var me = this,
|
|
data = null,
|
|
val;
|
|
if (!me.disabled && me.submitValue) {
|
|
val = me.getSubmitValue();
|
|
if (val !== null && val !== '') {
|
|
data = {};
|
|
data[me.getName()] = val;
|
|
} else if (me.deleteEmpty) {
|
|
data = {};
|
|
data['delete'] = me.getName();
|
|
}
|
|
}
|
|
return data;
|
|
},
|
|
|
|
initComponent: function() {
|
|
var me = this;
|
|
|
|
me.store = Ext.create('Ext.data.ArrayStore', {
|
|
model: 'KeyValue',
|
|
data : me.comboItems,
|
|
});
|
|
|
|
if (me.initialConfig.editable === undefined) {
|
|
me.editable = false;
|
|
}
|
|
|
|
me.callParent();
|
|
}
|
|
});
|