Pman.Dialog.CmsBlog.bjs
[Pman.Cms] / Pman.Dialog.CmsCategory.js
index 96b3464..ee7908f 100644 (file)
@@ -49,9 +49,6 @@ Pman.Dialog.CmsCategory = {
                         {
                             xtype: 'Form',
                             xns: Roo.form,
-                            style : 'margin: 5px',
-                            url : baseURL + '/Roo/Category.php',
-                            method : 'POST',
                             listeners : {
                                 actionfailed : function (_self, action)
                                 {
@@ -72,66 +69,105 @@ Pman.Dialog.CmsCategory = {
                                         _this.form.reset();
                                         return;
                                     }
-                                    if (action.type = 'setdata') {
+                                     if (action.type == 'setdata') {
+                                         if (_this.data.id) {
+                                           _this.dialog.el.mask("Loading");
+                                           this.load({ method: 'GET', params: { '_id' : _this.data.id }});
+                                            return;
+                                       }
+                                      _this.grid.getDataSource().load();
+                                       return;
+                                    }
+                                    if (action.type == 'load') {
                                        _this.grid.getDataSource().load();
-                                    
+                                        _this.dialog.el.unmask();
+                                        return;
                                     }
+                                    
+                                  
+                                    
                                 },
                                 rendered : function (_self)
                                 {
                                     _this.form = _self;
                                 }
                             },
+                            method : 'POST',
+                            style : 'margin: 5px',
+                            url : baseURL + '/Roo/Category.php',
                             items : [
                                 {
-                                    xtype: 'ComboBox',
+                                    xtype: 'TextField',
                                     xns: Roo.form,
-                                    fieldLabel : 'Parent ',
+                                    fieldLabel : 'Parent',
                                     name : 'parent_id_title',
-                                    hiddenName : 'parent_id',
-                                    qtip : "Select Parent ",
-                                    emptyText : "Select Parent ",
-                                    selectOnFocus : true,
+                                    readOnly : true,
+                                    width : 450
+                                },
+                                {
+                                    xtype: 'NumberField',
+                                    xns: Roo.form,
+                                    decimalPrecision : 0,
+                                    fieldLabel : 'Order (1 first)',
+                                    name : 'display_order',
+                                    width : 50
+                                },
+                                {
+                                    xtype: 'TextField',
+                                    xns: Roo.form,
+                                    name : 'title',
+                                    fieldLabel : 'Title',
+                                    width : 450
+                                },
+                                {
+                                    xtype: 'ComboBox',
+                                    xns: Roo.form,
                                     allowBlank : true,
-                                    width : 300,
-                                    listWidth : 400,
-                                    editable : false,
-                                    displayField : 'title',
-                                    valueField : 'id',
-                                    typeAhead : true,
+                                    displayField : 'name',
+                                    editable : 'false',
+                                    emptyText : "Select Type",
+                                    fieldLabel : 'Type',
                                     forceSelection : true,
-                                    triggerAction : 'all',
-                                    tpl : '<div class="x-grid-cell-text x-btn button"><b>{title}</b> </div>',
-                                    queryParam : 'query[title]',
+                                    hiddenName : 'category_type_id',
+                                    listWidth : 200,
                                     loadingText : "Searching...",
                                     minChars : 2,
+                                    name : 'category_type_id_name',
                                     pageSize : 20,
+                                    qtip : "Select cms_category_type",
+                                    selectOnFocus : true,
+                                    tpl : '<div class="x-grid-cell-text x-btn button"><b>{name}</b> </div>',
+                                    triggerAction : 'all',
+                                    typeAhead : true,
+                                    valueField : 'id',
+                                    width : 200,
                                     store : {
                                         xtype: 'Store',
                                         xns: Roo.data,
-                                        reader : Pman.Readers.Category,
+                                        remoteSort : true,
+                                        sortInfo : { direction : 'ASC', field: 'id' },
+                                        listeners : {
+                                            beforeload : function (_self, o){
+                                                o.params = o.params || {};
+                                                // set more here
+                                            }
+                                        },
                                         proxy : {
                                             xtype: 'HttpProxy',
                                             xns: Roo.data,
-                                            url : baseURL + '/Roo/Category.php',
-                                            method : 'GET'
+                                            method : 'GET',
+                                            url : baseURL + '/Roo/cms_category_type.php'
+                                        },
+                                        reader : {
+                                            xtype: 'JsonReader',
+                                            xns: Roo.data,
+                                            id : 'id',
+                                            root : 'data',
+                                            totalProperty : 'total',
+                                            fields : [{"name":"id","type":"int"},{"name":"name","type":"string"}]
                                         }
                                     }
                                 },
-                                {
-                                    xtype: 'TextField',
-                                    xns: Roo.form,
-                                    name : 'title',
-                                    fieldLabel : 'Title',
-                                    width : 450
-                                },
-                                {
-                                    xtype: 'TextField',
-                                    xns: Roo.form,
-                                    fieldLabel : 'Colour',
-                                    name : 'short_name',
-                                    width : 100
-                                },
                                 {
                                     xtype: 'Checkbox',
                                     xns: Roo.form,
@@ -139,20 +175,9 @@ Pman.Dialog.CmsCategory = {
                                     name : 'visible'
                                 },
                                 {
-                                    xtype: 'Column',
+                                    xtype: 'Hidden',
                                     xns: Roo.form,
-                                    width : '550',
-                                    labelAlign : 'top',
-                                    items : [
-                                        {
-                                            xtype: 'HtmlEditor',
-                                            xns: Roo.form,
-                                            fieldLabel : 'Page text',
-                                            height : 450,
-                                            name : 'page_text',
-                                            width : 550
-                                        }
-                                    ]
+                                    name : 'parent_id'
                                 },
                                 {
                                     xtype: 'Hidden',
@@ -282,9 +307,9 @@ Pman.Dialog.CmsCategory = {
                             {
                                 xtype: 'ColumnModel',
                                 xns: Roo.grid,
+                                dataIndex : 'id',
                                 header : '',
                                 width : 110,
-                                dataIndex : 'id',
                                 renderer : function(v,x,r) { return String.format('<img src="{0}/Images/Thumb/100/{1}/{2}">', baseURL, v, r.data.filename); }
                             },
                             {