feat(main): Draggable blocks
This commit is contained in:
@@ -8,6 +8,7 @@ use PrestaShop\PrestaShop\Core\Grid\Action\Row\Type\LinkRowAction;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Action\Type\SimpleGridAction;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Column\ColumnCollection;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\ActionColumn;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\Common\PositionColumn;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Column\Type\DataColumn;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\AbstractGridDefinitionFactory;
|
||||
use PrestaShop\PrestaShop\Core\Grid\Definition\Factory\DeleteActionTrait;
|
||||
@@ -84,9 +85,18 @@ final class CustomHtmlBlockGridDefinitionFactory extends AbstractGridDefinitionF
|
||||
->setOptions(['field' => 'active'])
|
||||
)
|
||||
->add(
|
||||
(new DataColumn('ordering'))
|
||||
(new PositionColumn('position'))
|
||||
->setName($this->trans('Position', [], 'Modules.Wscustomhtml.Admin'))
|
||||
->setOptions(['field' => 'ordering'])
|
||||
->setOptions([
|
||||
'id_field' => 'id_ws_customhtml',
|
||||
'position_field' => 'ordering',
|
||||
'update_method' => 'POST',
|
||||
'update_route' => 'customhtmlblock_update_position',
|
||||
'record_route_params' => [
|
||||
'id_ws_customhtml_group' => 'idGroup',
|
||||
],
|
||||
'required_filter' => 'id_ws_customhtml_group',
|
||||
])
|
||||
)
|
||||
->add(
|
||||
(new DataColumn('date_add'))
|
||||
|
||||
@@ -14,7 +14,7 @@ final class CustomHtmlBlockFilters extends Filters
|
||||
return [
|
||||
'limit' => 10,
|
||||
'offset' => 0,
|
||||
'orderBy' => 'wchb.id_ws_customhtml',
|
||||
'orderBy' => 'position',
|
||||
'sortOrder' => 'asc',
|
||||
'filters' => [],
|
||||
];
|
||||
|
||||
@@ -43,6 +43,7 @@ final class CustomHtmlBlockQueryBuilder extends AbstractDoctrineQueryBuilder
|
||||
|
||||
$qb->select(
|
||||
'wchb.`id_ws_customhtml`',
|
||||
'wchb.`id_ws_customhtml_group`',
|
||||
'wchb.`title`',
|
||||
'wchg.`title` AS group_title',
|
||||
'wchb.`type`',
|
||||
@@ -53,8 +54,10 @@ final class CustomHtmlBlockQueryBuilder extends AbstractDoctrineQueryBuilder
|
||||
|
||||
$this->applyFilters($qb, $searchCriteria);
|
||||
|
||||
$orderBy = $searchCriteria->getOrderBy() === 'position' ? 'wchb.ordering' : $searchCriteria->getOrderBy();
|
||||
|
||||
$qb
|
||||
->orderBy($searchCriteria->getOrderBy(), $searchCriteria->getOrderWay())
|
||||
->orderBy($orderBy, $searchCriteria->getOrderWay())
|
||||
->setFirstResult($searchCriteria->getOffset() ?? 0)
|
||||
->setMaxResults($searchCriteria->getLimit());
|
||||
|
||||
|
||||
Reference in New Issue
Block a user