]> git.proxmox.com Git - pmg-gui.git/blob - js/ObjectGroupConfiguration.js
buildsys: makefiles convert to use simple parenthesis
[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: 'border',
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 (!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: PMG.Utils.oclass_text[me.ogclass],
25 title: PMG.Utils.oclass_text[me.ogclass],
26 border: false,
27 split: true,
28 region: 'west',
29 });
30
31 var right = Ext.create('PMG.ObjectGroup', {
32 otype_list: me.otype_list,
33 border: false,
34 region: 'center',
35 listeners: {
36 dblclickOGInfo: function(w, e, t, ogdata) {
37 // test if the correct groups is selected (just to be sure)
38 var rec = left.selModel.getSelection()[0];
39 if (rec && rec.data && rec.data.id === ogdata.id) {
40 left.run_editor();
41 }
42 },
43 },
44 });
45
46 me.mon(left.store, "refresh", function() {
47 var rec = left.selModel.getSelection()[0];
48 if (!(rec && rec.data && rec.data.id)) {
49 return;
50 }
51 right.setObjectInfo(rec.data);
52 });
53
54 me.mon(left.selModel, "selectionchange", function() {
55 var rec = left.selModel.getSelection()[0];
56 if (!(rec && rec.data && rec.data.id)) {
57 right.setObjectInfo(undefined);
58 right.setBaseUrl(undefined);
59 return;
60 }
61 right.setObjectInfo(rec.data);
62 var baseurl = '/config/ruledb/' + me.ogclass + '/' + rec.data.id;
63 right.setBaseUrl(baseurl);
64 });
65
66 me.items = [left, right];
67
68 me.callParent();
69 },
70 });
71
72 Ext.define('PMG.WhoConfiguration', {
73 extend: 'PMG.ObjectGroupConfiguration',
74 xtype: 'pmgWhoConfiguration',
75
76 ogclass: 'who',
77 otype_list: [1000, 1001, 1002, 1003, 1004, 1005, 1006],
78 });
79
80 Ext.define('PMG.WhenConfiguration', {
81 extend: 'PMG.ObjectGroupConfiguration',
82 xtype: 'pmgWhenConfiguration',
83
84 ogclass: 'when',
85 otype_list: [2000],
86 });
87
88 Ext.define('PMG.WhatConfiguration', {
89 extend: 'PMG.ObjectGroupConfiguration',
90 xtype: 'pmgWhatConfiguration',
91
92 ogclass: 'what',
93 otype_list: [3000, 3001, 3002, 3003, 3004, 3005, 3006],
94 });
95