@@ -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
0 commit comments