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