From 2b88bdbbf3efa4967f65d43cbf9a58ca004c7147 Mon Sep 17 00:00:00 2001 From: vChabot Date: Wed, 11 Jan 2012 09:56:40 +0000 Subject: [PATCH] // little improvements for category management with multishop --- controllers/admin/AdminShopController.php | 9 ++++++++- js/admin-categories-tree.js | 17 +++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/controllers/admin/AdminShopController.php b/controllers/admin/AdminShopController.php index 713d744b1..c582dbf82 100755 --- a/controllers/admin/AdminShopController.php +++ b/controllers/admin/AdminShopController.php @@ -312,11 +312,18 @@ class AdminShopControllerCore extends AdminController ) ); + if (Tools::isSubmit('id_shop')) + { + $shop = new Shop(Tools::getValue('id_shop')); + $parent = $shop->id_category; + } + else + $parent = $categories[0]['id_category']; $this->fields_form['input'][] = array( 'type' => 'categories_select', 'name' => 'categoryBox', 'label' => $this->l('Associated categories :'), - 'category_tree' => $this->initCategoriesAssociation($categories[0]['id_category']) + 'category_tree' => $this->initCategoriesAssociation($parent) ); $this->fields_form['input'][] = array( 'type' => 'radio', diff --git a/js/admin-categories-tree.js b/js/admin-categories-tree.js index 3b6a52413..db8411652 100755 --- a/js/admin-categories-tree.js +++ b/js/admin-categories-tree.js @@ -31,6 +31,7 @@ var interval = null; var intervalCheck = null; var id_tree = 0; var arrayCatToExpand = new Array(); +var id_category_root = 0; function buildTreeView() { @@ -46,10 +47,10 @@ function buildTreeView() } } }); - - $('#categories-treeview li#1 span').trigger('click'); - $('#categories-treeview li#1').children('div').remove(); - $('#categories-treeview li#1'). + id_category_root = $('#categories-treeview li:first').attr('id'); + $('#categories-treeview li#'+id_category_root+' span').trigger('click'); + $('#categories-treeview li#'+id_category_root).children('div').remove(); + $('#categories-treeview li#'+id_category_root). removeClass('collapsable lastCollapsable'). addClass('last static'); @@ -100,7 +101,7 @@ function closeChildrenCategories(element) arrayLevel[level].push($(this).attr('id')); }); - for(i=arrayLevel.length-1;i!=0;i--) + for(i=arrayLevel.length-1;i>=0;i--) if (arrayLevel[i] != undefined) for(j=0;j