Pman.Dialog.AdminCoreEnum.bjs
[Pman.Admin] / Pman.Dialog.AdminCoreEnum.js
index fd1f218..b2a90cd 100644 (file)
@@ -30,7 +30,24 @@ Pman.Dialog.AdminCoreEnum = {
         this.dialog = Roo.factory({
             xtype: 'LayoutDialog',
             xns: Roo,
+            listeners : {
+                show : function (_self)
+                {
+                    var name_hidden = false;
+                
+                    if (typeof(_this.data._hide_name) != 'undefined') {
+                        name_hidden = true;
+                    
+                    }
+                    
+                  _this.grid.colModel.setHidden(1,name_hidden);
+                    _this.grid.footer.onClick('first');
+                }
+            },
+            closable : false,
             height : 400,
+            modal : true,
+            resizable : false,
             title : "Pulldown Options",
             width : 950,
             items : [
@@ -65,7 +82,7 @@ Pman.Dialog.AdminCoreEnum = {
                             },
                             afteredit : function (e)
                             {
-                               e.record.commit();     
+                             //  (function() {  e.record.commit(); }).defer(100);
                             },
                             cellclick : function (_self, rowIndex, columnIndex, e)
                             {
@@ -84,7 +101,18 @@ Pman.Dialog.AdminCoreEnum = {
                             },
                             beforeedit : function (e)
                             {
+                                Roo.log('before edit?');
+                                Roo.log(e);
+                                // force fill in of name first.. (Except when it's hidden)
+                                if (typeof(_this.data._hide_name) != 'undefined') { 
+                                    if(e.field == 'display_name' && e.record.data.is_system_enum*1 == 1){
+                                        return ;
+                                    }
+                             
+                                }
+                                
                                 if(e.field == 'name' && e.record.data.is_system_enum*1 == 1){
+                                    Roo.log("block name?");
                                     return false;
                                 }
                             }
@@ -98,10 +126,8 @@ Pman.Dialog.AdminCoreEnum = {
                             listeners : {
                                 beforeload : function (_self, options)
                                 {
-                                    if (!_this.etypeCombo) {
-                                        return false;
-                                    }
-                                    options.params.etype = _this.etypeCombo.getValue();
+                                
+                                    options.params.etype = _this.data.etype;
                                     if (!options.params.etype.length) {
                                         return false;
                                     }
@@ -111,14 +137,23 @@ Pman.Dialog.AdminCoreEnum = {
                                     if (operation != Roo.data.Record.COMMIT) {
                                         return;
                                     }
+                                    Roo.log(record);
+                                
+                                    if (typeof(_this.data._hide_name) != 'undefined') {
+                                        record.set('name', record.data.display_name);
+                                    }
+                                    if (!record.data.name.length) {
+                                        return;
+                                    }
+                                    
                                     // got commit..
                                     new Pman.Request({
                                         url : baseURL + '/Roo/Core_enum.php',
                                         method : 'POST',
                                         params : {
                                             id : record.data.id,
-                                            etype : _this.etypeCombo.getValue(),
-                                            name : record.data.name,
+                                            etype : _this.data.etype,
+                                            name :  record.data.name,
                                             active : record.data.active,
                                             seqid : record.data.seqid,
                                             display_name : record.data.display_name
@@ -192,7 +227,7 @@ Pman.Dialog.AdminCoreEnum = {
                                         {
                                             
                                             // if we do not have a selected type... - what should we show..?
-                                            var et = _this.etypeCombo.getValue();
+                                            var et = _this.data.etype;
                                             var ds = _this.grid.getDataSource();
                                             if (!et) {
                                                 Roo.MessageBox.alert("Error", "Select a pulldown");
@@ -209,7 +244,10 @@ Pman.Dialog.AdminCoreEnum = {
                                               });
                                              var r = ds.data.length;
                                             ds.insert(r  , add);  
-                                            _this.grid.startEditing(r, 1); // name... 
+                                            
+                                            
+                                            
+                                           // _this.grid.startEditing(r, 1); // name... 
                                         }
                                     },
                                     cls : 'x-btn-text-icon',
@@ -308,11 +346,34 @@ Pman.Dialog.AdminCoreEnum = {
                 {
                     xtype: 'Button',
                     xns: Roo,
-                    text : "OK"
+                    listeners : {
+                        click : function (_self, e)
+                        {
+                          _this.dialog.hide();
+                        }
+                    },
+                    text : "Cancel"
                 },
                 {
                     xtype: 'Button',
                     xns: Roo,
+                    listeners : {
+                        click : function (_self, e)
+                        {
+                            var sel = _this.grid.selModel.getSelectedCell();
+                            if (!sel && _this.callback) {
+                                Roo.MessageBox.alert("Error", "Select an item");
+                                return;
+                            }
+                            
+                        
+                            if (_this.callback) {
+                                var rec = _this.grid.ds.getAt(sel[0]);
+                               _this.callback(rec.data);
+                           }
+                           _this.dialog.hide();
+                        }
+                    },
                     text : "OK"
                 }
             ]