PHP8
[Pman.BAdmin] / Pman.Tab.BAdminStaff.js
index 4426952..83afb73 100644 (file)
@@ -7,6 +7,7 @@ Roo.namespace('Pman.Tab');
 Pman.Tab.BAdminStaff = new Roo.XComponent({
 
  _strings : {
+  'cdb6b6bab1fd18b9dbfe3fb84a5d34ae' :"<i class=\"fa fa-search\"></i>",
   'ce8ae9da5b7cd6c3df2929543a9af92d' :"Email",
   'b15aafc19dc2ba4b788adf77268d8ca4' :"Hide Inactive",
   'f29c99f082755399839b64ebaf9f608a' :"List / View",
@@ -15,9 +16,8 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
   'a37ede293936e29279ed543129451ec3' :"Groups",
   '7dce122004969d56ae2e0245cb754d35' :"Edit",
   '05b763f7d24f32575493b3c23f299b0e' :"Add To Group",
-  'aba9f7d7443652e858969bfc280690b1' :"Manage Groups ",
+  '9bac86fd9f499d47cea5f2fd70d701c1' :"search for account",
   'e0a7cc944485bdedafb92b0cf98632fa' :"Remove From Group",
-  'bcc254b55c4a1babdf1dcb82c207506b' :"Phone",
   '25f57527ae8a27c94fb5230b5486c743' :"Permission List",
   '09f0c5159c5e34504e453eff3fc70324' :"Account Management",
   '054176c3a541fb2d4b63e29360c749aa' :"Members List",
@@ -30,7 +30,8 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
   '4d3d769b812b6faa6b76e1a8abaece2d' :"Active",
   '49ee3087348e8d44e1feda1917443987' :"Name",
   'e55f75a29310d7b60f7ac1d390c8ae42' :"Module",
-  'ed5dea09095f671b801bee34ea28a319' :"Permission"
+  'b5a7adde1af5c87d7fd797b6245c2a39' :"Description",
+  'aba9f7d7443652e858969bfc280690b1' :"Manage Groups"
  },
  _named_strings : {
   'activeButton_offtext' : '5bc3fd20294c17c9803942958fd7f26d' /* Show Inactive */ ,
@@ -117,16 +118,19 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
        items  : [
         {
          xtype : 'NavGroup',
+         style : 'width: 100%;',
          xns : Roo.bootstrap,
          '|xns' : 'Roo.bootstrap',
          items  : [
           {
            xtype : 'NavItem',
+           style : 'width: 100%;',
            xns : Roo.bootstrap,
            '|xns' : 'Roo.bootstrap',
            items  : [
             {
              xtype : 'Element',
+             style : 'width: 100%;',
              xns : Roo.bootstrap,
              '|xns' : 'Roo.bootstrap',
              items  : [
@@ -138,7 +142,50 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                items  : [
                 {
                  xtype : 'Column',
-                 md : 12,
+                 md : 3,
+                 xns : Roo.bootstrap,
+                 '|xns' : 'Roo.bootstrap',
+                 items  : [
+                  {
+                   xtype : 'Input',
+                   placeholder : _this._strings['9bac86fd9f499d47cea5f2fd70d701c1'] /* search for account */,
+                   listeners : {
+                    render : function (_self)
+                     {
+                         _this.searchBox = this;
+                     },
+                    specialkey : function (_self, e)
+                     {    
+                          if(e.keyCode == e.ENTER) {
+                             if (_this.member_grid) {
+                                 _this.member_grid.footer.onClick('first'); 
+                             }
+                         
+                         }
+                         
+                     }
+                   },
+                   xns : Roo.bootstrap,
+                   '|xns' : 'Roo.bootstrap',
+                   after : {
+                    xtype : 'Button',
+                    html : _this._strings['cdb6b6bab1fd18b9dbfe3fb84a5d34ae'] /* <i class="fa fa-search"></i> */,
+                    listeners : {
+                     click : function (_self, e)
+                      {
+                          _this.member_grid.footer.onClick('first');
+                      }
+                    },
+                    xns : Roo.bootstrap,
+                    '|xns' : 'Roo.bootstrap'
+                   }
+                  }
+                 ]
+                },
+                {
+                 xtype : 'Column',
+                 cls : 'text-right',
+                 md : 9,
                  xns : Roo.bootstrap,
                  '|xns' : 'Roo.bootstrap',
                  items  : [
@@ -162,7 +209,9 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                              }
                              
                              Pman.Dialog.BAdminStaffTwoFactorQRCode.show({
-                                 id : res.id
+                                 id : res.id,
+                                 allow_close: false,
+                                 allow_cancel : true
                              }, function(res){
                                  _this.member_grid.footer.onClick('first');
                              });
@@ -419,11 +468,11 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
       },
       grid : {
        xtype : 'Table',
+       auto_hide_footer : true,
        cellSelection : true,
        cls : 'table-fixed',
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : false,
        listeners : {
@@ -454,22 +503,38 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                  },this,{single:true});
              }
          },
-        render : function (_self)
-         {
-             _this.member_grid = _self;
-            
-         },
-        rowdblclick : function (_self, el, rowIndex, e)
+        celldblclick : function (_self, el, rowIndex, columnIndex, e)
          {
+             var di = _this.member_grid.colModel.getDataIndex(columnIndex);
+         
+             if (di == 'active') {
+                 return;
+             }
              var s = _this.member_grid.store.getAt(rowIndex);
              
              if(s.data.id * 1 < 1){
                  return;
              }
              
-             Pman.Dialog.BAdminStaff.show( { id : s.data.id }, function() {
+             if (di == 'member_of') {
+                 Pman.Dialog.BAdminStaffGroups.show(   s.data , function() {
+                     _this.member_grid.footer.onClick('first');
+                 });
+                 return;
+             }
+             // show edit user dialog..
+             
+             
+             
+             Pman.Dialog.BAdminStaff.show( s.data , function() {
                  _this.member_grid.footer.onClick('first');
              });
+              
+         },
+        render : function (_self)
+         {
+             _this.member_grid = _self;
+            
          }
        },
        xns : Roo.bootstrap,
@@ -484,13 +549,13 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
         buttons : [
          {
           xtype : 'Button',
-          cls : 'btn btn-default',
+          cls : 'roo-toolbar-button',
           html : _this._strings['5bc3fd20294c17c9803942958fd7f26d'] /* Show Inactive */,
           name : 'activeButton',
           _offtext : _this._strings['5bc3fd20294c17c9803942958fd7f26d'] /* Show Inactive */,
           _ontext : _this._strings['b15aafc19dc2ba4b788adf77268d8ca4'] /* Hide Inactive */,
           pressed : false,
-          style : 'margin-left: 10px;',
+          weight : 'default',
           listeners : {
            render : function (_self)
             {
@@ -540,10 +605,13 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
               
               if(_this.footerActiveBtn && !_this.footerActiveBtn.pressed){
                   options.params.active = 1;
-              }
+              } 
+              
+              options.params._with_group_membership = 1;
+              options.params['query[name_or_email]'] =    _this.searchBox.getValue();
               
               options.params['query[in_group]'] = group.data.id;
-          
+            
           },
          load : function (_self, records, options)
           {
@@ -644,15 +712,14 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
          cursor : 'pointer',
          dataIndex : 'active',
          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
-         listeners : '{\n    \"click\" : function (e){\n        console.log(\"listener fired\");\n    }\n}',
          md : 1,
          renderer : function(v) {  
-         //    var state = v> 0 ?  '-checked' : '';
-             var state = v> 0 ?  'check-' : '';
+         
+             var state = v > 0 ?  'check-' : '';
+             var cls = v > 0 ? 'text-primary' : '';
              
-             //return '<img class=\"x-grid-check-icon' + state + '\" src=\"' + Roo.BLANK_IMAGE_URL + '\"/>';
-             return '<i class=\"far fa-'+ state + 'square-o text-primary\" aria-hidden=\"true\"></i>';
-                         
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
+                  
           },
          sm : 1,
          sortable : true,
@@ -694,10 +761,12 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
         {
          xtype : 'ColumnModel',
          cursor : 'pointer',
-         dataIndex : 'phone',
-         header : _this._strings['bcc254b55c4a1babdf1dcb82c207506b'] /* Phone */,
+         dataIndex : 'member_of',
+         header : _this._strings['a37ede293936e29279ed543129451ec3'] /* Groups */,
          md : 2,
-         renderer : function(v) { return String.format('{0}', v); },
+         renderer : function(v) {
+              return String.format('{0}', v).split("\n").join("<br/>"); 
+          },
          sm : 2,
          xs : 2,
          xns : Roo.grid,
@@ -718,7 +787,7 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                      String.format('<a href="mailto:{0}">{0}</a>',v) : v;
                      
          },
-         sm : 4,
+         sm : 2,
          sortable : true,
          xs : 4,
          xns : Roo.grid,
@@ -756,7 +825,6 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
        footerShow : false,
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : true,
        listeners : {
@@ -841,7 +909,7 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
               }
               
               if(group.data.id * 1 < 1){
-                  _this.permission_panel.el.mask('You can not set permissions for this group');
+                  _this.permission_panel.el.mask('Please select a group on the left');
                   this.removeAll();
                   return false;
               }
@@ -970,21 +1038,22 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
          xtype : 'ColumnModel',
          dataIndex : 'rightname',
          header : _this._strings['e55f75a29310d7b60f7ac1d390c8ae42'] /* Module */,
+         hidden : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 1 : 0,
          renderer : function (v) {
              return String.format('<span tooltip="{1}">{0}</span>', v.split('.').shift(), v);
          },
-         xs : 2,
+         xs : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 0 : 2,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
         {
          xtype : 'ColumnModel',
          dataIndex : 'descript',
-         header : _this._strings['ed5dea09095f671b801bee34ea28a319'] /* Permission */,
+         header : _this._strings['b5a7adde1af5c87d7fd797b6245c2a39'] /* Description */,
          renderer : function (v) {
              return String.format('{0}', v ? v : '');
          },
-         xs : 4,
+         xs : appDisabled.indexOf('Core.SuperAdmin') > 0 ? 6 : 4,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
@@ -1020,9 +1089,10 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                  return '';
              }
              
-             var state = (r.data.accessmask.indexOf('E') !== -1) ? '-checked' : '';
+             var state = (r.data.accessmask.indexOf('E') !== -1) ? 'check-' : '';
+             var cls = (r.data.accessmask.indexOf('E') !== -1) ? 'text-primary' : '';
              
-             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
          },
          sortable : false,
          xs : 1,
@@ -1040,9 +1110,11 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                  return '';
              }
              
-             var state = (r.data.accessmask.indexOf('D') !== -1) ? '-checked' : '';
+             var state = (r.data.accessmask.indexOf('D') !== -1) ? 'check-' : '';
+             var cls = (r.data.accessmask.indexOf('D') !== -1) ? 'text-primary' : '';
+             
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
              
-             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
          },
          sortable : false,
          xs : 1,
@@ -1060,9 +1132,11 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                  return '';
              }
              
-             var state = (r.data.accessmask.indexOf('S') !== -1) ? '-checked' : '';
+             var state = (r.data.accessmask.indexOf('S') !== -1) ? 'check-' : '';
+             var cls = (r.data.accessmask.indexOf('S') !== -1) ? 'text-primary' : '';
+             
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
              
-             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
          },
          sortable : false,
          xs : 1,
@@ -1080,9 +1154,11 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
                  return '';
              }
              
-             var state = (r.data.accessmask.indexOf('P') !== -1) ? '-checked' : '';
+             var state = (r.data.accessmask.indexOf('P') !== -1) ? 'check-' : '';
+             var cls = (r.data.accessmask.indexOf('P') !== -1) ? 'text-primary' : '';
+             
+             return '<i class=\"far fa-'+ state + 'square-o ' + cls + '\" aria-hidden=\"true\"></i>';
              
-             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
          },
          sortable : false,
          xs : 1,
@@ -1124,132 +1200,138 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
          '|xns' : 'Roo.bootstrap',
          items  : [
           {
-           xtype : 'NavSidebarItem',
-           glyphicon : 'menu-hamburger',
-           html : _this._strings['aba9f7d7443652e858969bfc280690b1'] /* Manage Groups  */,
-           preventDefault : true,
+           xtype : 'NavItem',
+           cls : 'account-management-group-nav-item',
            xns : Roo.bootstrap,
            '|xns' : 'Roo.bootstrap',
-           menu : {
-            xtype : 'Menu',
-            xns : Roo.bootstrap,
-            '|xns' : 'Roo.bootstrap',
-            items  : [
-             {
-              xtype : 'MenuItem',
-              fa : 'fa fa-plus',
-              html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
-              isContainer : false,
-              preventDefault : true,
-              listeners : {
-               click : function (_self, e)
-                {
-                    Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){
-                        _this.group_grid.store.load({});
-                    });
-                }
-              },
-              xns : Roo.bootstrap,
-              '|xns' : 'Roo.bootstrap'
-             },
-             {
-              xtype : 'MenuItem',
-              fa : 'fa fa-pencil',
-              html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
-              isContainer : false,
-              preventDefault : true,
-              listeners : {
-               click : function (_self, e)
-                {
-                    var sel = _this.group_grid.getSelectionModel().getSelected();
-                    
-                    if(!sel){
-                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
-                        return;
-                    }
-                    
-                    if(sel.data.id * 1 < 1){
-                        Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
-                        return;
-                    }
-                    
-                    Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){
-                        _this.group_grid.store.load({});
-                    });
-                }
-              },
-              xns : Roo.bootstrap,
-              '|xns' : 'Roo.bootstrap'
-             },
-             {
-              xtype : 'MenuItem',
-              fa : 'fa fa-trash',
-              html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
-              isContainer : false,
-              preventDefault : true,
-              listeners : {
-               click : function (_self, e)
-                {
-                    var sel = _this.group_grid.getSelectionModel().getSelected();
-                    
-                    if(!sel){
-                        Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
-                        return;
-                    }
-                    
-                    if(sel.data.id * 1 < 1){
-                        Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
-                        return;
-                    }
-                    
-                    var deleteIt = function()
-                    {
-                        new Pman.Request({
-                            url: baseURL + '/Roo/Core_group',
-                            method: 'POST',
-                            params: {
-                                _delete : sel.data.id
-                            },
-                            success: function(res){
-                                _this.group_grid.store.load({});
-                                return;
-                            }
-                        });
-                    }
-                    
-                    Roo.bootstrap.MessageBox.confirm('Confirm', 'Are you sure to delete the group?',function(ret) {
-                        
-                        if(ret == 'no'){
-                            return;
-                        }
-                        
-                        deleteIt();
-                        
-                     }, this);
-                    
-                    
-                }
-              },
-              xns : Roo.bootstrap,
-              '|xns' : 'Roo.bootstrap'
-             },
-             {
-              xtype : 'MenuItem',
-              fa : 'fa fa-refresh',
-              html : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
-              isContainer : false,
-              preventDefault : true,
-              listeners : {
-               click : function (_self, e)
-                {
-                    _this.group_grid.store.load({});
-                }
-              },
+           items  : [
+            {
+             xtype : 'Button',
+             html : _this._strings['aba9f7d7443652e858969bfc280690b1'] /* Manage Groups */,
+             xns : Roo.bootstrap,
+             '|xns' : 'Roo.bootstrap',
+             menu : {
+              xtype : 'Menu',
               xns : Roo.bootstrap,
-              '|xns' : 'Roo.bootstrap'
+              '|xns' : 'Roo.bootstrap',
+              items  : [
+               {
+                xtype : 'MenuItem',
+                fa : 'fa fa-plus',
+                html : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
+                isContainer : false,
+                preventDefault : true,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      Pman.Dialog.BAdminGroups.show({ id : 0 }, function(res){
+                          _this.group_grid.store.load({});
+                      });
+                  }
+                },
+                xns : Roo.bootstrap,
+                '|xns' : 'Roo.bootstrap'
+               },
+               {
+                xtype : 'MenuItem',
+                fa : 'fa fa-pencil',
+                html : _this._strings['7dce122004969d56ae2e0245cb754d35'] /* Edit */,
+                isContainer : false,
+                preventDefault : true,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var sel = _this.group_grid.getSelectionModel().getSelected();
+                      
+                      if(!sel){
+                          Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
+                          return;
+                      }
+                      
+                      if(sel.data.id * 1 < 1){
+                          Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
+                          return;
+                      }
+                      
+                      Pman.Dialog.BAdminGroups.show({ id : sel.data.id }, function(res){
+                          _this.group_grid.store.load({});
+                      });
+                  }
+                },
+                xns : Roo.bootstrap,
+                '|xns' : 'Roo.bootstrap'
+               },
+               {
+                xtype : 'MenuItem',
+                fa : 'fa fa-trash',
+                html : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
+                isContainer : false,
+                preventDefault : true,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      var sel = _this.group_grid.getSelectionModel().getSelected();
+                      
+                      if(!sel){
+                          Roo.bootstrap.MessageBox.alert('Error', 'Please select a group');
+                          return;
+                      }
+                      
+                      if(sel.data.id * 1 < 1){
+                          Roo.bootstrap.MessageBox.alert('Error', 'The selected group is not editable');
+                          return;
+                      }
+                      
+                      var deleteIt = function()
+                      {
+                          new Pman.Request({
+                              url: baseURL + '/Roo/Core_group',
+                              method: 'POST',
+                              params: {
+                                  _delete : sel.data.id
+                              },
+                              success: function(res){
+                                  _this.group_grid.store.load({});
+                                  return;
+                              }
+                          });
+                      }
+                      
+                      Roo.bootstrap.MessageBox.confirm('Confirm', 'Are you sure to delete the group?',function(ret) {
+                          
+                          if(ret == 'no'){
+                              return;
+                          }
+                          
+                          deleteIt();
+                          
+                       }, this);
+                      
+                      
+                  }
+                },
+                xns : Roo.bootstrap,
+                '|xns' : 'Roo.bootstrap'
+               },
+               {
+                xtype : 'MenuItem',
+                fa : 'fa fa-refresh',
+                html : _this._strings['4d1c8263ba1036754f8db14a98f9f006'] /* Reload */,
+                isContainer : false,
+                preventDefault : true,
+                listeners : {
+                 click : function (_self, e)
+                  {
+                      _this.group_grid.store.load({});
+                  }
+                },
+                xns : Roo.bootstrap,
+                '|xns' : 'Roo.bootstrap'
+               }
+              ]
              }
-            ]
-           }
+            }
+           ]
           }
          ]
         }
