]> git.proxmox.com Git - pmg-gui.git/blob - js/ObjectGroupConfiguration.js
replace alias by xtype
[pmg-gui.git] / js / ObjectGroupConfiguration.js
1 Ext.define('PMG.ObjectGroupConfiguration', {
2 extend: 'Ext.panel.Panel',
3
4 ogclass: undefined, // who, when, what
5 otype_list: [],
6
7 layout: { type: 'hbox', align: 'stretch' },
8 border: false,
9
10 initComponent : function() {
11 var me = this;
12
13 if (me.ogclass === undefined) {
14 throw "undefined object group class"
15 }
16
17 if (!(me.title = PMG.Utils.oclass_text[me.ogclass])) {
18 throw "unknown object group class";
19 }
20
21 var left = Ext.create('PMG.ObjectGroupList', {
22 width: 250,
23 ogclass: me.ogclass,
24 subject: me.title,
25 border: false
26 });
27
28 var right = Ext.create('PMG.ObjectGroup', {
29 otype_list: me.otype_list,
30 border: false,
31 flex: 1,
32 listeners: {
33 dblclickOGInfo: function(w, e, t, ogdata) {
34 // test if the correct groups is selected (just to be sure)
35 var rec = left.selModel.getSelection()[0];
36 if (rec && rec.data && rec.data.id === ogdata.id) {
37 left.run_editor();
38 return;
39 }
40 }
41 }
42 });
43
44 me.mon(left.store, "refresh", function() {
45 var rec = left.selModel.getSelection()[0];
46 if (!(rec && rec.data && rec.data.id)) {
47 return;
48 }
49 right.setObjectInfo(rec.data);
50 });
51
52 me.mon(left.selModel, "selectionchange", function() {
53 var rec = left.selModel.getSelection()[0];
54 if (!(rec && rec.data && rec.data.id)) {
55 right.setObjectInfo(undefined);
56 right.setBaseUrl(undefined);
57 return;
58 }
59 right.setObjectInfo(rec.data);
60 var baseurl = '/config/ruledb/' + me.ogclass + '/' + rec.data.id;
61 right.setBaseUrl(baseurl);
62 });
63
64 me.items = [ left, { xtype: 'splitter' }, right ];
65
66 me.callParent();
67 }
68 });
69
70 Ext.define('PMG.WhoConfiguration', {
71 extend: 'PMG.ObjectGroupConfiguration',
72 xtype: 'pmgWhoConfiguration',
73
74 ogclass: 'who',
75 otype_list: [1000, 1001, 1002, 1003, 1004, 1005, 1006]
76 });
77
78 Ext.define('PMG.WhenConfiguration', {
79 extend: 'PMG.ObjectGroupConfiguration',
80 xtype: 'pmgWhenConfiguration',
81
82 ogclass: 'when',
83 otype_list: [2000]
84 });
85
86 Ext.define('PMG.WhatConfiguration', {
87 extend: 'PMG.ObjectGroupConfiguration',
88 xtype: 'pmgWhatConfiguration',
89
90 ogclass: 'what',
91 otype_list: []
92 });
93