ext6migrate: set valueField as a class property

Also moves to full declarative style for
IPProtocolSelector, saves 11 lines of of boilerplate code
(works when the store is local and not pulled over the API)
This commit is contained in:
Emmanuel Kasper 2016-02-15 09:22:59 +01:00 committed by Dietmar Maurer
parent 48cf541624
commit 82a7467bc4
2 changed files with 48 additions and 60 deletions

View File

@ -1,11 +1,34 @@
Ext.define('PVE.form.IPProtocolSelector', {
extend: 'PVE.form.ComboGrid',
alias: ['widget.pveIPProtocolSelector'],
initComponent: function() {
var me = this;
var store = Ext.create('Ext.data.Store', {
valueField: 'p',
displayField: 'p',
listConfig: {
columns: [
{
header: gettext('Protocol'),
dataIndex: 'p',
hideable: false,
sortable: false,
width: 100
},
{
header: gettext('Number'),
dataIndex: 'n',
hideable: false,
sortable: false,
width: 50
},
{
header: gettext('Description'),
dataIndex: 'd',
hideable: false,
sortable: false,
flex: 1
}
]
},
store: {
fields: [ 'p', 'd', 'n'],
data: [
{ p: 'tcp', n: 6, d: 'Transmission Control Protocol' },
@ -60,39 +83,5 @@ Ext.define('PVE.form.IPProtocolSelector', {
{ p: 'wesp', n: 141, d: 'Wrapped Encapsulating Security Payload' },
{ p: 'rohc', n: 142, d: 'Robust Header Compression' }
]
});
Ext.apply(me, {
store: store,
valueField: 'p',
displayField: 'p',
listConfig: {
columns: [
{
header: gettext('Protocol'),
dataIndex: 'p',
hideable: false,
sortable: false,
width: 100
},
{
header: gettext('Number'),
dataIndex: 'n',
hideable: false,
sortable: false,
width: 50
},
{
header: gettext('Description'),
dataIndex: 'd',
hideable: false,
sortable: false,
flex: 1
}
]
}
});
me.callParent();
}
}
});

View File

@ -1,7 +1,25 @@
Ext.define('PVE.form.FWMacroSelector', {
extend: 'PVE.form.ComboGrid',
alias: 'widget.pveFWMacroSelector',
allowBlank: true,
autoSelect: false,
valueField: 'macro',
displayField: 'macro',
listConfig: {
columns: [
{
header: gettext('Macro'),
dataIndex: 'macro',
hideable: false,
width: 100
},
{
header: gettext('Description'),
flex: 1,
dataIndex: 'descr'
}
]
},
initComponent: function() {
var me = this;
@ -21,25 +39,6 @@ Ext.define('PVE.form.FWMacroSelector', {
Ext.apply(me, {
store: store,
allowBlank: true,
autoSelect: false,
valueField: 'macro',
displayField: 'macro',
listConfig: {
columns: [
{
header: gettext('Macro'),
dataIndex: 'macro',
hideable: false,
width: 100
},
{
header: gettext('Description'),
flex: 1,
dataIndex: 'descr'
}
]
}
});
me.callParent();