Skip to content

Commit

Permalink
Merge pull request #276 from magento-troll/MAGETWO-42140
Browse files Browse the repository at this point in the history
[Troll] MAGETWO-42140 Category page update
  • Loading branch information
Ganin, Roman(rganin) committed Jan 6, 2016
2 parents 11dcb28 + dab098e commit 169af51
Show file tree
Hide file tree
Showing 125 changed files with 3,590 additions and 2,231 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/

namespace Magento\Catalog\Block\Adminhtml\Category;

class AssignProducts extends \Magento\Backend\Block\Template
{
/**
* Block template
*
* @var string
*/
protected $_template = 'catalog/category/edit/assign_products.phtml';

/**
* @var \Magento\Catalog\Block\Adminhtml\Category\Tab\Product
*/
protected $blockGrid;

/**
* @var \Magento\Framework\Registry
*/
protected $registry;

/**
* @var \Magento\Framework\Json\EncoderInterface
*/
protected $jsonEncoder;

/**
* AssignProducts constructor.
*
* @param \Magento\Backend\Block\Template\Context $context
* @param \Magento\Framework\Registry $registry
* @param \Magento\Framework\Json\EncoderInterface $jsonEncoder
* @param array $data
*/
public function __construct(
\Magento\Backend\Block\Template\Context $context,
\Magento\Framework\Registry $registry,
\Magento\Framework\Json\EncoderInterface $jsonEncoder,
array $data = []
) {
$this->registry = $registry;
$this->jsonEncoder = $jsonEncoder;
parent::__construct($context, $data);
}

/**
* Retrieve instance of grid block
*
* @return \Magento\Framework\View\Element\BlockInterface
* @throws \Magento\Framework\Exception\LocalizedException
*/
public function getBlockGrid()
{
if (null === $this->blockGrid) {
$this->blockGrid = $this->getLayout()->createBlock(
'Magento\Catalog\Block\Adminhtml\Category\Tab\Product',
'category.product.grid'
);
}
return $this->blockGrid;
}

/**
* Return HTML of grid block
*
* @return string
*/
public function getGridHtml()
{
return $this->getBlockGrid()->toHtml();
}

/**
* @return string
*/
public function getProductsJson()
{
$products = $this->getCategory()->getProductsPosition();
if (!empty($products)) {
return $this->jsonEncoder->encode($products);
}
return '{}';
}
/**
* Retrieve current category instance
*
* @return array|null
*/
public function getCategory()
{
return $this->registry->registry('category');
}
}
25 changes: 6 additions & 19 deletions app/code/Magento/Catalog/Block/Adminhtml/Category/Edit.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,28 +5,15 @@
*/
namespace Magento\Catalog\Block\Adminhtml\Category;

/**
* Category container block
*/
class Edit extends \Magento\Backend\Block\Widget\Form\Container
class Edit extends \Magento\Framework\View\Element\Template
{
/**
* @var string
*/
protected $_template = 'catalog/category/edit.phtml';

/**
* @return void
* Return URL for refresh input element 'path' in form
*
* @return string
*/
protected function _construct()
public function getRefreshPathUrl()
{
$this->_objectId = 'entity_id';
$this->_blockGroup = 'Magento_Catalog';
$this->_controller = 'adminhtml_category';
$this->_mode = 'edit';
parent::_construct();
$this->buttonList->remove('back');
$this->buttonList->remove('reset');
$this->buttonList->remove('save');
return $this->getUrl('catalog/*/refreshPath', ['_current' => true]);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
<?php
/**
* Copyright © 2015 Magento. All rights reserved.
* See COPYING.txt for license details.
*/
namespace Magento\Catalog\Block\Adminhtml\Category\Edit;

use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
use Magento\Catalog\Block\Adminhtml\Category\AbstractCategory;

/**
* Class DeleteButton
*/
class DeleteButton extends AbstractCategory implements ButtonProviderInterface
{
/**
* Delete button
*
* @return array
*/
public function getButtonData()
{
$category = $this->getCategory();
$categoryId = (int)$category->getId();

if ($categoryId && !in_array($categoryId, $this->getRootIds()) && $category->isDeleteable()) {
return [
'id' => 'delete',
'label' => __('Delete'),
'on_click' => "categoryDelete('" . $this->getDeleteUrl() . "')",
'class' => 'delete',
'sort_order' => 10
];
}

return [];
}

/**
* @param array $args
* @return string
*/
public function getDeleteUrl(array $args = [])
{
$params = array_merge($this->getDefaultUrlParams(), $args);
return $this->getUrl('catalog/*/delete', $params);
}

/**
* @return array
*/
protected function getDefaultUrlParams()
{
return ['_current' => true, '_query' => ['isAjax' => null]];
}
}
Loading

0 comments on commit 169af51

Please sign in to comment.