Skip to content

Commit d186f32

Browse files
committed
Adjust the user grid
1 parent 8326787 commit d186f32

File tree

6 files changed

+267
-27
lines changed

6 files changed

+267
-27
lines changed
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
twilio.combo.UserActive = function (config) {
2+
config = config || {};
3+
Ext.applyIf(config, {
4+
store: new Ext.data.SimpleStore({
5+
fields: ["l", "v"],
6+
data: [
7+
["All", ""],
8+
["Active", 1],
9+
["Inactive", 0],
10+
],
11+
}),
12+
displayField: 'l',
13+
valueField: 'v',
14+
emptyText: _('twilio.user.activefilter.empty'),
15+
mode: "local",
16+
triggerAction: "all",
17+
editable: false,
18+
selectOnFocus: false,
19+
preventRender: true,
20+
forceSelection: true,
21+
enableKeyEvents: true,
22+
});
23+
twilio.combo.UserActive.superclass.constructor.call(this, config);
24+
}
25+
Ext.extend(twilio.combo.UserActive, MODx.combo.ComboBox);
26+
Ext.reg('twilio-combo-user-active', twilio.combo.UserActive);
27+
28+
twilio.combo.Use2fa = function (config) {
29+
config = config || {};
30+
Ext.applyIf(config, {
31+
store: new Ext.data.SimpleStore({
32+
fields: ["l", "v"],
33+
data: [
34+
["All", ""],
35+
["Enabled", 1],
36+
["Disabled", 0],
37+
],
38+
}),
39+
displayField: 'l',
40+
valueField: 'v',
41+
emptyText: _('twilio.users.totp_value'),
42+
mode: "local",
43+
triggerAction: "all",
44+
editable: false,
45+
selectOnFocus: false,
46+
preventRender: true,
47+
forceSelection: true,
48+
enableKeyEvents: true,
49+
});
50+
twilio.combo.Use2fa.superclass.constructor.call(this, config);
51+
}
52+
Ext.extend(twilio.combo.Use2fa, MODx.combo.ComboBox);
53+
Ext.reg('twilio-combo-use-2FA', twilio.combo.Use2fa);

assets/components/twilio/js/mgr/widgets/users.grid.js

