1 //<script type="text/javascript">
3 // Auto generated file - created by app.Builder.js- do not edit directly (at present!)
7 // register the module first
8 Pman.on('beforeload', function()
11 modKey : '001-Pman.Tab.CmsProductCategory',
12 module : Pman.Tab.CmsProductCategory,
14 parent : Pman.Tab.CmsProductMgr,
15 name : "Pman.Tab.CmsProductCategory",
21 Pman.Tab.CmsProductCategory = new Roo.util.Observable({
27 add : function(parentLayout, region)
31 this.parentLayout = parentLayout;
33 this.panel = parentLayout.addxtype({
37 activate : function (_self)
46 title : "Category Tree",
54 text : "Manage Categories",
63 click : function (_self, e)
66 var sel = _this.panel.tree.getSelectionModel().getSelectedNode();
67 var id = (!sel || isNaN(parseInt(sel.attributes.id))) ? 0 : sel.attributes.id;
70 var sel = _this.panel.tree.root;
74 Pman.Dialog.CmsCategory.show( { id : 0 , parent_id : id, parent_id_title: sel.text }, function(r)
81 // otherwise it's a treenode, and needs replacing...
82 var attr = sel.attributes;
84 var repnode = new Roo.tree.AsyncTreeNode(attr);
85 sel.parentNode.replaceChild(repnode, sel);
92 icon : Roo.rootURL + 'images/default/tree/drop-add.gif'
98 click : function (_self, e)
101 var sel = _this.panel.tree.getSelectionModel().getSelectedNode();
102 if (!sel || isNaN(parseInt(sel.id))) {
103 Roo.MessageBox.alert("Error", "select a category to edit");
106 var ats = sel.attributes;
108 Pman.Dialog.CmsCategory.show( ats , function(r)
111 sel.setText(r.display_order + '. ' + r.title);
118 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
128 click : function (_self, e)
130 var sel = _this.panel.tree.getSelectionModel().getSelectedNode();
131 if (!sel || isNaN(parseInt(sel.id))) {
132 Roo.MessageBox.alert("Error", "you can not delete that category");
135 var par = sel.parentNode;
136 Roo.MessageBox.confirm("Confirm", "Are you sure you want to delete that?", function(b)
147 url : baseURL + '/Roo/Category.php',
148 success : function(r, o) {
149 par.removeChild(sel);
152 failure : function () {
153 Roo.messageBox.alert('Error', 'Error updating categories');
175 click : function (_self, e)
177 _this.panel.tree.root.reload();
191 click : function (node, e)
194 Pman.Tab.CmsProduct.grid.footer.onClick('first');
197 nodedragover : function (dragOverEvent)
199 //console.log('nodedragover');
200 // console.log(dragOverEvent.point);
202 if (dragOverEvent.data.grid) {
203 // comming from grid..
204 if (!dragOverEvent.data.selections.length) {
208 if (isNaN(parseInt(dragOverEvent.target.id))) {
212 if (dragOverEvent.point !='append') {
217 // only allow append..
218 if (dragOverEvent.point !='append') {
224 beforenodedrop : function (dropEvent)
226 console.log('beforenodedrop');
227 console.log(dropEvent);
228 if (dropEvent.data.grid) {
229 // comming from grid..
230 if (!dropEvent.data.selections.length) {
234 if (isNaN(parseInt(dropEvent.target.id))) {
238 if (dropEvent.point !='append') {
242 Roo.each(dropEvent.data.selections, function(d) {
248 _ids : ids.join(','),
249 category_id : dropEvent.target.id
251 url : baseURL + '/Roo/Product.php',
252 success : function(r, o) {
253 dropEvent.data.grid.footer.onClick('refresh');
255 failure : function () {
256 Roo.messageBox.alert('Error', 'Error updating categories');
272 nodedrop : function (dropEvent)
274 // now handle node drop..
275 // if it fails, we just reload the tree.. a bit messy, but acceptable..
281 id : dropEvent.dropNode.id,
282 parent_id : dropEvent.target.id
284 url : baseURL + '/Roo/Category.php',
285 success : function(r, o) {
289 failure : function () {
290 Roo.messageBox.alert('Error', 'Error updating categories');
296 contextmenu : function (node, e)
298 this.selModel.select(node);
299 _this.panel.menu = Roo.factory(_this.panel.menu, Roo.menu);
301 _this.panel.menu.show(node.ui.textNode);
304 ddGroup : 'products',
308 xtype: 'AsyncTreeNode',
316 create : function (This, attr)
319 attr.text = attr.display_order + '. ' + attr.title;
321 attr.allowChildren = true;
324 queryParam : 'parent_id',
325 requestMethod : 'GET',
327 baseParams : { _tree: 1, 'sort': 'display_order,title', 'dir': 'ASC' },
328 dataUrl : baseURL + '/Roo/Category.php'
339 click : function (_self, e)
342 var sel = _this.panel.tree.getSelectionModel().getSelectedNode();
343 if (!sel || isNaN(parseInt(sel.id))) {
344 Roo.MessageBox.alert("Error", "select a category to edit");
347 var ats = sel.attributes;
349 Pman.Dialog.CmsCategory.show( ats , function(r)
353 sel.setText(r.display_order + '. ' + r.title);
360 icon : Roo.rootURL + 'images/default/tree/leaf.gif'
365 this.layout = this.panel.layout;