// little improvements for category management with multishop

This commit is contained in:
vChabot
2012-01-11 09:56:40 +00:00
parent 74ba9e82b4
commit 2b88bdbbf3
2 changed files with 17 additions and 9 deletions
+8 -1
View File
@@ -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( $this->fields_form['input'][] = array(
'type' => 'categories_select', 'type' => 'categories_select',
'name' => 'categoryBox', 'name' => 'categoryBox',
'label' => $this->l('Associated categories :'), 'label' => $this->l('Associated categories :'),
'category_tree' => $this->initCategoriesAssociation($categories[0]['id_category']) 'category_tree' => $this->initCategoriesAssociation($parent)
); );
$this->fields_form['input'][] = array( $this->fields_form['input'][] = array(
'type' => 'radio', 'type' => 'radio',
+9 -8
View File
@@ -31,6 +31,7 @@ var interval = null;
var intervalCheck = null; var intervalCheck = null;
var id_tree = 0; var id_tree = 0;
var arrayCatToExpand = new Array(); var arrayCatToExpand = new Array();
var id_category_root = 0;
function buildTreeView() function buildTreeView()
{ {
@@ -46,10 +47,10 @@ function buildTreeView()
} }
} }
}); });
id_category_root = $('#categories-treeview li:first').attr('id');
$('#categories-treeview li#1 span').trigger('click'); $('#categories-treeview li#'+id_category_root+' span').trigger('click');
$('#categories-treeview li#1').children('div').remove(); $('#categories-treeview li#'+id_category_root).children('div').remove();
$('#categories-treeview li#1'). $('#categories-treeview li#'+id_category_root).
removeClass('collapsable lastCollapsable'). removeClass('collapsable lastCollapsable').
addClass('last static'); addClass('last static');
@@ -100,7 +101,7 @@ function closeChildrenCategories(element)
arrayLevel[level].push($(this).attr('id')); 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) if (arrayLevel[i] != undefined)
for(j=0;j<arrayLevel[i].length;j++) for(j=0;j<arrayLevel[i].length;j++)
{ {
@@ -134,8 +135,8 @@ function expandAllCategories()
if (!needExpandAllCategories()) if (!needExpandAllCategories())
return; return;
// force to open main category // force to open main category
if ($('li#1').is('.expandable')) if ($('li#'+id_category_root).is('.expandable'))
$('li#1').children('span.folder').trigger('click'); $('li#'+id_category_root).children('span.folder').trigger('click');
readyToExpand = true; readyToExpand = true;
if (setCategoryToExpand()) if (setCategoryToExpand())
interval = setInterval(openCategory, 10); interval = setInterval(openCategory, 10);
@@ -179,7 +180,7 @@ function openCategory()
function collapseAllCategories() function collapseAllCategories()
{ {
closeChildrenCategories($('li#1')); closeChildrenCategories($('li#'+id_category_root));
} }
function checkAllCategories() function checkAllCategories()