feat(main): Draggable blocks
This commit is contained in:
@@ -3,6 +3,9 @@
|
||||
namespace Websmid\CustomHtml\Controller;
|
||||
|
||||
use Exception;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Position\Exception\PositionUpdateException;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Position\GridPositionUpdaterInterface;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Position\PositionUpdateFactoryInterface;
|
||||
use PrestaShopBundle\Controller\Admin\FrameworkBundleAdminController;
|
||||
use PrestaShopBundle\Security\Voter\PageVoter;
|
||||
use Symfony\Component\HttpFoundation\RedirectResponse;
|
||||
@@ -115,6 +118,28 @@ class CustomHtmlBlockController extends FrameworkBundleAdminController
|
||||
return $this->redirectToRoute('customhtmlblock_index');
|
||||
}
|
||||
|
||||
public function updatePositionAction(int $idGroup, Request $request): RedirectResponse
|
||||
{
|
||||
$positionDefinition = $this->get('websmid.customhtml.grid.position.customhtmlblock_position_definition');
|
||||
|
||||
try {
|
||||
$positionUpdateFactory = $this->get(PositionUpdateFactoryInterface::class);
|
||||
$positionUpdate = $positionUpdateFactory->buildPositionUpdate([
|
||||
'positions' => $request->request->all('positions'),
|
||||
'parentId' => $idGroup,
|
||||
], $positionDefinition);
|
||||
|
||||
$updater = $this->get(GridPositionUpdaterInterface::class);
|
||||
$updater->update($positionUpdate);
|
||||
|
||||
$this->addFlash('success', $this->trans('Successful update.', 'Admin.Notifications.Success'));
|
||||
} catch (PositionUpdateException $e) {
|
||||
$this->addFlash('error', $this->getErrorMessageForException($e, []));
|
||||
}
|
||||
|
||||
return $this->redirectToRoute('customhtmlblock_index', ['idGroup' => $idGroup]);
|
||||
}
|
||||
|
||||
private function getToolbarButtons(?string $securitySubject): array
|
||||
{
|
||||
$toolbarButtons = [];
|
||||
|
||||
Reference in New Issue
Block a user