DataObjects/Cms_page.php
[Pman.Cms] / Pman.Tab.CmsBlog.js
index 9709e8b..506d177 100644 (file)
@@ -74,7 +74,7 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
      split : true,
      title : _this._strings['695e93e1d9db8283a9dd66782625065d'] /* Child Elements */,
      titlebar : true,
-     width : 400,
+     width : 500,
      xns : Roo,
      '|xns' : 'Roo'
     },
@@ -144,6 +144,12 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
              if(s.data.id * 1 < 1){
                  return;\r
              }
+             if (s.data.is_deleted) {
+                 _this.deleteBtn.setText("Un-delete");
+             } else {
+                 _this.deleteBtn.setText("Delete");
+             } 
+             
              
              _this.prepanel.el.dom.src =  baseURL + '/Cms/PageThumb/' +  s.data.id;
              
@@ -163,6 +169,13 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                  });
                  return;
              }*/
+             if (s.data.is_deleted) {
+                 Roo.MessageBox.alert("Undelete this", "You need to un-delete this item before you can edit it");
+                 return;
+             }
+             
+             
+             
              _this.dialog.show(s.data, function() {
                  _this.grid.footer.onClick('refresh');
              }); 
@@ -412,83 +425,72 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                     return;
                 }
                 
-                new Pman.Request({
-                    url : baseURL + '/Roo/cms_page.php',
-                    method : 'GET',
-                    params : {
-                        _id : sel.data.id
-                    }, 
-                    success : function(res) {
-                    
-                        Roo.log(res.data);
-                        
-                        var params = Roo.apply({}, res.data);
-                        
-                        params.id = 0;
-                        params._is_copy = 1;
-                        
-                        _this.dialog.show( params, function() {
-                            _this.grid.footer.onClick('first');
-                        });
-                    }
-                });
-                
-                return;
-                
-                
-                var ds = false;
-                if(_this.grid.selModel.getSelections().length == 1){
-                   ds = _this.grid.selModel.getSelected().data;
+                var editIt = function() {
+                    new Pman.Request({
+                        url : baseURL + '/Roo/cms_page.php',
+                        method : 'GET',
+                        params : {
+                            _id : sel.data.id
+                        }, 
+                        success : function(res) {
+                            
+                            var params = Roo.apply({}, res.data);
+                            
+                            params.id = 0;
+                            params._is_copy = 1;
+                            
+                            if(params.page_link.length){
+                                params.page_link = params.page_link + '-copy';
+                            }
+                            
+                            if(params.title.length){
+                                params.title = 'Copy of ' + params.title;
+                            }
+                            
+                            _this.dialog.show( params, function() {
+                                _this.grid.footer.onClick('first');
+                            });
+                        }
+                    });
                 }
                 
-                var page_type_id = 0;
-                var page_type_id_name = '';
-                var page_type_id_display_name = '';
-                
-                var sel = _this.category_grid.getSelectionModel().getSelected();
-                
-                if(!ds && sel && sel.data.pid * 1 > 0 && sel.data.type == 'page_type'){
-                    page_type_id = sel.data.pid;
-                    page_type_id_name = sel.data.name;
-                    page_type_id_display_name = sel.data.display_name;
+                var copyIt = function() {
                     
-                    if(sel.data.name == 'page'){
-                        page_type_id_display_name = 'Pages';
-                    }
-                    
-                    if(sel.data.name == 'blog'){
-                        page_type_id_display_name = 'Blog Entries';
-                    }
+                    new Pman.Request({
+                        url : baseURL + '/Roo/cms_page.php',
+                        method : 'POST',
+                        params : {
+                            _copy_of : sel.data.id
+                        }, 
+                        success : function(res) {
+                            
+                            Roo.log(res);
+                            
+                            _this.dialog.show( { id : res.data }, function() {
+                                _this.grid.footer.onClick('first');
+                            });
+                            
+                        }
+                    });
                     
                 }
-            
-                /*
-                var s = _this.page_type.selectedData;
                 
-                if(!ds){
-                    page_type_id = s.id;
-                    page_type_id_name = s.name;
-                    page_type_id_display_name = s.display_name;
-                    
-                    if(s.name == 'page'){
-                        page_type_id_display_name = 'Pages';
+                Roo.MessageBox.confirm(
+                    "Confirm", 
+                    "Are you wish to copy the child elements as well?", 
+                    function(res) {
+                        if(res != 'yes') {
+                            editIt();
+                            return;
+                        }
+                        
+                        copyIt();
+                        
+                        return;
                     }
-                }
-               */
-               
-                var q =   {
-                    id : 0,
-                    parent_id : ds ? ds.id : '',
-                    parent_id_title : ds ? ds.title : '',
-                    page_link : ds && !ds.is_element ? (ds.page_link + '/') : '',
-                    page_type_id : ds ? ds.page_type_id : page_type_id,
-                    page_type_id_name : ds ? ds.page_type_id_name : page_type_id_name,
-                    page_type_id_display_name : ds ? ds.page_type_id_display_name : page_type_id_display_name
-                };
-               
-               _this.dialog.show( q, function() {
-                 _this.grid.footer.onClick('first');
-               });
+                );
+                
+                
             }
           },
           xns : Roo.Toolbar,
