Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.js
index 8ea9ef1..8fd0514 100644 (file)
@@ -57,7 +57,8 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                     },
                     cellclick : function (_self, rowIndex, columnIndex, e)
                     {
-                    
+                            _this.dataUpdate = typeof(_this.dataUpdate) =='undefined' ?  {} : _this.dataUpdate;
+                            
                             var di = this.colModel.getDataIndex(columnIndex);
                             var i = di.split('_').shift();
                             var k = di.split('_').pop();
@@ -72,7 +73,10 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                                 });
                             } 
                             rec.set(i+'_'+k, rec.data[i+'_'+k] ? 0 : 1);
-                            
+                            //rec.data.accessmask = rec.data.accessmask + rec
+                            //Roo.log(rec);
+                            _this.dataUpdate[rec.data.id] = rec.data.accessmask;
+                    
                             //rec.commit();
                              
                             
@@ -135,8 +139,15 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         },
                         load : function (_self, records, options)
                         {
-                            Roo.log(records);
-                            Roo.log(options);
+                            Roo.each(records, function(e){
+                                var k = e.data.accessmask.split('');
+                                Roo.each(k, function(ee){
+                                    e.set('accessmask_'+ee, 1);
+                                });
+                                if(e.data.accessmask == e.data.FullMask){
+                                    e.set('accessmask_AA', 1);
+                                }
+                            });
                         }
                     },
                     remoteSort : true,
@@ -201,94 +212,32 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                     xns: Roo,
                     items : [
                         {
-                            xtype: 'TextItem',
+                            xtype: 'Button',
                             xns: Roo.Toolbar,
-                            text : "Search"
-                        },
-                        {
-                            xtype: 'TextField',
-                            xns: Roo.form,
                             listeners : {
-                                render : function (_self)
-                                {
-                                    _this.searchBox = _self;
-                                },
-                                show : function (_self,e)
-                                {
-                                    if (e.getCharCode() != 13) {
-                                        return;
-                                    }
-                                    _this.grid.footer.onClick('first');
-                                },
-                                specialkey : function (_self, e)
+                                click : function (_self, e)
                                 {
-                                  if (e.getKey() == 13) {
-                                    _this.grid.footer.onClick('first');
-                                  }
-                                }
-                            }
-                        },
-                        {
-                            xtype: 'ComboBox',
-                            xns: Roo.form,
-                            listeners : {
-                                render : function (_self)
-                                {
-                                  _this.companyCombo = _self;
-                                },
-                                select : function (combo, record, index)
-                                {
-                                   _this.grid.footer.onClick.defer(300,_this.grid.footer,[ 'first'] );
+                                    
+                                    new Pman.Request({
+                                        url : baseURL + '/Roo/GroupRights.php',
+                                        method :'POST',
+                                        params : _this.dataUpdate,
+                                        success : function() {
+                                            // do nothing
+                                            
+                                            //_this.grid.ds.remove(record);
+                                            
+                                        },
+                                        failure : function() 
+                                        {
+                                            Roo.MessageBox.alert("Error", "saving failed", function() {
+                                                _this.grid.footer.onClick('first');
+                                            });
+                                        }
+                                    });
                                 }
                             },
-                            displayField : 'name',
-                            editable : true,
-                            emptyText : "Select Company",
-                            forceSelection : true,
-                            hiddenName : 'company_id',
-                            listWidth : 400,
-                            loadingText : "Searching...",
-                            minChars : 2,
-                            name : 'company_name',
-                            pageSize : 20,
-                            qtip : "Select Companies",
-                            queryParam : 'query[name]',
-                            selectOnFocus : true,
-                            tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
-                            triggerAction : 'all',
-                            typeAhead : true,
-                            valueField : 'id',
-                            width : 150,
-                            store : {
-                                xtype: 'Store',
-                                xns: Roo.data,
-                                listeners : {
-                                    beforeload : function (_self, o){
-                                        o.params = o.params || {};
-                                        // set more here
-                                    }
-                                },
-                                remoteSort : true,
-                                sortInfo : { direction : 'ASC', field: 'name' },
-                                proxy : {
-                                    xtype: 'HttpProxy',
-                                    xns: Roo.data,
-                                    method : 'GET',
-                                    url : baseURL + '/Roo/Companies.php'
-                                },
-                                reader : {
-                                    xtype: 'JsonReader',
-                                    xns: Roo.data,
-                                    id : 'id',
-                                    root : 'data',
-                                    totalProperty : 'total',
-                                    fields : [{"name":"id","type":"int"},{"name":"code","type":"string"}]
-                                }
-                            }
-                        },
-                        {
-                            xtype: 'Fill',
-                            xns: Roo.Toolbar
+                            text : "Save"
                         }
                     ]
                 },
@@ -301,6 +250,7 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         sortable : false,
                         width : 50,
                         renderer : function(v,x,r) {
+                             
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -394,7 +344,8 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         dataIndex : 'accessmask_P',
                         header : 'Print/Export',
                         width : 75,
-                        renderer : function(v) {  
+                        renderer : function(v,x,r) {  
+                            
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';