/** * @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(); }
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; }
/** * @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]; }
/** * @return $this */ protected function _prepareLayout() { $this->buttonList->add('add', ['label' => __('Add New Tax Rate'), 'onclick' => 'window.location.href=\'' . $this->getUrl('tax/rate/add') . '\'', 'class' => 'add primary add-tax-rate']); $this->toolbar->pushButtons($this, $this->buttonList); return parent::_prepareLayout(); }
/** * Public wrapper for the button list * * @param string $buttonId * @param array $data * @param integer $level * @param integer $sortOrder * @param string|null $region That button should be displayed in ('toolbar', 'header', 'footer', null) * @return $this */ public function addButton($buttonId, $data, $level = 0, $sortOrder = 0, $region = 'toolbar') { $this->buttonList->add($buttonId, $data, $level, $sortOrder, $region); return $this; }