Skip to content

Commit

Permalink
added domain filter to inquiry list in admin
Browse files Browse the repository at this point in the history
  • Loading branch information
grossmannmartin committed Nov 6, 2024
1 parent be6de34 commit 6aef288
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/Controller/Admin/InquiryController.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

namespace Shopsys\FrameworkBundle\Controller\Admin;

use Shopsys\FrameworkBundle\Component\Domain\AdminDomainFilterTabsFacade;
use Shopsys\FrameworkBundle\Form\Admin\QuickSearch\QuickSearchFormData;
use Shopsys\FrameworkBundle\Form\Admin\QuickSearch\QuickSearchFormType;
use Shopsys\FrameworkBundle\Model\Inquiry\InquiryFacade;
Expand All @@ -19,11 +20,13 @@ class InquiryController extends AdminBaseController
* @param \Shopsys\FrameworkBundle\Model\Inquiry\InquiryGridFactory $inquiryGridFactory
* @param \Shopsys\FrameworkBundle\Model\Inquiry\InquiryFacade $inquiryFacade
* @param \Shopsys\FrameworkBundle\Model\Localization\Localization $localization
* @param \Shopsys\FrameworkBundle\Component\Domain\AdminDomainFilterTabsFacade $adminDomainFilterTabsFacade
*/
public function __construct(
protected readonly InquiryGridFactory $inquiryGridFactory,
protected readonly InquiryFacade $inquiryFacade,
protected readonly Localization $localization,
protected readonly AdminDomainFilterTabsFacade $adminDomainFilterTabsFacade,
) {
}

Expand All @@ -34,6 +37,8 @@ public function __construct(
#[Route(path: '/inquiry/list/')]
public function listAction(Request $request): Response
{
$domainFilterNamespace = 'inquiries';

$quickSearchForm = $this->createForm(QuickSearchFormType::class, new QuickSearchFormData());
$quickSearchForm->handleRequest($request);

Expand All @@ -42,8 +47,17 @@ public function listAction(Request $request): Response
$this->localization->getAdminLocale(),
);

$selectedDomainId = $this->adminDomainFilterTabsFacade->getSelectedDomainId($domainFilterNamespace);

if ($selectedDomainId !== null) {
$queryBuilder
->andWhere('i.domainId = :selectedDomainId')
->setParameter('selectedDomainId', $selectedDomainId);
}

return $this->render('@ShopsysFramework/Admin/Content/Inquiry/list.html.twig', [
'gridView' => $this->inquiryGridFactory->createView($queryBuilder, $this->getCurrentAdministrator()),
'domainFilterNamespace' => $domainFilterNamespace,
'quickSearchForm' => $quickSearchForm->createView(),
]);
}
Expand Down
2 changes: 2 additions & 0 deletions src/Resources/views/Admin/Content/Inquiry/list.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,5 +20,7 @@
</div>
</div>

{{ render(controller('Shopsys\\FrameworkBundle\\Controller\\Admin\\DomainFilterController::domainFilterTabsAction', { namespace: domainFilterNamespace })) }}

{{ gridView.render() }}
{% endblock %}

0 comments on commit 6aef288

Please sign in to comment.