Pman.Tab.CmsProduct.js
[Pman.Cms] / Pman.Tab.CmsProductCategory.bjs
1 {
2     "id": "roo-file-88",
3     "name": "Pman.Tab.CmsProductCategory",
4     "parent": "Pman.Tab.CmsProductMgr",
5     "title": "Pman.Tab.CmsProductCategory",
6     "path": "/home/alan/gitlive/Pman.Cms/Pman.Tab.CmsProductCategory.bjs",
7     "items": [
8         {
9             "listeners": {
10                 "activate": "function (_self)\n{\n    \n    _this.panel = _self;\n}"
11             },
12             "autoScroll": true,
13             "fitToFrame": true,
14             "region": "west",
15             "title": "Category Tree",
16             "xtype": "TreePanel",
17             "|xns": "Roo",
18             "items": [
19                 {
20                     "|xns": "Roo",
21                     "xtype": "Toolbar",
22                     "*prop": "toolbar",
23                     "items": [
24                         {
25                             "text": "Manage Categories",
26                             "xtype": "Button",
27                             "|xns": "Roo.Toolbar",
28                             "items": [
29                                 {
30                                     "|xns": "Roo.menu",
31                                     "xtype": "Menu",
32                                     "*prop": "menu",
33                                     "items": [
34                                         {
35                                             "listeners": {
36                                                 "click": "function (_self, e)\n{\n\n    var sel = _this.panel.tree.getSelectionModel().getSelectedNode();\n    var id =  (!sel || isNaN(parseInt(sel.attributes.id))) ? 0 : sel.attributes.id;\n\n    if (!id) {\n        var sel = _this.panel.tree.root;\n    }\n    \n    \n    Pman.Dialog.CmsCategory.show( { id : 0 , parent_id : id, parent_id_title:  sel.text }, function(r)\n    {\n       if (r && r.title) {\n            if(sel.reload) {\n                sel.reload();\n                return;\n            }\n            // otherwise it's a treenode, and needs replacing...\n            var attr = sel.attributes;\n            attr.leaf = false;\n            var repnode = new Roo.tree.AsyncTreeNode(attr);\n            sel.parentNode.replaceChild(repnode, sel);\n            repnode.expand();\n       }\n    });\n}"
37                                             },
38                                             "text": "Add",
39                                             "xtype": "Item",
40                                             "|icon": "Roo.rootURL + 'images/default/tree/drop-add.gif'",
41                                             "|xns": "Roo.menu"
42                                         },
43                                         {
44                                             "listeners": {
45                                                 "click": "function (_self, e)\n{\n\n    var sel = _this.panel.tree.getSelectionModel().getSelectedNode();\n    if (!sel || isNaN(parseInt(sel.id))) {\n        Roo.MessageBox.alert(\"Error\", \"select a category to edit\");\n        return;\n    }\n     var ats = sel.attributes;\n\n     Pman.Dialog.CmsCategory.show( ats  , function(r)\n    {\n       if (r && r.title) {\n            sel.setText(r.display_order + '. ' + r.title);\n       }\n       sel.attributes = r;\n    });\n}"
46                                             },
47                                             "text": "Edit",
48                                             "xtype": "Item",
49                                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
50                                             "|xns": "Roo.menu"
51                                         },
52                                         {
53                                             "|xns": "Roo.menu",
54                                             "xtype": "Separator"
55                                         },
56                                         {
57                                             "listeners": {
58                                                 "click": "function (_self, e)\n{\n    var sel = _this.panel.tree.getSelectionModel().getSelectedNode();\n    if (!sel || isNaN(parseInt(sel.id))) {\n        Roo.MessageBox.alert(\"Error\", \"you can not delete that category\");\n        return;\n    }\n    var par = sel.parentNode;\n    Roo.MessageBox.confirm(\"Confirm\", \"Are you sure you want to delete that?\", function(b)\n    {\n       // console.log(b);\n        if (b!='yes') {\n            return;\n        }\n          Roo.Ajax.request({\n            method : 'GET',\n            params : {\n                _delete : sel.id\n            },\n            url : baseURL + '/Roo/Category.php',\n            success : function(r, o) { \n                par.removeChild(sel);\n                // do nothing..\n            },\n            failure : function () {\n                Roo.messageBox.alert('Error', 'Error updating categories');\n                _this.root.reload();\n            }\n        });\n        \n    });\n        \n    \n    \n    \n}"
59                                             },
60                                             "text": "Delete",
61                                             "xtype": "Item",
62                                             "|xns": "Roo.menu"
63                                         },
64                                         {
65                                             "|xns": "Roo.menu",
66                                             "xtype": "Separator"
67                                         },
68                                         {
69                                             "listeners": {
70                                                 "click": "function (_self, e)\n{\n   _this.panel.tree.root.reload();\n}"
71                                             },
72                                             "text": "Reload",
73                                             "xtype": "Item",
74                                             "|xns": "Roo.menu"
75                                         }
76                                     ]
77                                 }
78                             ]
79                         }
80                     ]
81                 },
82                 {
83                     "listeners": {
84                         "click": "function (node, e)\n{\n     (function() {\n        Pman.Tab.CmsProduct.grid.footer.onClick('first');\n    }).defer(200);\n}",
85                         "nodedragover": "function (dragOverEvent)\n{\n     //console.log('nodedragover');\n     // console.log(dragOverEvent.point);     \n     \n     if (dragOverEvent.data.grid) {\n        // comming from grid..\n         if (!dragOverEvent.data.selections.length) {\n             return false;\n         }\n       \n         if (isNaN(parseInt(dragOverEvent.target.id))) {\n            return false;\n         }\n\n         if (dragOverEvent.point !='append') {\n            return false; \n         }\n         return true;\n    }\n    // only allow append..\n     if (dragOverEvent.point !='append') {\n        return false; \n     }\n    \n    \n}",
86                         "beforenodedrop": "function (dropEvent)\n{\n    console.log('beforenodedrop');\n    console.log(dropEvent);\n    if (dropEvent.data.grid) {\n        // comming from grid..\n         if (!dropEvent.data.selections.length) {\n             return false;\n         }\n       \n         if (isNaN(parseInt(dropEvent.target.id))) {\n            return false;\n         }\n\n         if (dropEvent.point !='append') {\n            return false; \n         }\n         var ids = [];\n         Roo.each(dropEvent.data.selections, function(d) {\n            ids.push(d.data.id)\n         });\n         Roo.Ajax.request({\n            method : 'POST',\n            params : {\n                _ids : ids.join(','),\n                category_id : dropEvent.target.id\n            },\n            url : baseURL + '/Roo/Product.php',\n            success : function(r, o) { \n                dropEvent.data.grid.footer.onClick('refresh');\n            },\n            failure : function () {\n                Roo.messageBox.alert('Error', 'Error updating categories');\n            }\n        });\n         \n         \n         \n         return true;\n    }\n    \n \n    \n    \n    \n    \n    return true;\n}",
87                         "nodedrop": "function (dropEvent)\n{\n   // now handle node drop..\n    // if it fails, we just reload the tree..  a bit messy, but acceptable..\n    var _t = this;\n    \n    Roo.Ajax.request({\n        method : 'POST',\n        params : {\n            id : dropEvent.dropNode.id,\n            parent_id : dropEvent.target.id\n        },\n        url : baseURL + '/Roo/Category.php',\n        success : function(r, o) { \n            \n            // do nothing..\n        },\n        failure : function () {\n            Roo.messageBox.alert('Error', 'Error updating categories');\n            _this.root.reload()\n        }\n    });\n     \n}",
88                         "contextmenu": "function (node, e)\n{\n  this.selModel.select(node);\n  _this.panel.menu = Roo.factory(_this.panel.menu, Roo.menu);\n  Roo.log(node);\n  _this.panel.menu.show(node.ui.textNode);\n}"
89                     },
90                     "*prop": "tree",
91                     "ddGroup": "products",
92                     "enableDrag": true,
93                     "enableDrop": true,
94                     "xtype": "TreePanel",
95                     "|xns": "Roo.tree",
96                     "items": [
97                         {
98                             "text": "TOP LEVEL",
99                             "*prop": "root",
100                             "xtype": "AsyncTreeNode",
101                             "|xns": "Roo.tree"
102                         },
103                         {
104                             "listeners": {
105                                 "create": "function (This, attr)\n{\n    //Roo.log(attr);\n    attr.text =  attr.display_order + '. ' + attr.title;\n \n    attr.allowChildren = true;\n}"
106                             },
107                             "*prop": "loader",
108                             "queryParam": "parent_id",
109                             "requestMethod": "GET",
110                             "root": "data",
111                             "xtype": "TreeLoader",
112                             "|baseParams": "{ _tree: 1, 'sort': 'display_order,title', 'dir': 'ASC' }",
113                             "|dataUrl": "baseURL + '/Roo/Category.php'",
114                             "|xns": "Roo.tree"
115                         }
116                     ]
117                 },
118                 {
119                     "|xns": "Roo.menu",
120                     "xtype": "Menu",
121                     "*prop": "menu",
122                     "items": [
123                         {
124                             "listeners": {
125                                 "click": "function (_self, e)\n{\n\n    var sel = _this.panel.tree.getSelectionModel().getSelectedNode();\n    if (!sel || isNaN(parseInt(sel.id))) {\n        Roo.MessageBox.alert(\"Error\", \"select a category to edit\");\n        return;\n    }\n     var ats = sel.attributes;\n\n     Pman.Dialog.CmsCategory.show( ats  , function(r)\n    {\n       Roo.log(r);\n       if (r && r.title) {\n            sel.setText(r.display_order + '. ' + r.title);\n       }\n       sel.attributes = r;\n    });\n}"
126                             },
127                             "text": "Edit",
128                             "xtype": "Item",
129                             "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'",
130                             "|xns": "Roo.menu"
131                         }
132                     ]
133                 }
134             ]
135         }
136     ],
137     "permname": ""
138 }