public function testRemoveButton()
 {
     $this->testAddButton();
     $this->template->removeButton('1');
     $buttons = $this->buttonList->getItems()[0];
     $this->assertNotContains('1', array_keys($buttons));
 }
Esempio n. 2
0
 public function afterGetButtonList(\Magento\Backend\Block\Widget\Context $subject, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList)
 {
     $request = $this->_context->getRequest();
     if ($request->getFullActionName() == 'sales_order_view') {
         $order = $this->getOrder();
         if ($order && $order->getState() == 'canceled') {
             $message = __('Are you sure you want to un-cancel this order?');
             $buttonList->add('order_uncancel', ['label' => __('Un-Cancel'), 'onclick' => "confirmSetLocation('{$message}', '" . $this->getUnCancelUrl() . "')"]);
         }
     }
     return $buttonList;
 }
Esempio n. 3
0
 /**
  * {@inheritdoc}
  */
 public function pushButtons(\Magento\Framework\View\Element\AbstractBlock $context, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList)
 {
     foreach ($buttonList->getItems() as $buttons) {
         /** @var \Magento\Backend\Block\Widget\Button\Item $item */
         foreach ($buttons as $item) {
             $containerName = $context->getNameInLayout() . '-' . $item->getButtonKey();
             $container = $this->createContainer($context->getLayout(), $containerName, $item);
             if ($item->hasData('name')) {
                 $item->setData('element_name', $item->getName());
             }
             if ($container) {
                 $container->setContext($context);
                 $toolbar = $this->getToolbar($context, $item->getRegion());
                 $toolbar->setChild($item->getButtonKey(), $container);
             }
         }
     }
 }
Esempio n. 4
0
 /**
  * Check if there's anything to display in footer
  *
  * @return boolean
  */
 public function hasFooterButtons()
 {
     foreach ($this->buttonList->getItems() as $buttons) {
         foreach ($buttons as $data) {
             if (isset($data['region']) && 'footer' == $data['region']) {
                 return true;
             }
         }
     }
     return false;
 }
Esempio n. 5
0
 /**
  * Get Add New Template button html
  *
  * @return string
  */
 protected function getAddButtonHtml()
 {
     $out = '';
     foreach ($this->buttonList->getItems() as $buttons) {
         /** @var \Magento\Backend\Block\Widget\Button\Item $item */
         foreach ($buttons as $item) {
             $out .= $this->getChildHtml($item->getButtonKey());
         }
     }
     return $out;
 }
 /**
  * @param ToolbarContext $toolbar
  * @param AbstractBlock $context
  * @param ButtonList $buttonList
  * @return array
  */
 public function beforePushButtons(ToolbarContext $toolbar, \Magento\Framework\View\Element\AbstractBlock $context, \Magento\Backend\Block\Widget\Button\ButtonList $buttonList)
 {
     if (!$context instanceof \Magento\Sales\Block\Adminhtml\Order\View) {
         return [$context, $buttonList];
     }
     $buttonList->update('order_edit', 'class', 'edit');
     $buttonList->update('order_invoice', 'class', 'invoice primary');
     $buttonList->update('order_invoice', 'sort_order', (count($buttonList->getItems()) + 1) * 10);
     $buttonList->add('order_review', ['label' => __('Review'), 'onclick' => 'setLocation(\'' . $context->getUrl('sales/*/review') . '\')', 'class' => 'review']);
     $buttonList->remove('order_hold');
     $buttonList->remove('send_notification');
     return [$context, $buttonList];
 }
Esempio n. 7
0
 /**
  * @return $this
  */
 protected function _prepareLayout()
 {
     $this->buttonList->add('back', ['label' => __('Back'), 'onclick' => 'window.location.href=\'' . $this->getUrl('tax/*/') . '\'', 'class' => 'back']);
     $this->buttonList->add('reset', ['label' => __('Reset'), 'onclick' => 'window.location.reload()', 'class' => 'reset']);
     $rate = intval($this->getRequest()->getParam('rate'));
     if ($rate) {
         $this->buttonList->add('delete', ['label' => __('Delete Rate'), 'onclick' => 'deleteConfirm(\'' . __('Are you sure you want to do this?') . '\', \'' . $this->getUrl('tax/*/delete', ['rate' => $rate]) . '\')', 'class' => 'delete']);
     }
     $this->buttonList->add('save', ['label' => __('Save Rate'), 'class' => 'save primary save-rate', 'data_attribute' => ['mage-init' => ['button' => ['event' => 'save', 'target' => '#rate-form']]]]);
     $this->toolbar->pushButtons($this, $this->buttonList);
     return parent::_prepareLayout();
 }
Esempio n. 8
0
 /**
  * {$@inheritdoc}
  */
 public function updateButton($buttonId, $key, $data)
 {
     $this->buttonList->update($buttonId, $key, $data);
     return $this;
 }
Esempio n. 9
0
 /**
  *{@inheritdoc}
  */
 public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'toolbar')
 {
     $this->buttonList->add($buttonId, $data, $level, $sortOrder, $region);
     return $this;
 }