Pman.Dialog.AdminCoreEnum.bjs
[Pman.Admin] / Pman.Dialog.AdminCoreEnum.js
index 82db5ed..6033470 100644 (file)
@@ -30,6 +30,20 @@ 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');
+                }
+            },
             height : 400,
             title : "Pulldown Options",
             width : 950,
@@ -98,10 +112,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,13 +123,18 @@ Pman.Dialog.AdminCoreEnum = {
                                     if (operation != Roo.data.Record.COMMIT) {
                                         return;
                                     }
+                                    
+                                    var name = record.data.name;
+                                    if (typeof(_this.data._hide_name) != 'undefined') {
+                                        name =  record.data.display_name;
+                                    }
                                     // got commit..
                                     new Pman.Request({
                                         url : baseURL + '/Roo/Core_enum.php',
                                         method : 'POST',
                                         params : {
                                             id : record.data.id,
-                                            etype : _this.etypeCombo.getValue(),
+                                            etype : _this.data.etype,
                                             name : record.data.name,
                                             active : record.data.active,
                                             seqid : record.data.seqid,
@@ -178,92 +195,12 @@ Pman.Dialog.AdminCoreEnum = {
                             pageSize : 25,
                             displayInfo : true,
                             displayMsg : "Displaying core_enum{0} - {1} of {2}",
-                            emptyMsg : "No core_enum found",
-                            items : [
-                                {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    listeners : {
-                                        click : function (_self, e)
-                                        {
-                                            new Pman.Download({
-                                                grid : _this.grid
-                                            });
-                                            Roo.MessageBox.alert("Downloading", "File is downloading");
-                                        }
-                                    },
-                                    text : "Download"
-                                }
-                            ]
+                            emptyMsg : "No core_enum found"
                         },
                         toolbar : {
                             xtype: 'Toolbar',
                             xns: Roo,
                             items : [
-                                {
-                                    xtype: 'TextItem',
-                                    xns: Roo.Toolbar,
-                                    text : "Pulldown Name:"
-                                },
-                                {
-                                    xtype: 'ComboBox',
-                                    xns: Roo.form,
-                                    listeners : {
-                                        render : function (_self)
-                                        {
-                                            _this.etypeCombo = _self;
-                                        },
-                                        select : function (combo, record, index)
-                                        {
-                                            _this.grid.footer.onClick('first');
-                                        }
-                                    },
-                                    alwaysQuery : true,
-                                    displayField : 'name',
-                                    editable : 'false',
-                                    emptyText : "Select pulldown",
-                                    fieldLabel : 'core_enum',
-                                    forceSelection : true,
-                                    listWidth : 400,
-                                    loadingText : "Searching...",
-                                    minChars : 2,
-                                    pageSize : 50,
-                                    qtip : "Select type",
-                                    queryParam : 'query[name]',
-                                    selectOnFocus : true,
-                                    tpl : '<div class="x-grid-cell-text x-btn button"><b>{display_name}</b> - {name} </div>',
-                                    triggerAction : 'all',
-                                    typeAhead : false,
-                                    valueField : 'name',
-                                    width : 300,
-                                    store : {
-                                        xtype: 'Store',
-                                        xns: Roo.data,
-                                        listeners : {
-                                            beforeload : function (_self, o){
-                                                o.params = o.params || {};
-                                                // set more here
-                                                o.params['query[empty_etype]'] = 1; 
-                                            }
-                                        },
-                                        remoteSort : true,
-                                        sortInfo : { direction : 'ASC', field: 'display_name' },
-                                        proxy : {
-                                            xtype: 'HttpProxy',
-                                            xns: Roo.data,
-                                            method : 'GET',
-                                            url : baseURL + '/Roo/core_enum.php'
-                                        },
-                                        reader : {
-                                            xtype: 'JsonReader',
-                                            xns: Roo.data,
-                                            id : 'id',
-                                            root : 'data',
-                                            totalProperty : 'total',
-                                            fields : [{"name":"id","type":"int"},{"name":"etype","type":"string"}]
-                                        }
-                                    }
-                                },
                                 {
                                     xtype: 'Button',
                                     xns: Roo.Toolbar,
@@ -272,7 +209,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");
@@ -296,83 +233,9 @@ Pman.Dialog.AdminCoreEnum = {
                                     text : "Add Value",
                                     icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
                                 },
-                                {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    listeners : {
-                                        click : function()
-                                        {
-                                            
-                                            // if we do not have a selected type... - what should we show..?
-                                            var et = _this.etypeCombo.getValue();
-                                            
-                                            if (!et) {
-                                                Roo.MessageBox.alert("Error", "Select a pulldown");
-                                                return;
-                                            }
-                                            var sc = _this.grid.getSelectionModel().getSelectedCell();
-                                            Roo.log(sc);
-                                            var ds = _this.grid.ds.getAt(sc[0]);
-                                            if (!ds) {
-                                                Roo.MessageBox.alert("Error", "Select enum");
-                                                return;
-                                            }
-                                            
-                                            Roo.log(ds);
-                                            Pman.Dialog.AdminEnumImages.show({onid:ds.data.id}, function(){
-                                                _this.grid.footer.onClick('first');
-                                            });
-                                            
-                                        }
-                                    },
-                                    cls : 'x-btn-text-icon',
-                                    text : "Add Images",
-                                    icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
-                                },
                                 {
                                     xtype: 'Fill',
                                     xns: Roo.Toolbar
-                                },
-                                {
-                                    xtype: 'Button',
-                                    xns: Roo.Toolbar,
-                                    listeners : {
-                                        click : function()
-                                        {
-                                            
-                                            Roo.MessageBox.prompt ("Create a new Enum type",
-                                                "Enter the name for a new enum type, " + 
-                                                "this is only relivant if you  know how it is going to be used",
-                                                function(btn,txt) {
-                                                    if (btn != 'ok') {
-                                                        return; 
-                                                    }
-                                                    new Pman.Request({
-                                                        url : baseURL + '/Roo/Core_enum.php',
-                                                        method : 'POST',
-                                                        params : {
-                                                            etype : '',
-                                                            name : txt,
-                                                            active : 1
-                                                        }, 
-                                                        success : function() {
-                                                            Roo.MessageBox.alert("Created", "You can now select it from the type list on the left");
-                                                        }
-                                                    });
-                                                            
-                                                    
-                                                     
-                                                     
-                                                }
-                                            ); 
-                                                 
-                                                 
-                                        
-                                        }
-                                    },
-                                    cls : 'x-btn-text-icon',
-                                    text : "Add new pulldown list",
-                                    icon : Roo.rootURL + 'images/default/dd/drop-add.gif'
                                 }
                             ]
                         },
@@ -385,14 +248,6 @@ Pman.Dialog.AdminCoreEnum = {
                                 width : 75,
                                 renderer : function(v) { return String.format('{0}', v); }
                             },
-                            {
-                                xtype: 'ColumnModel',
-                                xns: Roo.grid,
-                                dataIndex : 'images_id_id',
-                                header : 'Image',
-                                width : 75,
-                                renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/25/{1}/{2}" width="25" height="25">', baseURL, v, r.data.images_id_filename); }
-                            },
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
@@ -469,7 +324,34 @@ Pman.Dialog.AdminCoreEnum = {
             buttons : [
                 {
                     xtype: 'Button',
-                    xns: Roo
+                    xns: Roo,
+                    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) {
+                                Roo.MesssageBox.alert("Error", "Select an item");
+                                return;
+                            }
+                            var rec = _this.grid.getAt(sel[0]);
+                            if (_this.callback) {
+                               _this.callback(rec.data);
+                           }
+                           _this.dialog.hide();
+                        }
+                    },
+                    text : "OK"
                 }
             ]
         });