@@ -518,42 +520,50 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                     return;
                 }
                 
-                /*
-                Roo.MessageBox.confirm("Confirm", 
-                    "Are you sure you want to delete this, it can not be recovered if you make a mistake!", 
-                    function(res) {
-                        if (res != 'yes') {
-                            return;
-                        }
-                        new Pman.Request({
-                            method : 'POST',
-                            url : baseURL + '/Roo/cms_page',
-                            params : {
-                                _delete : sel.data.id
-                            },
-                            success : function() { 
-                                _this.grid.footer.onClick('refresh');
+                if (!sel.data.is_deleted) {
+                    Roo.MessageBox.confirm("Confirm", 
+                        "Are you sure you want to delete this, - to un-delete, select 'Show Deleted' at bottom, select this item and press this button again", 
+                        function(res) {
+                            if (res != 'yes') {
+                                return;
                             }
-                        });
-                        
+                            new Pman.Request({
+                                method : 'POST',
+                                mask : "Deleting",
+                                url : baseURL + '/Roo/cms_page',
+                                params : {
+                                    id : sel.data.id,
+                                    is_deleted : 1  
+                                },
+                                success : function() { 
+                                    _this.grid.footer.onClick('refresh');
+                                }
+                            });
                             
-                    }
-                );
-                
-                */
+                                
+                        }
+                    );
+                    return;
+                }
+              
                 
                 new Pman.Request({
                     method : 'POST',
                     url : baseURL + '/Roo/cms_page',
+                    mask: 'Un-deleting',
                     params : {
                         id : sel.data.id,
-                        is_deleted : 1
+                        is_deleted : 0
                     },
                     success : function() { 
                         _this.grid.footer.onClick('refresh');
                     }
                 });
                 
+            },
+           render : function (_self)
+            {
+                _this.deleteBtn = this;
             }
           },
           xns : Roo.Toolbar,
@@ -600,6 +610,9 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
               if(sel.data.type == 'page_type'){
                   options.params._page_type_id = sel.data.pid;
               }
+              if (sel.data.page_type > 0 ) {
+                  options.params._page_type_id = sel.data.page_type;
+              }
               
               if(sel.data.type == 'category'){
                   options.params._category_id = sel.data.pid;
@@ -1072,7 +1085,11 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          dataIndex : 'is_draft',
          header : _this._strings['4d3d769b812b6faa6b76e1a8abaece2d'] /* Active */,
          renderer : function(v,x,r) {
-              
+             
+             if (r.data.is_deleted) {
+                 return 'DELETED';
+             }
+             
              var state = v> 0 ?  '' : '-checked';
          
              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
@@ -1093,7 +1110,8 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                  return;
              }
              
-             return String.format('<img src="{0}/Images/Thumb/{1}/{2}" width="{1}">', baseURL, size, v); 
+             return String.format('<img src="{0}/Images/Thumb/{1}/{2}" width="{1}" height="{3}">', 
+                     baseURL, size, v, Math.floor(size*0.6)); 
          },
          sortable : false,
          width : 75,
@@ -1356,8 +1374,8 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
        items  : [
         {
          xtype : 'GridPanel',
-         autoScroll : true,
-         background : false,
+         autoScroll : false,
+         background : true,
          fitContainer : true,
          fitToframe : true,
          region : 'center',
@@ -1453,6 +1471,14 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                 {
                     'name': 'type',
                     'type': 'string'
+                },
+                {
+                    'name': 'page_type',
+                    'type': 'int'
+                },
+                {
+                    'name': 'category_id_is_draft',
+                    'type': 'int'
                 }
             ],
             id : 'id',
@@ -1479,7 +1505,12 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
             xtype : 'ColumnModel',
             dataIndex : 'display_name',
             header : _this._strings['3adbdb3ac060038aa0e6e6c138ef9873'] /* Category */,
-            renderer : function(v,x,r) { 
+            renderer : function(v,x,r) 
+            { 
+                if(r.data.category_id_is_draft * 1 == 1){
+                    return String.format('<span style="text-decoration:line-through">{0}</span>', v ? v : ''); 
+                }
+                
                 return String.format('{0}', v ? v : '');
             },
             width : 200,
@@ -1757,7 +1788,8 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                   !sel || 
                   sel.data.id * 1< 1 || 
                   sel.data.page_type_id_name != 'page' ||
-                  sel.data.template_id * 1 < 1
+                  sel.data.template_id * 1 < 1 ||
+                  sel.data.has_child_element_type * 1 < 1
               ){
                   this.removeAll();
                   
@@ -1868,9 +1900,6 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
                  return '';
              }
              
-             Roo.log(v);
-             Roo.log(r.data);
-             
              return String.format('<img src="{0}/Images/Thumb/40/{1}" width="40">', baseURL, v); 
          },
          width : 75,