// BO : product form improved (categories association)
This commit is contained in:
@@ -36,17 +36,12 @@
|
||||
<table>
|
||||
<tr>
|
||||
<td class="col-left">
|
||||
{include file="controllers/products/multishop/checkbox.tpl" field="category_box" type="category_box"}
|
||||
<label for="category_block">{l s='Associated categories:'}</label>
|
||||
</td>
|
||||
<td class="col-right">
|
||||
<div id="category_block">
|
||||
{if !$is_shop_context}
|
||||
<div class="warn">
|
||||
{/if}
|
||||
{$category_tree}
|
||||
{if !$is_shop_context}
|
||||
</div>
|
||||
{/if}
|
||||
</div>
|
||||
</td>
|
||||
</tr>
|
||||
@@ -56,12 +51,10 @@
|
||||
<tr>
|
||||
<td></td>
|
||||
<td class="col-right">
|
||||
{if $is_shop_context}
|
||||
<a class="button bt-icon confirm_leave" href="{$link->getAdminLink('AdminCategories')}&addcategory">
|
||||
<img src="../img/admin/add.gif" alt="{l s='Create new category'}" title="{l s='Create new category'}" />
|
||||
<span>{l s='Create new category'}</span>
|
||||
</a>
|
||||
{/if}
|
||||
</td>
|
||||
</tr>
|
||||
<tr>
|
||||
|
||||
@@ -2704,10 +2704,7 @@ class AdminProductsControllerCore extends AdminController
|
||||
|
||||
$tab_root = array('id_category' => $root->id, 'name' => $root->name);
|
||||
$helper = new Helper();
|
||||
if (Shop::getContext() != Shop::CONTEXT_SHOP)
|
||||
$category_tree = $this->l('You must select a shop if you want to put your product into a particular shop.');
|
||||
else
|
||||
$category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true);
|
||||
$category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true);
|
||||
$data->assign(array('default_category' => $default_category,
|
||||
'selected_cat_ids' => implode(',', array_keys($selected_cat)),
|
||||
'selected_cat' => $selected_cat,
|
||||
|
||||
@@ -513,11 +513,13 @@ class AdminShopControllerCore extends AdminController
|
||||
return $object;
|
||||
}
|
||||
|
||||
public function initCategoriesAssociation($id_root = 1)
|
||||
public function initCategoriesAssociation($id_root = null)
|
||||
{
|
||||
if (is_null($id_root))
|
||||
$id_root = Configuration::get('PS_ROOT_CATEGORY');
|
||||
$id_shop = (int)Tools::getValue('id_shop');
|
||||
$shop = new Shop($id_shop);
|
||||
$selected_cat = Shop::getCategories($id_shop);
|
||||
$selected_cat = Shop::getCategories();
|
||||
if (empty($selected_cat))
|
||||
{
|
||||
// get first category root and preselect all these children
|
||||
|
||||
@@ -35,15 +35,15 @@ var id_category_root = 0;
|
||||
|
||||
function buildTreeView()
|
||||
{
|
||||
use_shop_context = false;
|
||||
use_shop_context = 0;
|
||||
if (buildTreeView.arguments[0])
|
||||
use_shop_context = true;
|
||||
use_shop_context = 1;
|
||||
$("#categories-treeview").treeview({
|
||||
url : 'ajax.php',
|
||||
toggle: function () { callbackToggle($(this)); },
|
||||
ajax : {
|
||||
type: 'POST',
|
||||
async: true,
|
||||
async: false,
|
||||
data: {
|
||||
getChildrenCategories : true,
|
||||
use_shop_context : use_shop_context,
|
||||
@@ -57,7 +57,10 @@ function buildTreeView()
|
||||
$('#categories-treeview li#'+id_category_root).
|
||||
removeClass('collapsable lastCollapsable').
|
||||
addClass('last static');
|
||||
|
||||
|
||||
disabled = $('#categories-treeview li:first input[type=checkbox]').attr('disabled');
|
||||
$('#categories-treeview input[type=checkbox]').attr('disabled', disabled);
|
||||
|
||||
$('#expand_all').click( function () {
|
||||
expandAllCategories();
|
||||
return false;
|
||||
@@ -79,6 +82,12 @@ function buildTreeView()
|
||||
uncheckAllCategories();
|
||||
return false;
|
||||
});
|
||||
|
||||
// check if checkboxes need to be disabled or not
|
||||
$('.expandable').click(function(){
|
||||
disabled = $('#categories-treeview li:first input[type=checkbox]').attr('disabled');
|
||||
$('#categories-treeview input[type=checkbox]').attr('disabled', disabled);
|
||||
});
|
||||
}
|
||||
|
||||
function callbackToggle(element)
|
||||
|
||||
@@ -1500,6 +1500,10 @@ function multishopCheckProductField(checked, id, type)
|
||||
$('#unity').attr('disabled', checked);
|
||||
break;
|
||||
|
||||
case 'category_box' :
|
||||
$('#categories-treeview input[type=checkbox]').attr('disabled', checked);
|
||||
break;
|
||||
|
||||
default :
|
||||
$('#'+id).attr('disabled', checked);
|
||||
break;
|
||||
@@ -1545,6 +1549,7 @@ function multishopCheckAllProductFieldsSeo(checked)
|
||||
function multishopCheckAllProductFieldsAssociations(checked)
|
||||
{
|
||||
multishopCheckProductField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'id_category_default');
|
||||
multishopCheckProductField($('input[name=\'multishop_check[category_box]\']').attr('checked'), 'categories-treeview', 'category_box');
|
||||
}
|
||||
|
||||
var tabs_manager = new ProductTabsManager();
|
||||
|
||||
Reference in New Issue
Block a user