]>
Commit | Line | Data |
---|---|---|
0391dee1 DC |
1 | Ext.define('Proxmox.form.RealmComboBox', { |
2 | extend: 'Ext.form.field.ComboBox', | |
3 | alias: 'widget.pmxRealmComboBox', | |
4 | ||
5 | controller: { | |
6 | xclass: 'Ext.app.ViewController', | |
7 | ||
8 | init: function(view) { | |
9 | view.store.on('load', this.onLoad, view); | |
10 | }, | |
11 | ||
12 | onLoad: function(store, records, success) { | |
13 | if (!success) { | |
14 | return; | |
15 | } | |
05a977a2 TL |
16 | let me = this; |
17 | let val = me.getValue(); | |
0753b980 | 18 | if (!val || !me.store.findRecord('realm', val, 0, false, true, true)) { |
05a977a2 | 19 | let def = 'pam'; |
0391dee1 DC |
20 | Ext.each(records, function(rec) { |
21 | if (rec.data && rec.data.default) { | |
22 | def = rec.data.realm; | |
23 | } | |
24 | }); | |
25 | me.setValue(def); | |
26 | } | |
27 | }, | |
28 | }, | |
29 | ||
30 | fieldLabel: gettext('Realm'), | |
31 | name: 'realm', | |
32 | queryMode: 'local', | |
33 | allowBlank: false, | |
34 | editable: false, | |
35 | forceSelection: true, | |
36 | autoSelect: false, | |
37 | triggerAction: 'all', | |
38 | valueField: 'realm', | |
39 | displayField: 'descr', | |
40 | getState: function() { | |
41 | return { value: this.getValue() }; | |
42 | }, | |
43 | applyState: function(state) { | |
44 | if (state && state.value) { | |
45 | this.setValue(state.value); | |
46 | } | |
47 | }, | |
48 | stateEvents: ['select'], | |
49 | stateful: true, // last chosen auth realm is saved between page reloads | |
50 | id: 'pveloginrealm', // We need stable ids when using stateful, not autogenerated | |
51 | stateID: 'pveloginrealm', | |
52 | ||
53 | store: { | |
54 | model: 'pmx-domains', | |
55 | autoLoad: true, | |
56 | }, | |
57 | }); |