11 class Chooser extends \Magento\Backend\Block\Widget\Grid\Extended
32 \
Magento\Backend\Helper\Data $backendHelper,
33 \
Magento\Cms\Model\BlockFactory $blockFactory,
37 $this->_blockFactory = $blockFactory;
38 $this->_collectionFactory = $collectionFactory;
39 parent::__construct($context, $backendHelper,
$data);
52 $this->setUseAjax(
true);
64 $uniqId = $this->mathRandom->getUniqueHash(
$element->getId());
65 $sourceUrl = $this->
getUrl(
'cms/block_widget/chooser', [
'uniq_id' => $uniqId]);
67 $chooser = $this->
getLayout()->createBlock(
74 $this->getFieldsetId()
82 $block = $this->_blockFactory->create()->load(
$element->getValue());
88 $element->setData(
'after_element_html', $chooser->toHtml());
99 $chooserJsObject = $this->
getId();
101 function (grid, event) { 102 var trElement = Event.findElement(event, "tr"); 103 var blockId = trElement.down("td").innerHTML.replace(/^\s+|\s+$/g,""); 104 var blockTitle = trElement.down("td").next().innerHTML; 107 '.setElementValue(blockId); 110 '.setElementLabel(blockTitle); 127 return parent::_prepareCollection();
139 [
'header' =>
__(
'ID'),
'align' =>
'right',
'index' =>
'block_id',
'width' => 50]
142 $this->
addColumn(
'chooser_title', [
'header' =>
__(
'Title'),
'align' =>
'left',
'index' =>
'title']);
145 'chooser_identifier',
146 [
'header' =>
__(
'Identifier'),
'align' =>
'left',
'index' =>
'identifier']
152 'header' =>
__(
'Status'),
153 'index' =>
'is_active',
155 'options' => [0 =>
__(
'Disabled'), 1 =>
__(
'Enabled')]
159 return parent::_prepareColumns();
169 return $this->
getUrl(
'cms/block_widget/chooser', [
'_current' =>
true]);
escapeHtml($data, $allowedTags=null)
getUrl($route='', $params=[])