// BO : product form improved (categories association)

This commit is contained in:
vChabot
2012-04-19 16:18:58 +00:00
parent 925406d026
commit 9b2f0d9ed3
5 changed files with 24 additions and 18 deletions
@@ -36,17 +36,12 @@
<table> <table>
<tr> <tr>
<td class="col-left"> <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> <label for="category_block">{l s='Associated categories:'}</label>
</td> </td>
<td class="col-right"> <td class="col-right">
<div id="category_block"> <div id="category_block">
{if !$is_shop_context}
<div class="warn">
{/if}
{$category_tree} {$category_tree}
{if !$is_shop_context}
</div>
{/if}
</div> </div>
</td> </td>
</tr> </tr>
@@ -56,12 +51,10 @@
<tr> <tr>
<td></td> <td></td>
<td class="col-right"> <td class="col-right">
{if $is_shop_context}
<a class="button bt-icon confirm_leave" href="{$link->getAdminLink('AdminCategories')}&addcategory"> <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'}" /> <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> <span>{l s='Create new category'}</span>
</a> </a>
{/if}
</td> </td>
</tr> </tr>
<tr> <tr>
@@ -2704,10 +2704,7 @@ class AdminProductsControllerCore extends AdminController
$tab_root = array('id_category' => $root->id, 'name' => $root->name); $tab_root = array('id_category' => $root->id, 'name' => $root->name);
$helper = new Helper(); $helper = new Helper();
if (Shop::getContext() != Shop::CONTEXT_SHOP) $category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true);
$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);
$data->assign(array('default_category' => $default_category, $data->assign(array('default_category' => $default_category,
'selected_cat_ids' => implode(',', array_keys($selected_cat)), 'selected_cat_ids' => implode(',', array_keys($selected_cat)),
'selected_cat' => $selected_cat, 'selected_cat' => $selected_cat,
+4 -2
View File
@@ -513,11 +513,13 @@ class AdminShopControllerCore extends AdminController
return $object; 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'); $id_shop = (int)Tools::getValue('id_shop');
$shop = new Shop($id_shop); $shop = new Shop($id_shop);
$selected_cat = Shop::getCategories($id_shop); $selected_cat = Shop::getCategories();
if (empty($selected_cat)) if (empty($selected_cat))
{ {
// get first category root and preselect all these children // get first category root and preselect all these children
+13 -4
View File
@@ -35,15 +35,15 @@ var id_category_root = 0;
function buildTreeView() function buildTreeView()
{ {
use_shop_context = false; use_shop_context = 0;
if (buildTreeView.arguments[0]) if (buildTreeView.arguments[0])
use_shop_context = true; use_shop_context = 1;
$("#categories-treeview").treeview({ $("#categories-treeview").treeview({
url : 'ajax.php', url : 'ajax.php',
toggle: function () { callbackToggle($(this)); }, toggle: function () { callbackToggle($(this)); },
ajax : { ajax : {
type: 'POST', type: 'POST',
async: true, async: false,
data: { data: {
getChildrenCategories : true, getChildrenCategories : true,
use_shop_context : use_shop_context, use_shop_context : use_shop_context,
@@ -57,7 +57,10 @@ function buildTreeView()
$('#categories-treeview li#'+id_category_root). $('#categories-treeview li#'+id_category_root).
removeClass('collapsable lastCollapsable'). removeClass('collapsable lastCollapsable').
addClass('last static'); 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 () { $('#expand_all').click( function () {
expandAllCategories(); expandAllCategories();
return false; return false;
@@ -79,6 +82,12 @@ function buildTreeView()
uncheckAllCategories(); uncheckAllCategories();
return false; 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) function callbackToggle(element)
+5
View File
@@ -1500,6 +1500,10 @@ function multishopCheckProductField(checked, id, type)
$('#unity').attr('disabled', checked); $('#unity').attr('disabled', checked);
break; break;
case 'category_box' :
$('#categories-treeview input[type=checkbox]').attr('disabled', checked);
break;
default : default :
$('#'+id).attr('disabled', checked); $('#'+id).attr('disabled', checked);
break; break;
@@ -1545,6 +1549,7 @@ function multishopCheckAllProductFieldsSeo(checked)
function multishopCheckAllProductFieldsAssociations(checked) function multishopCheckAllProductFieldsAssociations(checked)
{ {
multishopCheckProductField($('input[name=\'multishop_check[id_category_default]\']').attr('checked'), 'id_category_default'); 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(); var tabs_manager = new ProductTabsManager();