Skip to content

Commit b0c9d3d

Browse files
committed
sync updates from 2.x branch
1 parent fee6249 commit b0c9d3d

File tree

11 files changed

+2904
-47
lines changed

11 files changed

+2904
-47
lines changed

_build/gpm.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"lowCaseName": "twilio",
44
"description": "Twilio for MODX Revolution 3.x",
55
"author": "John Peca",
6-
"version": "2.0.3",
6+
"version": "2.1.0",
77
"menus": [
88
{
99
"text": "twilio.users",
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: 'MODX\\Twilio\\Processors\\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/composer.json

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,10 @@
1818
},
1919
"minimum-stability": "dev",
2020
"require": {
21-
"php": ">=7.2.0",
21+
"php": ">=7.4.0",
2222
"twilio/sdk": "dev-main"
23+
},
24+
"require-dev": {
25+
"modx/revolution": "^3.0"
2326
}
2427
}

0 commit comments

Comments
 (0)