add possibility to generate filter/order elements, with only search box

for now
This commit is contained in:
2021-10-08 16:50:31 +02:00
parent e286acf9fe
commit 4d71a1c630
15 changed files with 325 additions and 89 deletions

View File

@@ -5,6 +5,7 @@ namespace Chill\ThirdPartyBundle\Controller;
use Chill\MainBundle\CRUD\Controller\AbstractCRUDController;
use Chill\MainBundle\CRUD\Controller\CRUDController;
use Chill\MainBundle\Pagination\PaginatorInterface;
use Chill\MainBundle\Templating\Listing\FilterOrderHelper;
use Chill\ThirdPartyBundle\Repository\ThirdPartyACLAwareRepositoryInterface;
use Chill\ThirdPartyBundle\Repository\ThirdPartyRepository;
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
@@ -56,15 +57,20 @@ final class ThirdPartyController extends CRUDController
$this->thirdPartyACLAwareRepository = $thirdPartyACLAwareRepository;
}
protected function countEntities(string $action, Request $request): int
protected function countEntities(string $action, Request $request, ?FilterOrderHelper $filterOrder = null): int
{
return $this->thirdPartyACLAwareRepository->countThirdParties(ThirdPartyVoter::SHOW);
if (NULL === $filterOrder){
throw new \LogicException('filterOrder should not be null');
}
return $this->thirdPartyACLAwareRepository->countThirdParties(ThirdPartyVoter::SHOW,
$filterOrder->getQueryString());
}
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator)
protected function getQueryResult(string $action, Request $request, int $totalItems, PaginatorInterface $paginator, ?FilterOrderHelper $filterOrder = null)
{
return $this->thirdPartyACLAwareRepository
->listThirdParties(ThirdPartyVoter::class, ['name' => 'ASC'], $paginator->getItemsPerPage(),
->listThirdParties(ThirdPartyVoter::SHOW, $filterOrder->getQueryString(), ['name' => 'ASC'], $paginator->getItemsPerPage(),
$paginator->getCurrentPageFirstItemNumber());
}
@@ -78,4 +84,12 @@ final class ThirdPartyController extends CRUDController
return null;
}
protected function buildFilterOrderHelper(string $action, Request $request): ?FilterOrderHelper
{
return $this->getFilterOrderHelperFactory()
->create(self::class)
->addSearchBox(['name', 'company_name', 'acronym'])
->build();
}
}