feat(main): Draggable blocks

This commit is contained in:
2026-08-12 15:39:07 +02:00
parent 1493081602
commit d0da05845a
8 changed files with 74 additions and 6 deletions
@@ -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 = [];