{ "id": "roo-file-88", "name": "Pman.Tab.CmsProductCategory", "parent": "Pman.Tab.CmsProductMgr", "title": "Pman.Tab.CmsProductCategory", "path": "/home/alan/gitlive/Pman.Cms/Pman.Tab.CmsProductCategory.bjs", "items": [ { "listeners": { "activate": "function (_self)\n{\n \n _this.panel = _self;\n}" }, "autoScroll": true, "fitToFrame": true, "region": "west", "title": "Category Tree", "xtype": "TreePanel", "|xns": "Roo", "items": [ { "|xns": "Roo", "xtype": "Toolbar", "*prop": "toolbar", "items": [ { "text": "Manage Categories", "xtype": "Button", "|xns": "Roo.Toolbar", "items": [ { "|xns": "Roo.menu", "xtype": "Menu", "*prop": "menu", "items": [ { "listeners": { "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}" }, "text": "Add", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/tree/drop-add.gif'", "|xns": "Roo.menu" }, { "listeners": { "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}" }, "text": "Edit", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.menu" }, { "|xns": "Roo.menu", "xtype": "Separator" }, { "listeners": { "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}" }, "text": "Delete", "xtype": "Item", "|xns": "Roo.menu" }, { "|xns": "Roo.menu", "xtype": "Separator" }, { "listeners": { "click": "function (_self, e)\n{\n _this.panel.tree.root.reload();\n}" }, "text": "Reload", "xtype": "Item", "|xns": "Roo.menu" } ] } ] } ] }, { "listeners": { "click": "function (node, e)\n{\n (function() {\n Pman.Tab.CmsProduct.grid.footer.onClick('first');\n }).defer(200);\n}", "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}", "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}", "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}", "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}" }, "*prop": "tree", "ddGroup": "products", "enableDrag": true, "enableDrop": true, "xtype": "TreePanel", "|xns": "Roo.tree", "items": [ { "text": "TOP LEVEL", "*prop": "root", "xtype": "AsyncTreeNode", "|xns": "Roo.tree" }, { "listeners": { "create": "function (This, attr)\n{\n //Roo.log(attr);\n attr.text = attr.display_order + '. ' + attr.title;\n \n attr.allowChildren = true;\n}" }, "*prop": "loader", "queryParam": "parent_id", "requestMethod": "GET", "root": "data", "xtype": "TreeLoader", "|baseParams": "{ _tree: 1, 'sort': 'display_order,title', 'dir': 'ASC' }", "|dataUrl": "baseURL + '/Roo/Category.php'", "|xns": "Roo.tree" } ] }, { "|xns": "Roo.menu", "xtype": "Menu", "*prop": "menu", "items": [ { "listeners": { "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}" }, "text": "Edit", "xtype": "Item", "|icon": "Roo.rootURL + 'images/default/tree/leaf.gif'", "|xns": "Roo.menu" } ] } ] } ], "permname": "" }