init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class BackButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData(): array
|
||||
{
|
||||
return [
|
||||
'label' => __('Back'),
|
||||
'on_click' => sprintf("location.href = '%s';", $this->getUrl('*/*/')),
|
||||
'class' => 'back',
|
||||
'sort_order' => 10,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class DeleteButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData(): array
|
||||
{
|
||||
if (!$this->getEntityId()) {
|
||||
return [];
|
||||
}
|
||||
|
||||
return [
|
||||
'label' => __('Delete Agent'),
|
||||
'class' => 'delete',
|
||||
'on_click' => 'deleteConfirm('
|
||||
. json_encode(__('Are you sure you want to delete this agent?')) . ', '
|
||||
. json_encode($this->getUrl('*/*/delete', ['entity_id' => $this->getEntityId()]))
|
||||
. ')',
|
||||
'sort_order' => 20,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
|
||||
|
||||
use Magento\Backend\Block\Widget\Context;
|
||||
|
||||
class GenericButton
|
||||
{
|
||||
public function __construct(protected readonly Context $context)
|
||||
{
|
||||
}
|
||||
|
||||
public function getEntityId(): int
|
||||
{
|
||||
return (int) $this->context->getRequest()->getParam('entity_id');
|
||||
}
|
||||
|
||||
public function getUrl(string $route = '', array $params = []): string
|
||||
{
|
||||
return $this->context->getUrlBuilder()->getUrl($route, $params);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class SaveAndContinueButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData(): array
|
||||
{
|
||||
return [
|
||||
'label' => __('Save and Continue Edit'),
|
||||
'class' => 'save',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'saveAndContinueEdit']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 80,
|
||||
];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
<?php
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Esun\Agent\Block\Adminhtml\Agent\Edit;
|
||||
|
||||
use Magento\Framework\View\Element\UiComponent\Control\ButtonProviderInterface;
|
||||
|
||||
class SaveButton extends GenericButton implements ButtonProviderInterface
|
||||
{
|
||||
public function getButtonData(): array
|
||||
{
|
||||
return [
|
||||
'label' => __('Save Agent'),
|
||||
'class' => 'save primary',
|
||||
'data_attribute' => [
|
||||
'mage-init' => ['button' => ['event' => 'save']],
|
||||
'form-role' => 'save',
|
||||
],
|
||||
'sort_order' => 90,
|
||||
];
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user