[pve-devel] [PATCH manager 5/5] form/FileSelector: move to declarative style

Thomas Lamprecht t.lamprecht at proxmox.com
Wed Feb 14 13:34:48 CET 2018


Signed-off-by: Thomas Lamprecht <t.lamprecht at proxmox.com>
---
 www/manager6/form/FileSelector.js | 75 +++++++++++++++++++--------------------
 1 file changed, 36 insertions(+), 39 deletions(-)

diff --git a/www/manager6/form/FileSelector.js b/www/manager6/form/FileSelector.js
index b07f6bbc..9afbf821 100644
--- a/www/manager6/form/FileSelector.js
+++ b/www/manager6/form/FileSelector.js
@@ -6,6 +6,15 @@ Ext.define('PVE.form.FileSelector', {
     anyMatch: true,
     forceSelection: true,
 
+    listeners: {
+	afterrender: function() {
+	    var me = this;
+	    if (!me.disabled) {
+		me.setStorage(me.storage, me.nodename);
+	    }
+	}
+    },
+
     setStorage: function(storage, nodename) {
 	var me = this;
 
@@ -38,47 +47,35 @@ Ext.define('PVE.form.FileSelector', {
 	me.store.load();
     },
 
-    initComponent: function() {
-	var me = this;
+    store: {
+	model: 'pve-storage-content'
+    },
 
-	var store = Ext.create('Ext.data.Store', {
-	    model: 'pve-storage-content'
-	});
+    allowBlank: false,
+    autoSelect: false,
+    valueField: 'volid',
+    displayField: 'text',
 
-	Ext.apply(me, {
-	    store: store,
-	    allowBlank: false,
-	    autoSelect: false,
-	    valueField: 'volid',
-	    displayField: 'text',
-            listConfig: {
-		width: 600,
-		columns: [
-		    {
-			header: gettext('Name'),
-			dataIndex: 'text',
-			hideable: false,
-			flex: 1
-		    },
-		    {
-			header: gettext('Format'),
-			width: 60,
-			dataIndex: 'format'
-		    },
-		    {
-			header: gettext('Size'),
-			width: 100,
-			dataIndex: 'size',
-			renderer: Proxmox.Utils.format_size
-		    }
-		]
+    listConfig: {
+	width: 600,
+	columns: [
+	    {
+		header: gettext('Name'),
+		dataIndex: 'text',
+		hideable: false,
+		flex: 1
+	    },
+	    {
+		header: gettext('Format'),
+		width: 60,
+		dataIndex: 'format'
+	    },
+	    {
+		header: gettext('Size'),
+		width: 100,
+		dataIndex: 'size',
+		renderer: Proxmox.Utils.format_size
 	    }
-	});
-
-        me.callParent();
-
-	if (!me.disabled) {
-	    me.setStorage(me.storage, me.nodename);
-	}
+	]
     }
 });
-- 
2.14.2





More information about the pve-devel mailing list