Pman.Dialog.CmsBlog.bjs
[Pman.Cms] / Pman.Tab.CmsBlog.js
index 7bc27c3..b283ee0 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'
     },
@@ -110,61 +110,17 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
        xtype : 'Grid',
        autoExpandColumn : 'title',
        loadMask : true,
-       trigger_link_click : function(g, rowIndex, columnIndex, e) 
-       { 
-           e.preventDefault();
-           
-           var target = e.getTarget();
-           
-           if(target.nodeName.toLowerCase() != 'a'){
-               return;
-           }
-           
-           var rec = _this.grid.ds.getAt(rowIndex);
-           
-           var el = Roo.get(target);
-           
-           var element_id = el.attr('data-element-id');
-           
-           var element_id_name = el.attr('data-element-name');
-           var page_type_id = el.attr('data-page-type-id');
-           var parent_id = el.attr('data-parent-id');
-           var parent_id_title = el.attr('data-parent-title');
-           
-           var params =   {
-               id : 0,
-               element_id : element_id,
-               element_id_name : element_id_name,
-               page_type_id : page_type_id,
-               page_type_id_name : 'element',
-               page_type_id_display_name : 'Elements',
-               parent_id : parent_id,
-               parent_id_title : parent_id_title
-           };
-          
-           _this.dialog.show( params, function() {
-               _this.grid.footer.onClick('first');
-           });
-           
-           return;
-           
-       },
        listeners : {
         cellclick : function (g, ri,ci, e)\r
          {
              var h = this.colModel.getDataIndex(ci);
-             
-             if(h == 'title'){
-                 _this.grid.trigger_link_click(g, ri, ci, e);
-                 return;
-             }
              \r
              if (h != 'is_draft') {\r
                  return;\r
              }\r
              var rec = g.ds.getAt(ri);
              
-             if(rec.data.is_system_page*1 == 1){
+             if(rec.data.is_system_page * 1 == 1){
                  Roo.MessageBox.alert('Error', 'You cannot de-active the system page');
                  return;
              }\r
@@ -185,9 +141,15 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          
              _this.prepanel.el.dom.innerHTML = '';
              
-             if(s.data.id *1 < 1){
+             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;
              
@@ -198,7 +160,6 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          },
         rowdblclick : function (_self, rowIndex, e)
          {
-         
              var s = this.dataSource.getAt(rowIndex);
              /*  
              if (s.data.language.length) {
@@ -208,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');
              }); 
@@ -457,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;
-                    
-                    if(sel.data.name == 'page'){
-                        page_type_id_display_name = 'Pages';
-                    }
+                var copyIt = function() {
                     
-                    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,
@@ -563,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,
@@ -645,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;
@@ -1117,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 + '"/>';
@@ -1138,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,
@@ -1401,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',
@@ -1498,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',
@@ -1524,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,
@@ -1710,29 +1696,40 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          {
           xtype : 'Button',
           cls : 'x-btn-text-icon',
-          icon : rootURL + '/Pman/templates/images/trash.gif',
-          text : _this._strings['f2a6c498fb90ee345d997f888fce3b18'] /* Delete */,
+          icon : Roo.rootURL + 'images/default/dd/drop-add.gif',
+          text : _this._strings['ec211f7c20af43e742bf2570c3cb84f9'] /* Add */,
           listeners : {
            click : function()
             {
-                var sel = _this.child_element_grid.selModel.getSelected();
+                var s = _this.grid.selModel.getSelected();
                 
-                if(!sel || sel.data.id * 1< 1){
-                    Roo.MessageBox.alert("Error", "Select page to delete");
+                if(!s || s.data.id * 1 < 1 || s.data.template_id * 1 < 1){
+                    Roo.MessageBox.alert('Error', 'Please select a page');
                     return;
                 }
                 
-                new Pman.Request({
-                    method : 'POST',
-                    url : baseURL + '/Roo/cms_page',
-                    params : {
-                        id : sel.data.id,
-                        is_deleted : 1
-                    },
-                    success : function() { 
-                        _this.child_element_grid.footer.onClick('refresh');
-                    }
+                Pman.Dialog.AddChildElementToPage.show({
+                    template_id : s.data.template_id
+                }, function(res) {
+                    
+                    var params =   {
+                        id : 0,
+                        element_id : res.element_id,
+                        element_id_name : res.element_id_name,
+                        page_type_id : s.data.element_page_type_id,
+                        page_type_id_name : 'element',
+                        page_type_id_display_name : 'Elements',
+                        parent_id : s.data.id,
+                        parent_id_title : s.data.title
+                    };
+                   
+                    _this.dialog.show( params, function() {
+                        _this.grid.footer.onClick('first');
+                    });
+                    
                 });
+                
+                
             }
           },
           xns : Roo.Toolbar,
@@ -1791,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();
                   
@@ -1872,6 +1870,14 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
              {
                  'name': 'translation_type',
                  'type': 'string'
+             },
+             {
+                 'name': 'primary_image_id',
+                 'type': 'int'
+             },
+             {
+                 'name': 'template_id_template',
+                 'type': 'string'
              }
          ],
          id : 'id',
@@ -1888,6 +1894,22 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
         '|xns' : 'Roo.grid'
        },
        cm : [
+        {
+         xtype : 'ColumnModel',
+         dataIndex : 'primary_image_id',
+         header : _this._strings['be53a0541a6d36f6ecb879fa2c584b08'] /* Image */,
+         renderer : function(v,x,r) 
+         { 
+             if(!v){
+                 return '';
+             }
+             
+             return String.format('<img src="{0}/Images/Thumb/40/{1}" width="40">', baseURL, v); 
+         },
+         width : 50,
+         xns : Roo.grid,
+         '|xns' : 'Roo.grid'
+        },
         {
          xtype : 'ColumnModel',
          dataIndex : 'is_draft',
@@ -1898,7 +1920,7 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          
              return '<img class="x-grid-check-icon' + state + '" src="' + Roo.BLANK_IMAGE_URL + '"/>';
          },
-         width : 50,
+         width : 40,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
@@ -1908,9 +1930,20 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
          header : _this._strings['ce5bf551379459c1c61d2a204061c455'] /* Location */,
          renderer : function(v,x,r) { 
          
-             var fmt = (r.data.is_deleted ? '<s>{0}</s>' : '{0}');
+             var fmt = '';
+             
+             if(r.data.template_id_template.length){
+                 
+                 fmt = (r.data.is_deleted ? '<s>{0}<br/>{1}</s>' : '{0}<br/>{1}');
+                 
+                 return String.format(fmt, v, r.data.template_id_template);
+             }
+             
+             fmt = (r.data.is_deleted ? '<s>{0}</s>' : '{0}');
              
              return String.format( fmt, v);
+             
+             
           },
          width : 100,
          xns : Roo.grid,
@@ -1954,7 +1987,7 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
              return ret.join("<br/>");
              
          },
-         width : 100,
+         width : 75,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         },
@@ -1988,7 +2021,7 @@ Pman.Tab.CmsBlog = new Roo.XComponent({
              return v *1;
              
          },
-         width : 50,
+         width : 30,
          xns : Roo.grid,
          '|xns' : 'Roo.grid'
         }