Pman.Tab.AdminContactsGroupRight.bjs
[Pman.Admin] / Pman.Tab.AdminContactsGroupRight.js
index 1c79fb0..7188f50 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();
                              
                             
@@ -90,7 +94,7 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                             if (!o.params) {
                                 o.params = {}
                             }
-                            var s = Pman.Tab.Groups.grid.getSelectionModel().getSelections();
+                            var s = Pman.Tab.AdminContactsGroup.grid.getSelectionModel().getSelections();
                             if (!s.length) {
                                 o.params.group_id = -1;
                             } else {
@@ -135,12 +139,27 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         },
                         load : function (_self, records, options)
                         {
+                            _this.dataUpdate = {};
+                            var fmask = 'ADEPS'.split('');
+                            
                             Roo.each(records, function(e){
+                                _this.dataUpdate[e.id] = e.accessmask;
+                            
                                 var k = e.data.accessmask.split('');
-                                Roo.each(k, function(ee){
+                                var rm = e.data.FullMask.split('');
+                                
+                                Roo.each(full, function(ee){
+                                    if (rm.indexOf(ee) < 0) {
+                                        e.set('accessmask_'+ee, -1);          
+                                        return;
+                                    }
                                     
-                                    e.data['accessmask_'+ee] = 1;
+                                    e.set('accessmask_'+ee, (k.indexOf(ee) < 0) ? 0 : 1);
                                 });
+                                
+                                if(e.data.accessmask == e.data.FullMask){
+                                    e.set('accessmask_AA', 1);
+                                }
                             });
                         }
                     },
@@ -206,94 +225,35 @@ 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)
+                                click : function (_self, e)
                                 {
-                                    _this.searchBox = _self;
-                                },
-                                show : function (_self,e)
-                                {
-                                    if (e.getCharCode() != 13) {
-                                        return;
-                                    }
-                                    _this.grid.footer.onClick('first');
-                                },
-                                specialkey : 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 + '/GroupRights.php',
+                                        method :'POST',
+                                        params : {
+                                            dataUpdate : _this.dataUpdate,
+                                            dataAdd : _this.dataAdd
+                                        },
+                                        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"
                         }
                     ]
                 },
@@ -349,6 +309,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'Add',
                         width : 75,
                         renderer : function(v) {  
+                            if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -362,6 +325,9 @@ Pman.Tab.AdminContactsGroupRight = new Roo.XComponent({
                         header : 'Edit',
                         width : 75,
                         renderer : function(v) {  
+                           if (v < 0) {
+                                return '';
+                            }
                             var state = v> 0 ?  '-checked' : '';
                         
                             return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';