On 12/11/2017 04:26 PM, Thomas Lamprecht wrote:
Signed-off-by: Thomas Lamprecht <t.lampre...@proxmox.com>
---
  www/manager6/form/RealmComboBox.js | 53 +++++++++++++++++++-------------------
  1 file changed, 26 insertions(+), 27 deletions(-)

diff --git a/www/manager6/form/RealmComboBox.js 
b/www/manager6/form/RealmComboBox.js
index 8d0c71a8..39c47329 100644
--- a/www/manager6/form/RealmComboBox.js
+++ b/www/manager6/form/RealmComboBox.js
@@ -1,7 +1,30 @@
+/*global Proxmox*/
  Ext.define('PVE.form.RealmComboBox', {
      extend: 'Ext.form.field.ComboBox',
      alias: ['widget.pveRealmComboBox'],
+ controller: {
+       xclass: 'Ext.app.ViewController',
+
+       init: function(view) {
+           view.store.on('load', this.onLoad, view);
+       },
+
+       onLoad: function(store, records, success) {
+           var me = this;
+           var val = me.getValue();
+           if (!val || !me.store.findRecord('realm', val)) {
+               var def = 'pam';
+               Ext.each(records, function(rec) {
+                   if (rec.data && rec.data['default']) {
+                       def = rec.data.realm;
+                   }
+               });
+               me.setValue(def);
+           }
+       }

here the success check is missing, should not break anything, but i would prefer to leave it in

+    },
+
      fieldLabel: gettext('Realm'),
      name: 'realm',
      queryMode: 'local',
@@ -32,32 +55,8 @@ Ext.define('PVE.form.RealmComboBox', {
        return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
      },
- initComponent: function() {
-       var me = this;
-
-       me.store = Ext.create('Ext.data.Store', {
-           model: 'pve-domains'
-       });
-
-       me.callParent();
-
-       me.store.load({
-           callback: function(r, o, success) {
-               if (success) {
-                   var def = me.getValue();
-                   if (!def || !me.store.findRecord('realm', def)) {
-                       def = 'pam';
-                       Ext.each(r, function(record) {
-                           if (record.data && record.data["default"]) {
-                               def = record.data.realm;
-                           }
-                       });
-                   }
-                   if (def) {
-                       me.setValue(def);
-                   }
-               }
-           }
-       });
+    store: {
+       model: 'pve-domains',
+       autoLoad: true
      }
  });



_______________________________________________
pve-devel mailing list
pve-devel@pve.proxmox.com
https://pve.proxmox.com/cgi-bin/mailman/listinfo/pve-devel

Reply via email to