]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/form/RealmComboBox.js
rename manager5 to manager6
[pve-manager.git] / www / manager6 / form / RealmComboBox.js
1 Ext.define('PVE.form.RealmComboBox', {
2 extend: 'Ext.form.field.ComboBox',
3 alias: ['widget.pveRealmComboBox'],
4
5 needOTP: function(realm) {
6 var me = this;
7
8 var rec = me.store.findRecord('realm', realm);
9
10 return rec && rec.data && rec.data.tfa ? rec.data.tfa : undefined;
11 },
12
13 initComponent: function() {
14 var me = this;
15
16 var stateid = 'pveloginrealm';
17
18 var realmstore = Ext.create('Ext.data.Store', {
19 model: 'pve-domains',
20 });
21
22 Ext.apply(me, {
23 fieldLabel: gettext('Realm'),
24 name: 'realm',
25 store: realmstore,
26 queryMode: 'local',
27 allowBlank: false,
28 forceSelection: true,
29 autoSelect: false,
30 triggerAction: 'all',
31 valueField: 'realm',
32 displayField: 'descr',
33 getState: function() {
34 return { value: this.getValue() };
35 },
36 applyState : function(state) {
37 if (state && state.value) {
38 this.setValue(state.value);
39 }
40 },
41 stateEvents: [ 'select' ],
42 stateful: true,
43 id: stateid, // fixme: remove (Stateful does not work without)
44 stateID: stateid
45 });
46
47 me.callParent();
48
49 realmstore.load({
50 callback: function(r, o, success) {
51 if (success) {
52 var def = me.getValue();
53 if (!def || !realmstore.findRecord('realm', def)) {
54 def = 'pam';
55 Ext.each(r, function(record) {
56 if (record.data && record.data["default"]) {
57 def = record.data.realm;
58 }
59 });
60 }
61 if (def) {
62 me.setValue(def);
63 }
64 }
65 }
66 });
67 }
68 });