]> git.proxmox.com Git - pve-manager.git/blob - www/manager6/dc/RoleView.js
ui: eslint: fix trailing comma and comma related whitespaces errors
[pve-manager.git] / www / manager6 / dc / RoleView.js
1 Ext.define('PVE.dc.RoleView', {
2 extend: 'Ext.grid.GridPanel',
3
4 alias: ['widget.pveRoleView'],
5
6 onlineHelp: 'pveum_roles',
7
8 stateful: true,
9 stateId: 'grid-roles',
10
11 initComponent : function() {
12 var me = this;
13
14 var store = new Ext.data.Store({
15 model: 'pmx-roles',
16 sorters: {
17 property: 'roleid',
18 order: 'DESC',
19 },
20 });
21
22 var render_privs = function(value, metaData) {
23
24 if (!value) {
25 return '-';
26 }
27
28 // allow word wrap
29 metaData.style = 'white-space:normal;';
30
31 return value.replace(/\,/g, ' ');
32 };
33
34 Proxmox.Utils.monStoreErrors(me, store);
35
36 var sm = Ext.create('Ext.selection.RowModel', {});
37
38 var reload = function() {
39 store.load();
40 };
41
42 var run_editor = function() {
43 var rec = sm.getSelection()[0];
44 if (!rec) {
45 return;
46 }
47
48 if (!!rec.data.special) {
49 return;
50 }
51
52 var win = Ext.create('PVE.dc.RoleEdit', {
53 roleid: rec.data.roleid,
54 privs: rec.data.privs,
55 });
56 win.on('destroy', reload);
57 win.show();
58 };
59
60 Ext.apply(me, {
61 store: store,
62 selModel: sm,
63
64 viewConfig: {
65 trackOver: false,
66 },
67 columns: [
68 {
69 header: gettext('Built-In'),
70 width: 65,
71 sortable: true,
72 dataIndex: 'special',
73 renderer: Proxmox.Utils.format_boolean,
74 },
75 {
76 header: gettext('Name'),
77 width: 150,
78 sortable: true,
79 dataIndex: 'roleid',
80 },
81 {
82 itemid: 'privs',
83 header: gettext('Privileges'),
84 sortable: false,
85 renderer: render_privs,
86 dataIndex: 'privs',
87 flex: 1,
88 },
89 ],
90 listeners: {
91 activate: function() {
92 store.load();
93 },
94 itemdblclick: run_editor,
95 },
96 tbar: [
97 {
98 text: gettext('Create'),
99 handler: function() {
100 var win = Ext.create('PVE.dc.RoleEdit', {});
101 win.on('destroy', reload);
102 win.show();
103 },
104 },
105 {
106 xtype: 'proxmoxButton',
107 text: gettext('Edit'),
108 disabled: true,
109 selModel: sm,
110 handler: run_editor,
111 enableFn: (rec) => !rec.data.special,
112 },
113 {
114 xtype: 'proxmoxStdRemoveButton',
115 selModel: sm,
116 callback: function() {
117 reload();
118 },
119 baseurl: '/access/roles/',
120 enableFn: (rec) => !rec.data.special,
121 },
122 ],
123 });
124
125 me.callParent();
126 },
127 });