Skip to content

Commit

Permalink
sync updates from 2.x branch
Browse files Browse the repository at this point in the history
  • Loading branch information
matdave committed Jan 18, 2024
1 parent fee6249 commit b0c9d3d
Show file tree
Hide file tree
Showing 11 changed files with 2,904 additions and 47 deletions.
2 changes: 1 addition & 1 deletion _build/gpm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"lowCaseName": "twilio",
"description": "Twilio for MODX Revolution 3.x",
"author": "John Peca",
"version": "2.0.3",
"version": "2.1.0",
"menus": [
{
"text": "twilio.users",
Expand Down
53 changes: 53 additions & 0 deletions assets/components/twilio/js/mgr/helpers/combo.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
twilio.combo.UserActive = function (config) {
config = config || {};
Ext.applyIf(config, {
store: new Ext.data.SimpleStore({
fields: ["l", "v"],
data: [
["All", ""],
["Active", '1'],
["Inactive", '0'],
],
}),
displayField: 'l',
valueField: 'v',
emptyText: _('twilio.user.activefilter.empty'),
mode: "local",
triggerAction: "all",
editable: false,
selectOnFocus: false,
preventRender: true,
forceSelection: true,
enableKeyEvents: true,
});
twilio.combo.UserActive.superclass.constructor.call(this, config);
}
Ext.extend(twilio.combo.UserActive, MODx.combo.ComboBox);
Ext.reg('twilio-combo-user-active', twilio.combo.UserActive);

twilio.combo.Use2fa = function (config) {
config = config || {};
Ext.applyIf(config, {
store: new Ext.data.SimpleStore({
fields: ["l", "v"],
data: [
["All", ""],
["Enabled", '1'],
["Disabled", '0'],
],
}),
displayField: 'l',
valueField: 'v',
emptyText: _('twilio.users.totp_value'),
mode: "local",
triggerAction: "all",
editable: false,
selectOnFocus: false,
preventRender: true,
forceSelection: true,
enableKeyEvents: true,
});
twilio.combo.Use2fa.superclass.constructor.call(this, config);
}
Ext.extend(twilio.combo.Use2fa, MODx.combo.ComboBox);
Ext.reg('twilio-combo-use-2FA', twilio.combo.Use2fa);
136 changes: 117 additions & 19 deletions assets/components/twilio/js/mgr/widgets/users.grid.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,21 @@ twilio.grid.Users = function (config) {
baseParams: {
action: 'MODX\\Twilio\\Processors\\Users\\GetList'
}
,fields: ['id','username', 'profile_fullname', 'profile_email', 'totp_value', 'totp_status']
,fields: ['id',
'username',
'active',
'add_groups',
'primary_group',
'primary_group_name',
'primary_group_role',
'profile_blocked',
'profile_comment',
'profile_email',
'profile_fullname',
'profile_lastlogin',
'totp_value',
'totp_status'
]
,sm: this.sm
,autoHeight: true
,paging: true
Expand All @@ -41,17 +55,71 @@ twilio.grid.Users = function (config) {
,sortable: true
,hidden: false
},{
header: _('twilio.users.fullname')
header: _('active')
,dataIndex: 'active'
,width: 100
,sortable: true
,hidden: true
,renderer: this.rendYesNo
},{
header: _('user_block')
,dataIndex: 'profile_blocked'
,width: 100
,sortable: true
,hidden: true
,renderer: this.rendYesNo
},{
header: _('user_full_name')
,dataIndex: 'profile_fullname'
,width: 200
,sortable: true
,hidden: false
},{
header: _('twilio.users.email')
header: _('email')
,dataIndex: 'profile_email'
,width: 200
,sortable: true
,hidden: false
},{
header: _('primary_group')
,dataIndex: 'primary_group_name'
,width: 200
,sortable: true
,hidden: false
,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
return value + ' (' + record.data.primary_group_role + ')';
}
},{
header: _('twilio.users.additional_groups')
,dataIndex: 'add_groups'
,width: 200
,sortable: true
,hidden: false
,renderer: function(value, metaData, record, rowIndex, colIndex, store) {
var groupNames = []
Ext.each(value, function (group, index) {
groupNames.push(group.name + ' (' + group.role + ')');
});
return groupNames.join(', ');
}
},{
header: _('role')
,dataIndex: 'primary_group_role'
,width: 200
,sortable: false
,hidden: true
},{
header: _('comment')
,dataIndex: 'profile_comment'
,width: 200
,sortable: false
,hidden: true
},{
header: _('user_prevlogin')
,dataIndex: 'profile_lastlogin'
,width: 200
,sortable: false
,hidden: false
}, {
header: _('twilio.users.totp_value')
,dataIndex: 'totp_value'
Expand Down Expand Up @@ -286,12 +354,23 @@ Ext.extend(twilio.grid.Users, MODx.grid.Grid, {
getSelectedAsList: function () {
return this.selectedRecords.join();
},

search: function (tf, newValue, oldValue) {
var nv = newValue || tf;
this.getStore().baseParams.search = Ext.isEmpty(nv) || Ext.isObject(nv) ? '' : nv;
filterSearch: function (comp, search) {
var s = this.getStore();
s.baseParams[comp.filterName] = search;
this.getBottomToolbar().changePage(1);
return true;
},
filterCombo: function (combo, record) {
var s = this.getStore();
s.baseParams[combo.filterName] = record.data[combo.valueField];
this.getBottomToolbar().changePage(1);
},
exportFilters: function (comp, search) {
var s = this.getStore();
var filters = "export=true&HTTP_MODAUTH=" + MODx.siteId;
Object.keys(s.baseParams).forEach((key) => {
filters += "&" + key + "=" + s.baseParams[key];
});
window.location = this.config.url + "?" + filters;
},
getTbar: function (config) {
var tbar = [];
Expand Down Expand Up @@ -324,28 +403,47 @@ Ext.extend(twilio.grid.Users, MODx.grid.Grid, {
handler: this.disableTotp,
}
]
},{
text: _("twilio.users.export"),
handler: this.exportFilters,
scope: this,
},'->',{
xtype: 'twilio-combo-use-2FA',
name: '2fa',
scope: this,
filterName: "2fa",
listeners: {
select: this.filterCombo,
scope: this
}
},{
xtype: 'twilio-combo-user-active',
name: 'active',
scope: this,
filterName: "active",
listeners: {
select: this.filterCombo,
scope: this
}

},{
xtype: 'textfield',
emptyText: _('search_ellipsis'),
id: 'twilio-filter-search',
filterName: "search",
listeners: {
change: {
fn: this.search,
scope: this
},
change: this.filterSearch,
scope: this,
render: {
fn: function (cmp) {
new Ext.KeyMap(cmp.getEl(), {
key: Ext.EventObject.ENTER,
fn: function () {
this.blur();
return true;
},
scope: cmp
fn: this.blur,
scope: cmp,
});
},
scope:this
}
scope: this,
},
}
}]);

Expand Down
5 changes: 4 additions & 1 deletion core/components/twilio/composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,10 @@
},
"minimum-stability": "dev",
"require": {
"php": ">=7.2.0",
"php": ">=7.4.0",
"twilio/sdk": "dev-main"
},
"require-dev": {
"modx/revolution": "^3.0"
}
}

0 comments on commit b0c9d3d

Please sign in to comment.