Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load Users with Autocomplete #531

Merged
merged 1 commit into from
Dec 30, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
* Fix Filters in User Admin
* Fix Filters in Alias Admin
* Improve Performance for Alias and Voucher Admin
* Use Autocomplete for loading Users in Alias and Voucher Admin

# 3.3.1 (2023.11.12)

Expand Down
5 changes: 1 addition & 4 deletions config/packages/dev/nelmio_security.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
nelmio_security:
csp:
enabled: true
enforce:
default-src:
- 'self'
enabled: false
3 changes: 2 additions & 1 deletion src/Admin/AliasAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
use Symfony\Component\Form\Extension\Core\Type\EmailType;
Expand All @@ -29,7 +30,7 @@
{
$form
->add('source', EmailType::class)
->add('user', EntityType::class, ['class' => User::class, 'required' => false])
->add('user', ModelAutocompleteType::class, ['property' => 'email', 'required' => false])

Check warning on line 33 in src/Admin/AliasAdmin.php

View check run for this annotation

Codecov / codecov/patch

src/Admin/AliasAdmin.php#L33

Added line #L33 was not covered by tests
->add('deleted', CheckboxType::class, ['disabled' => true]);

if ($this->security->isGranted(Roles::ADMIN)) {
Expand Down
9 changes: 2 additions & 7 deletions src/Admin/VoucherAdmin.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,17 +6,12 @@
use Sonata\AdminBundle\Datagrid\DatagridMapper;
use Sonata\AdminBundle\Datagrid\ListMapper;
use Sonata\AdminBundle\Form\FormMapper;
use Sonata\AdminBundle\Form\Type\ModelAutocompleteType;
use Sonata\DoctrineORMAdminBundle\Filter\DateTimeRangeFilter;
use Sonata\Form\Type\DateRangePickerType;

class VoucherAdmin extends Admin
{
protected array $datagridValues = [
'_page' => 1,
'_sort_order' => 'DESC',
'_sort_by' => 'creationTime',
];

protected function generateBaseRoutePattern(bool $isChildAdmin = false): string
{
return 'voucher';
Expand All @@ -42,7 +37,7 @@
}

$form
->add('user', null, ['disabled' => $disabled])
->add('user', ModelAutocompleteType::class, ['disabled' => $disabled, 'property' => 'email'])

Check warning on line 40 in src/Admin/VoucherAdmin.php

View check run for this annotation

Codecov / codecov/patch

src/Admin/VoucherAdmin.php#L40

Added line #L40 was not covered by tests
->add('code', null, ['disabled' => !$this->isNewObject()]);
}

Expand Down
Loading