@@ -1261,7 +1343,6 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
        footerShow : false,
        hover : true,
        loadMask : true,
-       responsive : true,
        rowSelection : true,
        striped : true,
        listeners : {
@@ -1315,7 +1396,7 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
               options.params.type = 0;
               
               options.params._add_everyone = 1;
-          
+          options.params.limit = 999;
           }
         },
         xns : Roo.data,
@@ -1329,6 +1410,28 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
         },
         reader : {
          xtype : 'JsonReader',
+         fields : [
+             {
+                 'name': 'id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'leader',
+                 'type': 'string'
+             },
+             {
+                 'name': 'group_member_count',
+                 'type': 'int'
+             },
+             {
+                 'name': 'display_name',
+                 'type': 'string'
+             },
+             {
+                 'name': 'name',
+                 'type': 'string'
+             }
+         ],
          id : 'id',
          root : 'data',
          totalProperty : 'total',
@@ -1364,7 +1467,7 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
          header : _this._strings['49ee3087348e8d44e1feda1917443987'] /* Name */,
          md : 12,
          renderer : function(v,x,r) { 
-             //console.log(r.data);
+         
              if (r.data.id == 0) {
                  return '<b>' + "All Staff" + '</b>';
              }
@@ -1372,16 +1475,18 @@ Pman.Tab.BAdminStaff = new Roo.XComponent({
              if (r.data.id == -1) {
                  return '<b>' + "Not in a Group" + '</b>';
              }
+         
+             var vv = (r.json.display_name.length) ? r.json.display_name : v;
              
              if (v == 'Administrators') {
-                 return '<b>' + "Adminstrators" + '</b>';
+                 return '<b>' + vv + '</b>';
              }
              
              if (r.data.leader) {
-                 return v + ' (' + r.data.leader_name + ')';
+                 return vv + ' (' + r.json.leader_name + ')';
              }
              
-             return String.format('{0} ({1})',v, r.json.group_member_count);
+             return String.format('{0} ({1})',vv, r.json.group_member_count);
          },
          sm : 12,
          sortable : false,