// Toolbar
This commit is contained in:
7
admin-dev/themes/default/js/vendor/typeahead.min.js
vendored
Normal file
7
admin-dev/themes/default/js/vendor/typeahead.min.js
vendored
Normal file
File diff suppressed because one or more lines are too long
@@ -24,7 +24,7 @@
|
||||
*}
|
||||
<li class="tree-folder">
|
||||
<span class="tree-folder-name">
|
||||
<input type="checkbox" name="id-category[]" value="{$node['id_category']}" />
|
||||
<input type="checkbox" name="categoryBox[]" value="{$node['id_category']}" />
|
||||
<i class="icon-folder-close"></i>
|
||||
<label class="tree-toggler">{$name}</label>
|
||||
</span>
|
||||
|
||||
@@ -24,7 +24,7 @@
|
||||
*}
|
||||
<li class="tree-item">
|
||||
<label class="tree-item-name">
|
||||
<input type="checkbox" name="id-category[]" value="{$node['id_category']}" />
|
||||
<input type="checkbox" name="categoryBox[]" value="{$node['id_category']}" />
|
||||
<i class="tree-dot"></i>
|
||||
{$name}
|
||||
</label>
|
||||
|
||||
@@ -22,6 +22,6 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<a href="{$link}" onclick="{$action}" class="btn btn-default btn-xs">
|
||||
<i class="{$icon_class}"></i> {l s=$label}
|
||||
<a href="{$link}"{if isset($action)}onclick="{$action}"{/if} class="btn btn-default btn-xs">
|
||||
{if isset($icon_class)}<i class="{$icon_class}"></i> {/if}{l s=$label}
|
||||
</a>
|
||||
@@ -22,4 +22,18 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<label for="node-search">{l s=$label}</label> <input type="text" id="node-search" name="node-search"{if isset($class)} class="{$class}"{/if}{if isset($categories_name)} data-provide="typeahead" data-source="[{$categories_name}]"{/if} />
|
||||
<label for="node-search">{l s=$label}</label> <input type="text"{if isset($id)} id="{$id}"{/if}{if isset($name)} name="{$name}"{/if}{if isset($class)} class="{$class}"{/if} />
|
||||
{if isset($typeahead_source) && isset($id)}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(
|
||||
function()
|
||||
{
|
||||
$("#{$id}").typeahead(
|
||||
{
|
||||
name: "{$name}",
|
||||
local: [{$typeahead_source}]
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
{/if}
|
||||
@@ -22,6 +22,6 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<a href="{$link}" onclick="{$action}" class="btn btn-default btn-xs">
|
||||
<i class="{$icon_class}"></i> {l s=$label}
|
||||
<a href="{$link}"{if isset($action)}onclick="{$action}"{/if} class="btn btn-default btn-xs">
|
||||
{if isset($icon_class)}<i class="{$icon_class}"></i> {/if}{l s=$label}
|
||||
</a>
|
||||
@@ -22,4 +22,19 @@
|
||||
* @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
|
||||
* International Registered Trademark & Property of PrestaShop SA
|
||||
*}
|
||||
<label for="node-search">{l s=$label}</label> <input type="text" id="node-search" name="node-search"{if isset($class)} class="{$class}"{/if}{if isset($data_source)} data-provide="typeahead" data-source="[{$data_source}]"{/if} />
|
||||
<label for="node-search">{l s=$label}</label> <input type="text"{if isset($id)} id="{$id}"{/if}{if isset($name)} name="{$name}"{/if}{if isset($class)} class="{$class}"{/if} />
|
||||
{if isset($typeahead_source) && isset($id)}
|
||||
<script type="text/javascript">
|
||||
$(document).ready(
|
||||
function()
|
||||
{
|
||||
$("#{$id}").typeahead(
|
||||
{
|
||||
name: "{$name}",
|
||||
valueKey: 'name',
|
||||
local: [{$typeahead_source}]
|
||||
});
|
||||
}
|
||||
);
|
||||
</script>
|
||||
{/if}
|
||||
@@ -31,10 +31,12 @@ interface HelperITreeToolbarCore
|
||||
public function getActions();
|
||||
public function setContext($value);
|
||||
public function getContext();
|
||||
public function setData($value);
|
||||
public function getData();
|
||||
public function setTemplate($value);
|
||||
public function getTemplate();
|
||||
public function setTemplateDirectory($value);
|
||||
public function getTemplateDirectory();
|
||||
public function getTemplateDirectory();
|
||||
public function addAction($action);
|
||||
public function render();
|
||||
}
|
||||
@@ -27,20 +27,24 @@
|
||||
interface HelperITreeToolbarButtonCore
|
||||
{
|
||||
public function __toString();
|
||||
public function setAction($value);
|
||||
public function getAction();
|
||||
public function setAttribute($name, $value);
|
||||
public function getAttribute($name);
|
||||
public function setAttributes($value);
|
||||
public function getAttributes();
|
||||
public function setClass($value);
|
||||
public function getClass();
|
||||
public function setContext($value);
|
||||
public function getContext();
|
||||
public function setId($value);
|
||||
public function getId();
|
||||
public function setLabel($value);
|
||||
public function getLabel();
|
||||
public function setName($value);
|
||||
public function getName();
|
||||
public function setTemplate($value);
|
||||
public function getTemplate();
|
||||
public function setTemplateDirectory($value);
|
||||
public function getTemplateDirectory();
|
||||
public function addAttribute($name, $value);
|
||||
public function hasAttribute($name);
|
||||
public function render();
|
||||
}
|
||||
@@ -32,10 +32,13 @@ class HelperTreeCore
|
||||
const DEFAULT_NODE_FOLDER_TEMPLATE = 'tree_node_folder.tpl';
|
||||
const DEFAULT_NODE_ITEM_TEMPLATE = 'tree_node_item.tpl';
|
||||
|
||||
private $_children_key;
|
||||
private $_context;
|
||||
private $_data;
|
||||
private $_headerTemplate;
|
||||
private $_id;
|
||||
private $_id_key;
|
||||
private $_name_key;
|
||||
private $_node_folder_template;
|
||||
private $_node_item_template;
|
||||
private $_template_directory;
|
||||
@@ -80,6 +83,20 @@ class HelperTreeCore
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function setChildrenKey($value)
|
||||
{
|
||||
$this->_children_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChildrenKey()
|
||||
{
|
||||
if (!isset($this->_children_key))
|
||||
$this->setChildrenKey('children');
|
||||
|
||||
return $this->_children_key;
|
||||
}
|
||||
|
||||
public function setContext($value)
|
||||
{
|
||||
$this->_context = $value;
|
||||
@@ -136,6 +153,34 @@ class HelperTreeCore
|
||||
return $this->_id;
|
||||
}
|
||||
|
||||
public function setIdKey($value)
|
||||
{
|
||||
$this->_id_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdKey()
|
||||
{
|
||||
if (!isset($this->_id_key))
|
||||
$this->setIdKey('id');
|
||||
|
||||
return $this->_id_key;
|
||||
}
|
||||
|
||||
public function setNameKey($value)
|
||||
{
|
||||
$this->_name_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNameKey()
|
||||
{
|
||||
if (!isset($this->_name_key))
|
||||
$this->setNameKey('name');
|
||||
|
||||
return $this->_name_key;
|
||||
}
|
||||
|
||||
public function setNodeFolderTemplate($value)
|
||||
{
|
||||
$this->_node_folder_template = $value;
|
||||
@@ -223,6 +268,9 @@ class HelperTreeCore
|
||||
|
||||
public function getToolbar()
|
||||
{
|
||||
if (isset($this->_toolbar))
|
||||
$this->_toolbar->setData($this->getData());
|
||||
|
||||
return $this->_toolbar;
|
||||
}
|
||||
|
||||
@@ -296,13 +344,14 @@ class HelperTreeCore
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
if (array_key_exists('children', $item) && !empty($item['children']))
|
||||
if (array_key_exists($this->getChildrenKey(), $item)
|
||||
&& !empty($item[$this->getChildrenKey()]))
|
||||
$html .= $this->getContext()->smarty->createTemplate(
|
||||
$this->getTemplateDirectory().$this->getNodeFolderTemplate(),
|
||||
$this->getContext()->smarty
|
||||
)->assign(array(
|
||||
'name' => $item['name'],
|
||||
'children' => $this->renderNodes($item['children']),
|
||||
'name' => $item[$this->getNameKey()],
|
||||
'children' => $this->renderNodes($item[$this->getChildrenKey()]),
|
||||
'node' => $item
|
||||
))->fetch();
|
||||
else
|
||||
@@ -310,7 +359,7 @@ class HelperTreeCore
|
||||
$this->getTemplateDirectory().$this->getNodeItemTemplate(),
|
||||
$this->getContext()->smarty
|
||||
)->assign(array(
|
||||
'name' => $item['name'],
|
||||
'name' => $item[$this->getNameKey()],
|
||||
'node' => $item
|
||||
))->fetch();
|
||||
}
|
||||
|
||||
@@ -31,6 +31,7 @@ class HelperTreeToolbarCore implements HelperITreeToolbarCore
|
||||
|
||||
private $_actions;
|
||||
private $_context;
|
||||
private $_data;
|
||||
private $_template;
|
||||
private $_template_directory;
|
||||
|
||||
@@ -69,6 +70,20 @@ class HelperTreeToolbarCore implements HelperITreeToolbarCore
|
||||
return $this->_context;
|
||||
}
|
||||
|
||||
public function setData($value)
|
||||
{
|
||||
if (!is_array($value) && !$value instanceof Traversable)
|
||||
throw new PrestaShopException('Data value must be an traversable array');
|
||||
|
||||
$this->_data = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getData()
|
||||
{
|
||||
return $this->_data;
|
||||
}
|
||||
|
||||
public function setTemplate($value)
|
||||
{
|
||||
$this->_template = $value;
|
||||
@@ -118,6 +133,12 @@ class HelperTreeToolbarCore implements HelperITreeToolbarCore
|
||||
|
||||
public function render()
|
||||
{
|
||||
foreach ($this->getActions() as $action)
|
||||
{
|
||||
if (is_subclass_of($action, 'HelperTreeToolbarSearchCore'))
|
||||
$action->setAttribute('data', $this->getData());
|
||||
}
|
||||
|
||||
return $this->getContext()->smarty->createTemplate(
|
||||
$this->getTemplateDirectory().$this->getTemplate(),
|
||||
$this->getContext()->smarty
|
||||
|
||||
@@ -28,18 +28,20 @@ abstract class HelperTreeToolbarButtonCore
|
||||
{
|
||||
const DEFAULT_TEMPLATE_DIRECTORY = 'helpers/tree';
|
||||
|
||||
private $_action;
|
||||
private $_attributes;
|
||||
protected $_attributes;
|
||||
private $_class;
|
||||
private $_context;
|
||||
private $_id;
|
||||
private $_label;
|
||||
private $_name;
|
||||
protected $_template;
|
||||
protected $_template_directory;
|
||||
|
||||
public function __construct($label, $action = null, $class = null)
|
||||
public function __construct($label, $id = null, $name = null, $class = null)
|
||||
{
|
||||
$this->setLabel($label);
|
||||
$this->setAction($action);
|
||||
$this->setId($id);
|
||||
$this->setName($name);
|
||||
$this->setClass($class);
|
||||
}
|
||||
|
||||
@@ -48,15 +50,18 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->render();
|
||||
}
|
||||
|
||||
public function setAction($value)
|
||||
public function setAttribute($name, $value)
|
||||
{
|
||||
$this->_action = $value;
|
||||
if (!isset($this->_attributes))
|
||||
$this->_attributes = array();
|
||||
|
||||
$this->_attributes[$name] = $value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
public function getAttribute($name)
|
||||
{
|
||||
return $this->_action;
|
||||
return $this->hasAttribute($name) ? $this->_attributes[$name] : null;
|
||||
}
|
||||
|
||||
public function setAttributes($value)
|
||||
@@ -78,13 +83,12 @@ abstract class HelperTreeToolbarButtonCore
|
||||
|
||||
public function setClass($value)
|
||||
{
|
||||
$this->_class = $value;
|
||||
return $this;
|
||||
return $this->setAttribute('class', $value);
|
||||
}
|
||||
|
||||
public function getClass()
|
||||
{
|
||||
return $this->_class;
|
||||
return $this->getAttribute('class');
|
||||
}
|
||||
|
||||
public function setContext($value)
|
||||
@@ -101,15 +105,34 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->_context;
|
||||
}
|
||||
|
||||
public function setId($value)
|
||||
{
|
||||
return $this->setAttribute('id', $value);
|
||||
}
|
||||
|
||||
public function getId()
|
||||
{
|
||||
return $this->getAttribute('id');
|
||||
}
|
||||
|
||||
public function setLabel($value)
|
||||
{
|
||||
$this->_label = $value;
|
||||
return $this;
|
||||
return $this->setAttribute('label', $value);
|
||||
}
|
||||
|
||||
public function getLabel()
|
||||
{
|
||||
return $this->_label;
|
||||
return $this->getAttribute('label');
|
||||
}
|
||||
|
||||
public function setName($value)
|
||||
{
|
||||
return $this->setAttribute('name', $value);
|
||||
}
|
||||
|
||||
public function getName()
|
||||
{
|
||||
return $this->getAttribute('name');
|
||||
}
|
||||
|
||||
public function setTemplate($value)
|
||||
@@ -139,13 +162,10 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->_template_directory;
|
||||
}
|
||||
|
||||
public function addAttribute($name, $value)
|
||||
public function hasAttribute($name)
|
||||
{
|
||||
if (!isset($this->_attributes))
|
||||
$this->_attributes = array();
|
||||
|
||||
$this->_attributes[$name] = $value;
|
||||
return $this;
|
||||
return (isset($this->_attributes)
|
||||
&& array_key_exists($name, $this->_attributes));
|
||||
}
|
||||
|
||||
public function render()
|
||||
@@ -153,7 +173,7 @@ abstract class HelperTreeToolbarButtonCore
|
||||
return $this->getContext()->smarty->createTemplate(
|
||||
$this->getTemplateDirectory().$this->getTemplate(),
|
||||
$this->getContext()->smarty
|
||||
)->assign($this->getAttributes());
|
||||
)->assign($this->getAttributes())->fetch();
|
||||
}
|
||||
|
||||
private function _normalizeDirectory($directory)
|
||||
|
||||
@@ -27,52 +27,47 @@
|
||||
class HelperTreeToolbarLinkCore extends HelperTreeToolbarButtonCore implements
|
||||
HelperITreeToolbarButtonCore
|
||||
{
|
||||
private $_action;
|
||||
private $_icon_class;
|
||||
private $_link;
|
||||
protected $_template = 'tree_toolbar_link.tpl';
|
||||
|
||||
public function __construct($label, $action = null, $link, $iconClass)
|
||||
public function __construct($label, $link, $action = null, $iconClass = null)
|
||||
{
|
||||
parent::__construct($label, $action);
|
||||
parent::__construct($label);
|
||||
|
||||
$this->setLink($link);
|
||||
$this->setAction($action);
|
||||
$this->setIconClass($iconClass);
|
||||
}
|
||||
|
||||
public function setAction($value)
|
||||
{
|
||||
return $this->setAttribute('action', $value);
|
||||
}
|
||||
|
||||
public function getAction()
|
||||
{
|
||||
return $this->getAttribute('action');
|
||||
}
|
||||
|
||||
public function setIconClass($value)
|
||||
{
|
||||
$this->_icon_class = $value;
|
||||
return $this;
|
||||
return $this->setAttribute('icon_class', $value);
|
||||
}
|
||||
|
||||
public function getIconClass()
|
||||
{
|
||||
return $this->_icon_class;
|
||||
return $this->getAttribute('icon_class');
|
||||
}
|
||||
|
||||
public function setLink($value)
|
||||
{
|
||||
$this->_link = $value;
|
||||
return $this;
|
||||
return $this->setAttribute('link', $value);
|
||||
}
|
||||
|
||||
public function getLink()
|
||||
{
|
||||
if (!isset($this->_link))
|
||||
$this->_link = '';
|
||||
|
||||
return $this->_link;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
$template = parent::render();
|
||||
$template->assign(array(
|
||||
'link' => $this->getLink(),
|
||||
'action' => $this->getAction(),
|
||||
'label' => $this->getLabel(),
|
||||
'class' => $this->getClass(),
|
||||
'icon_class' => $this->getIconClass()
|
||||
));
|
||||
return $template->fetch();
|
||||
return $this->getAttribute('link');
|
||||
}
|
||||
}
|
||||
@@ -27,10 +27,68 @@
|
||||
class HelperTreeToolbarSearchCore extends HelperTreeToolbarButtonCore implements
|
||||
HelperITreeToolbarButtonCore
|
||||
{
|
||||
private $_children_key;
|
||||
private $_id_key;
|
||||
private $_name_key;
|
||||
protected $_template = 'tree_toolbar_search.tpl';
|
||||
|
||||
public function __construct($label, $id, $name = null, $class = null)
|
||||
{
|
||||
parent::__construct($label);
|
||||
|
||||
$this->setId($id);
|
||||
$this->setName($name);
|
||||
$this->setClass($class);
|
||||
}
|
||||
|
||||
public function setChildrenKey($value)
|
||||
{
|
||||
$this->_children_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getChildrenKey()
|
||||
{
|
||||
if (!isset($this->_children_key))
|
||||
$this->setChildrenKey('children');
|
||||
|
||||
return $this->_children_key;
|
||||
}
|
||||
|
||||
public function setIdKey($value)
|
||||
{
|
||||
$this->_id_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getIdKey()
|
||||
{
|
||||
if (!isset($this->_id_key))
|
||||
$this->setIdKey('id');
|
||||
|
||||
return $this->_id_key;
|
||||
}
|
||||
|
||||
public function setNameKey($value)
|
||||
{
|
||||
$this->_name_key = (string)$value;
|
||||
return $this;
|
||||
}
|
||||
|
||||
public function getNameKey()
|
||||
{
|
||||
if (!isset($this->_name_key))
|
||||
$this->setNameKey('name');
|
||||
|
||||
return $this->_name_key;
|
||||
}
|
||||
|
||||
public function render()
|
||||
{
|
||||
if ($this->hasAttribute('data'))
|
||||
$this->setAttribute('typeahead_source',
|
||||
$this->_renderData($this->getAttribute('data')));
|
||||
|
||||
$admin_webpath = str_ireplace(_PS_ROOT_DIR_, '', _PS_ADMIN_DIR_);
|
||||
$admin_webpath = preg_replace('/^'.preg_quote(DIRECTORY_SEPARATOR, '/').'/', '', $admin_webpath);
|
||||
$bo_theme = ((Validate::isLoadedObject($this->getContext()->employee)
|
||||
@@ -47,12 +105,24 @@ class HelperTreeToolbarSearchCore extends HelperTreeToolbarButtonCore implements
|
||||
$this->getContext()->controller->addJs(__PS_BASE_URI__.$admin_webpath
|
||||
.'/themes/'.$bo_theme.'/js/vendor/typeahead.min.js');
|
||||
|
||||
$template = parent::render();
|
||||
$template->assign(array(
|
||||
'action' => $this->getAction(),
|
||||
'label' => $this->getLabel(),
|
||||
'class' => $this->getClass()
|
||||
));
|
||||
return (isset($html)?$html:'').$template->fetch();
|
||||
return (isset($html)?$html:'').parent::render();
|
||||
}
|
||||
|
||||
private function _renderData($data)
|
||||
{
|
||||
if (!is_array($data) && !$data instanceof Traversable)
|
||||
throw new PrestaShopException('Data value must be an traversable array');
|
||||
|
||||
$html = '';
|
||||
|
||||
foreach ($data as $item)
|
||||
{
|
||||
if (array_key_exists($this->getChildrenKey(), $item) && !empty($item[$this->getChildrenKey()]))
|
||||
$html .= '{id : '.$item[$this->getIdKey()].', name : "'.$item[$this->getNameKey()].'"},'.$this->_renderData($item[$this->getChildrenKey()]);
|
||||
else
|
||||
$html .= '{id : '.$item[$this->getIdKey()].', name : "'.$item[$this->getNameKey()].'"},';
|
||||
}
|
||||
|
||||
return $html;
|
||||
}
|
||||
}
|
||||
@@ -2328,14 +2328,23 @@ class AdminProductsControllerCore extends AdminController
|
||||
return parent::renderList();
|
||||
}
|
||||
|
||||
public function renderCategoriesTree($selectedCategory = null)
|
||||
public function renderCategoriesTree($selected_category = null)
|
||||
{
|
||||
$tree = new HelperTree('categories-tree', Category::getNestedCategories());
|
||||
$tree = new HelperTree('categories-tree', Category::getNestedCategories(
|
||||
1, $this->context->employee->id_lang));
|
||||
|
||||
$html = $tree->setTitle('Filter by category')
|
||||
->setActions(array(
|
||||
new HelperTreeToolbarLink('Collapse All', '$(\'#categories-tree\').tree(\'collapseAll\')', '#', 'icon-collapse-alt'),
|
||||
new HelperTreeToolbarLink('Expand All', '$(\'#categories-tree\').tree(\'expandAll\')', '#', 'icon-expand-alt')
|
||||
new HelperTreeToolbarLink(
|
||||
'Collapse All',
|
||||
'#',
|
||||
'$(\'#categories-tree\').tree(\'collapseAll\')',
|
||||
'icon-collapse-alt'),
|
||||
new HelperTreeToolbarLink(
|
||||
'Expand All',
|
||||
'#',
|
||||
'$(\'#categories-tree\').tree(\'expandAll\')',
|
||||
'icon-expand-alt')
|
||||
))
|
||||
->setTemplateDirectory($this->context->smarty->getTemplateDir(0).'/controllers/products/helpers/tree')
|
||||
->render();
|
||||
@@ -2351,13 +2360,14 @@ class AdminProductsControllerCore extends AdminController
|
||||
}
|
||||
);';
|
||||
|
||||
if (isset($selectedCategory))
|
||||
if (isset($selected_category))
|
||||
$html .= '$("#categories-tree").find(":input").each(
|
||||
function()
|
||||
{
|
||||
if ($(this).val() == '.$selectedCategory.')
|
||||
if ($(this).val() == '.$selected_category.')
|
||||
{
|
||||
$(this).prop("checked", true);
|
||||
$(this).parent().addClass("tree-selected");
|
||||
$(this).parents("ul.tree").each(
|
||||
function()
|
||||
{
|
||||
@@ -2375,36 +2385,51 @@ class AdminProductsControllerCore extends AdminController
|
||||
return $html;
|
||||
}
|
||||
|
||||
public function renderAssociationsCategoriesTree()
|
||||
public function renderAssociationsCategoriesTree($root_category,
|
||||
$selected_categories)
|
||||
{
|
||||
$categories = Category::getSimpleCategories(1);
|
||||
$search_source = array();
|
||||
foreach ($categories as $key => $category)
|
||||
$search_source[] = $category['name'];
|
||||
|
||||
$tree = new HelperTree('associated-categories-tree', Category::getNestedCategories());
|
||||
$search = new HelperTreeToolbarSearch('Find a category:');
|
||||
$search->setTemplateDirectory($this->context->smarty->getTemplateDir(0).'/controllers/products/helpers/tree')
|
||||
->addAttribute('categories_name', '"'.implode('","', $search_source).'"');
|
||||
$tree = new HelperTree('associated-categories-tree',
|
||||
Category::getNestedCategories(1, $this->context->employee->id_lang));
|
||||
$search = new HelperTreeToolbarSearch('Find a category:',
|
||||
'categories-search');
|
||||
$search->setIdKey('id_category');
|
||||
$html = $tree->setTitle('Associated categories')
|
||||
->setActions(array(
|
||||
new HelperTreeToolbarLink('Collapse All', '$(\'#associated-categories-tree\').tree(\'collapseAll\')', '#', 'icon-collapse-alt'),
|
||||
new HelperTreeToolbarLink('Expand All', '$(\'#associated-categories-tree\').tree(\'expandAll\')', '#', 'icon-expand-alt'),
|
||||
new HelperTreeToolbarLink('Check All', 'checkAllAssociatedCategories();', '#', 'icon-check-sign'),
|
||||
new HelperTreeToolbarLink('Uncheck All', 'uncheckAllAssociatedCategories();', '#', 'icon-check-empty'),
|
||||
new HelperTreeToolbarLink(
|
||||
'Collapse All',
|
||||
'#',
|
||||
'$(\'#associated-categories-tree\').tree(\'collapseAll\')',
|
||||
'icon-collapse-alt'),
|
||||
new HelperTreeToolbarLink(
|
||||
'Expand All',
|
||||
'#',
|
||||
'$(\'#associated-categories-tree\').tree(\'expandAll\')',
|
||||
'icon-expand-alt'),
|
||||
new HelperTreeToolbarLink(
|
||||
'Check All',
|
||||
'#',
|
||||
'checkAllAssociatedCategories();',
|
||||
'icon-check-sign'),
|
||||
new HelperTreeToolbarLink(
|
||||
'Uncheck All',
|
||||
'#',
|
||||
'uncheckAllAssociatedCategories();',
|
||||
'icon-check-empty'),
|
||||
$search
|
||||
))
|
||||
->setTemplateDirectory($this->context->smarty->getTemplateDir(0).'/controllers/products/helpers/tree')
|
||||
->setNodeFolderTemplate('tree_node_folder_associations.tpl')
|
||||
->setNodeFolderTemplate('tree_node_item_associations.tpl')
|
||||
->setNodeItemTemplate('tree_node_item_associations.tpl')
|
||||
->render();
|
||||
$html .= '<script type="text/javascript">
|
||||
|
||||
$html .= '<script type="text/javascript">
|
||||
function checkAllAssociatedCategories()
|
||||
{
|
||||
$("#associated-categories-tree").find(":input[type=checkbox]").each(
|
||||
function()
|
||||
{
|
||||
$(this).prop("checked", true);
|
||||
$(this).parent().addClass("tree-selected");
|
||||
}
|
||||
);
|
||||
}
|
||||
@@ -2415,13 +2440,60 @@ class AdminProductsControllerCore extends AdminController
|
||||
function()
|
||||
{
|
||||
$(this).prop("checked", false);
|
||||
$(this).parent().removeClass("tree-selected");
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
$(document).ready(function () {
|
||||
//$("#associated-categories-tree").tree("collapseAll");
|
||||
$("#categories-search").bind("typeahead:selected", function(obj, datum) {
|
||||
$("#associated-categories-tree").find(":input").each(
|
||||
function()
|
||||
{
|
||||
if ($(this).val() == datum.id)
|
||||
{
|
||||
$(this).prop("checked", true);
|
||||
$(this).parent().addClass("tree-selected");
|
||||
$(this).parents("ul.tree").each(
|
||||
function()
|
||||
{
|
||||
$(this).children().children(".icon-folder-close")
|
||||
.removeClass("icon-folder-close")
|
||||
.addClass("icon-folder-open");
|
||||
$(this).show();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
$(document).ready(
|
||||
function()
|
||||
{
|
||||
$("#associated-categories-tree").tree("collapseAll");
|
||||
|
||||
var selected_categories = new Array("'.implode('","', $selected_categories).'");
|
||||
$("#associated-categories-tree").find(":input").each(
|
||||
function()
|
||||
{
|
||||
if ($.inArray($(this).val(), selected_categories) != -1)
|
||||
{
|
||||
$(this).prop("checked", true);
|
||||
$(this).parent().addClass("tree-selected");
|
||||
$(this).parents("ul.tree").each(
|
||||
function()
|
||||
{
|
||||
$(this).children().children(".icon-folder-close")
|
||||
.removeClass("icon-folder-close")
|
||||
.addClass("icon-folder-open");
|
||||
$(this).show();
|
||||
}
|
||||
);
|
||||
}
|
||||
}
|
||||
);
|
||||
}
|
||||
);
|
||||
</script>';
|
||||
return $html;
|
||||
}
|
||||
@@ -3027,14 +3099,17 @@ class AdminProductsControllerCore extends AdminController
|
||||
$data->assign('accessories', $accessories);
|
||||
|
||||
$product->manufacturer_name = Manufacturer::getNameById($product->id_manufacturer);
|
||||
$tab_root = array('id_category' => $root->id, 'name' => $root->name);
|
||||
$category_tree = $helper->renderCategoryTree($tab_root, $selected_cat, 'categoryBox', false, true, array(), false, true);
|
||||
$helper = new Helper();
|
||||
|
||||
$categories = array();
|
||||
foreach ($selected_cat as $key => $category)
|
||||
$categories[] = $key;
|
||||
|
||||
$data->assign(array('default_category' => $default_category,
|
||||
'selected_cat_ids' => implode(',', array_keys($selected_cat)),
|
||||
'selected_cat' => $selected_cat,
|
||||
'id_category_default' => $product->getDefaultCategory(),
|
||||
'category_tree' => $category_tree,
|
||||
'category_tree' => $this->renderAssociationsCategoriesTree(
|
||||
$root->id, $categories),
|
||||
'product' => $product,
|
||||
'link' => $this->context->link,
|
||||
'is_shop_context' => Shop::getContext() == Shop::CONTEXT_SHOP
|
||||
|
||||
Reference in New Issue
Block a user