[pve-devel] r5897 - in pve-manager/pve2/www/new: . form
svn-commits at proxmox.com
svn-commits at proxmox.com
Wed May 4 08:50:49 CEST 2011
Author: dietmar
Date: 2011-05-04 08:50:48 +0200 (Wed, 04 May 2011)
New Revision: 5897
Added:
pve-manager/pve2/www/new/form/ComboGrid.js
Modified:
pve-manager/pve2/www/new/Makefile.am
pve-manager/pve2/www/new/form/StorageSelector.js
Log:
split out ComboGrid code
Modified: pve-manager/pve2/www/new/Makefile.am
===================================================================
--- pve-manager/pve2/www/new/Makefile.am 2011-05-03 12:22:42 UTC (rev 5896)
+++ pve-manager/pve2/www/new/Makefile.am 2011-05-04 06:50:48 UTC (rev 5897)
@@ -10,6 +10,7 @@
data/UpdateStore.js \
data/ObjectStore.js \
data/ResourceStore.js \
+ form/ComboGrid.js \
form/RealmComboBox.js \
form/ViewSelector.js \
form/StorageSelector.js \
Added: pve-manager/pve2/www/new/form/ComboGrid.js
===================================================================
--- pve-manager/pve2/www/new/form/ComboGrid.js (rev 0)
+++ pve-manager/pve2/www/new/form/ComboGrid.js 2011-05-04 06:50:48 UTC (rev 5897)
@@ -0,0 +1,79 @@
+Ext.define('PVE.form.ComboGrid', {
+ extend: 'Ext.form.ComboBox',
+ requires: [
+ 'Ext.grid.Panel'
+ ],
+ alias: ['widget.PVE.form.ComboGrid'],
+
+ // copied from ComboBox
+ createPicker: function() {
+ var me = this,
+ picker,
+ menuCls = Ext.baseCSSPrefix + 'menu',
+ opts = Ext.apply({
+ selModel: {
+ mode: me.multiSelect ? 'SIMPLE' : 'SINGLE'
+ },
+ floating: true,
+ hidden: true,
+ ownerCt: me.ownerCt,
+ cls: me.el.up('.' + menuCls) ? menuCls : '',
+ store: me.store,
+ displayField: me.displayField,
+ focusOnToFront: false,
+ pageSize: me.pageSize
+ }, me.listConfig, me.defaultListConfig);
+
+ // NOTE: we simply use a grid panel
+ //picker = me.picker = Ext.create('Ext.view.BoundList', opts);
+ picker = me.picker = Ext.create('Ext.grid.Panel', opts);
+
+ // pass getNode() to the view
+ picker.getNode = function() {
+ picker.getView().getNode(arguments);
+ };
+
+ me.mon(picker, {
+ itemclick: me.onItemClick,
+ refresh: me.onListRefresh,
+ scope: me
+ });
+
+ me.mon(picker.getSelectionModel(), {
+ selectionChange: me.onListSelectionChange,
+ scope: me
+ });
+
+ return picker;
+ },
+
+ initComponent: function() {
+ var me = this;
+
+ Ext.apply(me, {
+ queryMode: 'local',
+ editable: false,
+ autoSelect: true,
+ matchFieldWidth: false
+ });
+
+ Ext.applyIf(me.listConfig, { width: 400 });
+
+ me.callParent();
+
+ // hack: autoSelect does not work
+ me.store.load({
+ callback: function(r, o, success) {
+ if (success) {
+ var def = me.getValue();
+ if (!def || !store.findRecord(me.valueField, def)) {
+ if (r[0] && r[0].data) {
+ def = r[0].data[me.valueField];
+ me.setValue(def);
+ }
+ }
+ }
+ }
+ });
+ }
+});
\ No newline at end of file
Modified: pve-manager/pve2/www/new/form/StorageSelector.js
===================================================================
--- pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-03 12:22:42 UTC (rev 5896)
+++ pve-manager/pve2/www/new/form/StorageSelector.js 2011-05-04 06:50:48 UTC (rev 5897)
@@ -1,46 +1,11 @@
Ext.define('PVE.form.StorageSelector', {
- extend: 'Ext.form.ComboBox',
+ extend: 'PVE.form.ComboGrid',
requires: [
'Ext.data.Store',
'PVE.RestProxy'
],
alias: ['widget.PVE.form.StorageSelector'],
- createPicker: function() {
- var me = this,
- picker,
- menuCls = Ext.baseCSSPrefix + 'menu',
- opts = Ext.apply({
- selModel: {
- mode: me.multiSelect ? 'SIMPLE' : 'SINGLE'
- },
- floating: true,
- hidden: true,
- ownerCt: me.ownerCt,
- cls: me.el.up('.' + menuCls) ? menuCls : '',
- store: me.store,
- displayField: me.displayField,
- focusOnToFront: false,
- pageSize: me.pageSize
- }, me.listConfig, me.defaultListConfig);
-
- //picker = me.picker = Ext.create('Ext.view.BoundList', opts);
- picker = me.picker = Ext.create('Ext.grid.Panel', opts);
-
- me.mon(picker, {
- itemclick: me.onItemClick,
- refresh: me.onListRefresh,
- scope: me
- });
-
- me.mon(picker.getSelectionModel(), {
- selectionChange: me.onListSelectionChange,
- scope: me
- });
-
- return picker;
- },
-
initComponent: function() {
var me = this;
@@ -59,22 +24,14 @@
Ext.apply(me, {
store: store,
- queryMode: 'local',
allowBlank: false,
- forceSelection: true,
- editable: false,
- typeAhead: false, // does not work wit grid
- autoSelect: false, // does not work wit grid
valueField: 'storage',
displayField: 'storage',
- matchFieldWidth: false,
listConfig: {
- width: 400,
columns: [
{
header: 'Name',
dataIndex: 'storage',
- sortable: false,
hideable: false,
flex: 1
},
@@ -100,7 +57,5 @@
});
me.callParent();
-
- store.load();
}
});
\ No newline at end of file
More information about the pve-devel
mailing list