Lines changed: 117 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,21 @@ twilio.grid.Users = function (config) {
2121
baseParams: {
2222
action: 'users/getlist'
2323
}
24-
,fields: ['id','username', 'profile_fullname', 'profile_email', 'totp_value', 'totp_status']
24+
,fields: ['id',
25+
'username',
26+
'active',
27+
'add_groups',
28+
'primary_group',
29+
'primary_group_name',
30+
'primary_group_role',
31+
'profile_blocked',
32+
'profile_comment',
33+
'profile_email',
34+
'profile_fullname',
35+
'profile_lastlogin',
36+
'totp_value',
37+
'totp_status'
38+
]
2539
,sm: this.sm
2640
,autoHeight: true
2741
,paging: true
@@ -41,17 +55,71 @@ twilio.grid.Users = function (config) {
4155
,sortable: true
4256
,hidden: false
4357
},{
44-
header: _('twilio.users.fullname')
58+
header: _('active')
59+
,dataIndex: 'active'
60+
,width: 100
61+
,sortable: true
62+
,hidden: true
63+
,renderer: this.rendYesNo
64+
},{
65+
header: _('user_block')
66+
,dataIndex: 'profile_blocked'
67+
,width: 100
68+
,sortable: true
69+
,hidden: true
70+
,renderer: this.rendYesNo
71+
},{
72+
header: _('user_full_name')
4573
,dataIndex: 'profile_fullname'
4674
,width: 200
4775
,sortable: true
4876
,hidden: false
4977
},{
50-
header: _('twilio.users.email')
78+
header: _('email')
5179
,dataIndex: 'profile_email'
5280
,width: 200
5381
,sortable: true
5482
,hidden: false
83+
},{
84+
header: _('primary_group')
85+
,dataIndex: 'primary_group_name'
86+
,width: 200
87+
,sortable: true
88+
,hidden: false
89+
,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
90+
return value + ' (' + record.data.primary_group_role + ')';
91+
}
92+
},{
93+
header: _('twilio.users.additional_groups')
94+
,dataIndex: 'add_groups'
95+
,width: 200
96+
,sortable: true
97+
,hidden: false
98+
,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
99+
var groupNames = []
100+
Ext.each(value, function (group, index) {
101+
groupNames.push(group.name + ' (' + group.role + ')');
102+
});
103+
return groupNames.join(', ');
104+
}
105+
},{
106+
header: _('role')
107+
,dataIndex: 'primary_group_role'
108+
,width: 200
109+
,sortable: false
110+
,hidden: true
111+
},{
112+
header: _('comment')
113+
,dataIndex: 'profile_comment'
114+
,width: 200
115+
,sortable: false
116+
,hidden: true
117+
},{
118+
header: _('user_prevlogin')
119+
,dataIndex: 'profile_lastlogin'
120+
,width: 200
121+
,sortable: false
122+
,hidden: false
55123
}, {
56124
header: _('twilio.users.totp_value')
57125
,dataIndex: 'totp_value'
@@ -286,12 +354,23 @@ Ext.extend(twilio.grid.Users, MODx.grid.Grid, {
286354
getSelectedAsList: function () {
287355
return this.selectedRecords.join();
288356
},
289-
290-
search: function (tf, newValue, oldValue) {
291-
var nv = newValue || tf;
292-
this.getStore().baseParams.search = Ext.isEmpty(nv) || Ext.isObject(nv) ? '' : nv;
357+
filterSearch: function (comp, search) {
358+
var s = this.getStore();
359+
s.baseParams[comp.filterName] = search;
293360
this.getBottomToolbar().changePage(1);
294-
return true;
361+
},
362+
filterCombo: function (combo, record) {
363+
var s = this.getStore();
364+
s.baseParams[combo.filterName] = record.data[combo.valueField];
365+
this.getBottomToolbar().changePage(1);
366+
},
367+
exportFilters: function (comp, search) {
368+
var s = this.getStore();
369+
var filters = "export=true&HTTP_MODAUTH=" + MODx.siteId;
370+
Object.keys(s.baseParams).forEach((key) => {
371+
filters += "&" + key + "=" + s.baseParams[key];
372+
});
373+
window.location = this.config.url + "?" + filters;
295374
},
296375
getTbar: function (config) {
297376
var tbar = [];
@@ -324,28 +403,47 @@ Ext.extend(twilio.grid.Users, MODx.grid.Grid, {
324403
handler: this.disableTotp,
325404
}
326405
]
406+
},{
407+
text: _("twilio.users.export"),
408+
handler: this.exportFilters,
409+
scope: this,
327410
},'->',{
411+
xtype: 'twilio-combo-use-2FA',
412+
name: '2fa',
413+
scope: this,
414+
filterName: "2fa",
415+
listeners: {
416+
select: this.filterCombo,
417+
scope: this
418+
}
419+
},{
420+
xtype: 'twilio-combo-user-active',
421+
name: 'active',
422+
scope: this,
423+
filterName: "active",
424+
listeners: {
425+
select: this.filterCombo,
426+
scope: this
427+
}
428+
429+
},{
328430
xtype: 'textfield',
329431
emptyText: _('search_ellipsis'),
330432
id: 'twilio-filter-search',
433+
filterName: "search",
331434
listeners: {
332-
change: {
333-
fn: this.search,
334-
scope: this
335-
},
435+
change: this.filterSearch,
436+
scope: this,
336437
render: {
337438
fn: function (cmp) {
338439
new Ext.KeyMap(cmp.getEl(), {
339440
key: Ext.EventObject.ENTER,
340-
fn: function () {
341-
this.blur();
342-
return true;
343-
},
344-
scope: cmp
441+
fn: this.blur,
442+
scope: cmp,
345443
});
346444
},
347-
scope:this
348-
}
445+
scope: this,
446+
},
349447
}
350448
}]);
351449

core/components/twilio/controllers/users.class.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ public function getPageTitle()
1313
}
1414
public function loadCustomCssJs()
1515
{
16+
$this->addJavascript($this->twilio->getOption('jsUrl') . 'mgr/helpers/combo.js?v=' . $this->version);
1617
$this->addJavascript($this->twilio->getOption('jsUrl') . 'mgr/widgets/users.grid.js?v=' . $this->version);
1718
$this->addJavascript($this->twilio->getOption('jsUrl') . 'mgr/widgets/users.panel.js?v=' . $this->version);
1819
$this->addLastJavascript($this->twilio->getOption('jsUrl') . 'mgr/sections/users.js?v=' . $this->version);

core/components/twilio/index.class.php

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,11 @@ public function checkPermissions()
88
return true;
99
}
1010

11+
public function getLanguageTopics()
12+
{
13+
return array('twilio:default', 'user');
14+
}
15+
1116
public function initialize()
1217
{
1318
$corePath = $this->modx->getOption(
@@ -27,6 +32,7 @@ public function initialize()
2732
'core_path' => $corePath
2833
)
2934
);
35+
$this->modx->lexicon->load('twilio:default');
3036
$this->addJavascript($this->twilio->getOption('jsUrl') . 'mgr/twilio.js');
3137
$user = $this->modx->user;
3238
$profile = $user->getOne('Profile');
@@ -43,9 +49,4 @@ public function initialize()
4349
});
4450
</script>');
4551
}
46-
47-
public function getLanguageTopics()
48-
{
49-
return array('twilio:default');
50-
}
5152
}

core/components/twilio/lexicon/en/default.inc.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
$_lang['twilio.users.username'] = 'Username';
2525
$_lang['twilio.users.fullname'] = 'Full Name';
2626
$_lang['twilio.users.email'] = 'Email';
27+
$_lang['twilio.users.additional_groups'] = 'Additional Groups';
2728
$_lang['twilio.users.totp_status'] = '2FA Status';
2829
$_lang['twilio.users.totp_value'] = 'Use 2FA';
2930
$_lang['twilio.users.enable_totp'] = 'Enable 2FA';
@@ -38,6 +39,8 @@
3839
$_lang['twilio.users.totp_status_verified'] = 'Verified';
3940
$_lang['twilio.users.totp_status_unverified'] = 'Awaiting Verification';
4041
$_lang['twilio.users.with-selected'] = 'With Selected';
42+
$_lang['twilio.users.export'] = 'Export';
43+
$_lang['twilio.user.activefilter.empty'] = 'User Status';
4144
// Settings
4245
$_lang['setting_twilio.account_sid'] = 'Account SID';
4346
$_lang['setting_twilio.account_sid_desc'] = 'Found under Account Info here https://console.twilio.com/';

0 commit comments

Comments
 (0)