diff --git a/expose/api/src/Controller/Admin/AssetCrudController.php b/expose/api/src/Controller/Admin/AssetCrudController.php index f58d9f353..b5c1eb28a 100644 --- a/expose/api/src/Controller/Admin/AssetCrudController.php +++ b/expose/api/src/Controller/Admin/AssetCrudController.php @@ -2,19 +2,23 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use App\Entity\Asset; use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\JsonField; -use App\Entity\Asset; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; -use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; use EasyCorp\Bundle\EasyAdminBundle\Field\NumberField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; +use Alchemy\AdminBundle\Filter\AssociationIdentifierFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; class AssetCrudController extends AbstractAdminCrudController { @@ -36,6 +40,18 @@ public function configureCrud(Crud $crud): Crud ->setEntityLabelInPlural('Asset'); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('title')) + ->add(TextFilter::new('ownerId')) + ->add(TextFilter::new('mimeType')) + ->add(AssociationIdentifierFilter::new('publication')) + ->add(DateTimeFilter::new('createdAt')) + ; + } + public function configureFields(string $pageName): iterable { yield IdField::new(); diff --git a/expose/api/src/Controller/Admin/PublicationCrudController.php b/expose/api/src/Controller/Admin/PublicationCrudController.php index 23c09c192..d1d9956a5 100644 --- a/expose/api/src/Controller/Admin/PublicationCrudController.php +++ b/expose/api/src/Controller/Admin/PublicationCrudController.php @@ -2,20 +2,22 @@ namespace App\Controller\Admin; -use Alchemy\AclBundle\Admin\PermissionView; -use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; -use Alchemy\AdminBundle\Field\IdField; -use Alchemy\AdminBundle\Field\JsonField; use App\Entity\Publication; use App\Field\PublicationConfigField; +use Alchemy\AdminBundle\Field\IdField; +use Alchemy\AdminBundle\Field\JsonField; +use Alchemy\AclBundle\Admin\PermissionView; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; class PublicationCrudController extends AbstractAclAdminCrudController { @@ -45,7 +47,11 @@ public function configureCrud(Crud $crud): Crud public function configureFilters(Filters $filters): Filters { return $filters - ->add('profile'); + ->add(TextFilter::new('id')) + ->add(TextFilter::new('title')) + ->add(TextFilter::new('ownerId')) + ->add(EntityFilter::new('profile')) + ; } public function configureFields(string $pageName): iterable diff --git a/expose/api/src/Controller/Admin/PublicationProfileCrudController.php b/expose/api/src/Controller/Admin/PublicationProfileCrudController.php index c5b589b6e..5047ceab5 100644 --- a/expose/api/src/Controller/Admin/PublicationProfileCrudController.php +++ b/expose/api/src/Controller/Admin/PublicationProfileCrudController.php @@ -2,14 +2,16 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; -use Alchemy\AdminBundle\Field\IdField; use App\Entity\PublicationProfile; use App\Field\PublicationConfigField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use Alchemy\AdminBundle\Field\IdField; use EasyCorp\Bundle\EasyAdminBundle\Field\Field; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; class PublicationProfileCrudController extends AbstractAclAdminCrudController { @@ -18,6 +20,15 @@ public static function getEntityFqcn(): string return PublicationProfile::class; } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('name')) + ->add(TextFilter::new('ownerId')) + ; + } + public function configureFields(string $pageName): iterable { yield IdField::new(); diff --git a/expose/api/src/Controller/Admin/SubDefinitionCrudController.php b/expose/api/src/Controller/Admin/SubDefinitionCrudController.php index c74a397ab..4a791e52f 100644 --- a/expose/api/src/Controller/Admin/SubDefinitionCrudController.php +++ b/expose/api/src/Controller/Admin/SubDefinitionCrudController.php @@ -2,16 +2,20 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; -use Alchemy\AdminBundle\Field\IdField; use App\Entity\SubDefinition; +use Alchemy\AdminBundle\Field\IdField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; -use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use Alchemy\AdminBundle\Filter\AssociationIdentifierFilter; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; class SubDefinitionCrudController extends AbstractAdminCrudController { @@ -33,6 +37,16 @@ public function configureCrud(Crud $crud): Crud ->setEntityLabelInPlural('SubDefinition'); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('name')) + ->add(AssociationIdentifierFilter::new('asset')) + ->add(DateTimeFilter::new('createdAt')) + ; + } + public function configureFields(string $pageName): iterable { $name = TextField::new('name'); diff --git a/lib/php/admin-bundle/Controller/MultipartUploadCrudController.php b/lib/php/admin-bundle/Controller/MultipartUploadCrudController.php index e45c60cfb..646d1c91d 100644 --- a/lib/php/admin-bundle/Controller/MultipartUploadCrudController.php +++ b/lib/php/admin-bundle/Controller/MultipartUploadCrudController.php @@ -3,14 +3,18 @@ namespace Alchemy\AdminBundle\Controller; use Alchemy\AdminBundle\Field\IdField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use Alchemy\StorageBundle\Entity\MultipartUpload; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; class MultipartUploadCrudController extends AbstractAdminCrudController { @@ -33,6 +37,17 @@ public function configureCrud(Crud $crud): Crud ->setEntityLabelInPlural('MultipartUpload'); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('type')) + ->add(TextFilter::new('filename')) + ->add(BooleanFilter::new('complete')) + ->add(DateTimeFilter::new('createdAt')) + ; + } + public function configureFields(string $pageName): iterable { yield IdField::new(); diff --git a/uploader/api/src/Controller/Admin/AssetCrudController.php b/uploader/api/src/Controller/Admin/AssetCrudController.php index 025abc99f..4648b03fe 100644 --- a/uploader/api/src/Controller/Admin/AssetCrudController.php +++ b/uploader/api/src/Controller/Admin/AssetCrudController.php @@ -2,18 +2,23 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use App\Entity\Asset; use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\JsonField; -use App\Entity\Asset; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; +use Alchemy\AdminBundle\Filter\AssociationIdentifierFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; class AssetCrudController extends AbstractAdminCrudController { @@ -39,17 +44,25 @@ public function configureCrud(Crud $crud): Crud ->setSearchFields(['id', 'path', 'size', 'originalName', 'mimeType', 'userId']); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('mimeType')) + ->add(BooleanFilter::new('acknowledged')) + ->add(AssociationIdentifierFilter::new('commit')) + ->add(DateTimeFilter::new('createdAt')) + ; + } + public function configureFields(string $pageName): iterable { yield IdField::new(); yield IdField::new('userId'); yield IntegerField::new('size') - ->setTemplatePath('@AlchemyAdmin/list/file_size.html.twig') - ->hideOnIndex(); - yield TextField::new('originalName') - ->hideOnIndex(); - yield TextField::new('mimeType') - ->hideOnIndex(); + ->setTemplatePath('@AlchemyAdmin/list/file_size.html.twig'); + yield TextField::new('originalName'); + yield TextField::new('mimeType'); yield TextField::new('path') ->hideOnIndex(); yield JsonField::new('formData') diff --git a/uploader/api/src/Controller/Admin/CommitCrudController.php b/uploader/api/src/Controller/Admin/CommitCrudController.php index 7d09002ef..ead26da0f 100644 --- a/uploader/api/src/Controller/Admin/CommitCrudController.php +++ b/uploader/api/src/Controller/Admin/CommitCrudController.php @@ -2,23 +2,27 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use App\Entity\Commit; use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\JsonField; -use Alchemy\AdminBundle\Field\UserChoiceField; use App\Consumer\Handler\AssetConsumerNotify; -use App\Entity\Commit; +use Alchemy\AdminBundle\Field\UserChoiceField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; use EasyCorp\Bundle\EasyAdminBundle\Config\Action; use EasyCorp\Bundle\EasyAdminBundle\Config\Actions; -use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use Symfony\Component\Messenger\MessageBusInterface; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Context\AdminContext; +use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; use EasyCorp\Bundle\EasyAdminBundle\Router\AdminUrlGenerator; -use Symfony\Component\Messenger\MessageBusInterface; +use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; class CommitCrudController extends AbstractAdminCrudController { @@ -52,6 +56,17 @@ public function configureCrud(Crud $crud): Crud ->setSearchFields(['id', 'totalSize', 'formData', 'options', 'userId', 'token', 'notifyEmail', 'locale']); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('id')) + ->add(TextFilter::new('userId')) + ->add(BooleanFilter::new('acknowledged')) + ->add(DateTimeFilter::new('acknowledgedAt')) + ->add(DateTimeFilter::new('createdAt')) + ; + } + public function configureFields(string $pageName): iterable { yield IdField::new(); diff --git a/uploader/api/src/Controller/Admin/FormSchemaCrudController.php b/uploader/api/src/Controller/Admin/FormSchemaCrudController.php index b9b17846f..cdfb7f25b 100644 --- a/uploader/api/src/Controller/Admin/FormSchemaCrudController.php +++ b/uploader/api/src/Controller/Admin/FormSchemaCrudController.php @@ -2,15 +2,17 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; +use App\Entity\FormSchema; use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\JsonField; -use App\Entity\FormSchema; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Filter\EntityFilter; class FormSchemaCrudController extends AbstractAclAdminCrudController { @@ -27,26 +29,23 @@ public function configureCrud(Crud $crud): Crud ->setSearchFields(['id', 'locale', 'data']); } - public function configureFields(string $pageName): iterable + public function configureFilters(Filters $filters): Filters { - $target = AssociationField::new('target'); - $locale = TextField::new('locale'); - $jsonData = TextareaField::new('jsonData'); - $id = IdField::new(); - $data = JsonField::new('data'); - $createdAt = DateTimeField::new('createdAt'); - $updatedAt = DateTimeField::new('updatedAt'); - - if (Crud::PAGE_INDEX === $pageName) { - return [$id, $target, $locale, $createdAt]; - } elseif (Crud::PAGE_DETAIL === $pageName) { - return [$id, $locale, $createdAt, $updatedAt, $target, $data]; - } elseif (Crud::PAGE_NEW === $pageName) { - return [$target, $locale, $jsonData]; - } elseif (Crud::PAGE_EDIT === $pageName) { - return [$target, $locale, $jsonData]; - } + return $filters + ->add(EntityFilter::new('target')) + ->add(DateTimeFilter::new('createdAt')) + ; + } - return []; + public function configureFields(string $pageName): iterable + { + yield IdField::new(); + yield AssociationField::new('target'); + yield TextField::new('locale'); + yield DateTimeField::new('createdAt') + ->hideOnForm(); + yield DateTimeField::new('updatedAt') + ->onlyOnDetail(); + yield JsonField::new('data', 'jsonData'); } } diff --git a/uploader/api/src/Controller/Admin/MultipartUploadCrudController.php b/uploader/api/src/Controller/Admin/MultipartUploadCrudController.php deleted file mode 100644 index 117b98111..000000000 --- a/uploader/api/src/Controller/Admin/MultipartUploadCrudController.php +++ /dev/null @@ -1,63 +0,0 @@ -remove(Crud::PAGE_INDEX, Action::EDIT) - ->remove(Crud::PAGE_INDEX, Action::NEW); - } - - public function configureCrud(Crud $crud): Crud - { - return parent::configureCrud($crud) - ->setEntityLabelInSingular('MultipartUpload') - ->setEntityLabelInPlural('MultipartUpload') - ->setDefaultSort(['createdAt' => 'DESC']) - ->setSearchFields(['id', 'filename', 'type', 'sizeAsString', 'uploadId', 'path']); - } - - public function configureFields(string $pageName): iterable - { - $filename = TextField::new('filename'); - $type = TextField::new('type'); - $sizeAsString = TextField::new('sizeAsString'); - $uploadId = TextField::new('uploadId'); - $path = TextField::new('path'); - $complete = BooleanField::new('complete')->renderAsSwitch(false); - $createdAt = DateTimeField::new('createdAt'); - $id = IdField::new(); - $size = IntegerField::new('size')->setTemplatePath('@AlchemyAdmin/list/file_size.html.twig'); - - if (Crud::PAGE_INDEX === $pageName) { - return [$id, $filename, $type, $size, $path, $uploadId, $complete, $createdAt]; - } elseif (Crud::PAGE_DETAIL === $pageName) { - return [$id, $filename, $type, $sizeAsString, $uploadId, $path, $complete, $createdAt]; - } elseif (Crud::PAGE_NEW === $pageName) { - return [$filename, $type, $sizeAsString, $uploadId, $path, $complete, $createdAt]; - } elseif (Crud::PAGE_EDIT === $pageName) { - return [$filename, $type, $sizeAsString, $uploadId, $path, $complete, $createdAt]; - } - - return []; - } -} diff --git a/uploader/api/src/Controller/Admin/TargetCrudController.php b/uploader/api/src/Controller/Admin/TargetCrudController.php index 4dc0cd7eb..9c5464e17 100644 --- a/uploader/api/src/Controller/Admin/TargetCrudController.php +++ b/uploader/api/src/Controller/Admin/TargetCrudController.php @@ -2,16 +2,20 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use App\Entity\Target; +use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\CodeField; use Alchemy\AdminBundle\Field\GroupChoiceField; -use Alchemy\AdminBundle\Field\IdField; -use App\Entity\Target; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\Field; -use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Field\TextField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\TextFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; +use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\BooleanFilter; +use Alchemy\AdminBundle\Controller\AbstractAdminCrudController; +use EasyCorp\Bundle\EasyAdminBundle\Field\BooleanField; class TargetCrudController extends AbstractAdminCrudController { @@ -29,33 +33,39 @@ public function configureCrud(Crud $crud): Crud ->setSearchFields(['id', 'slug', 'name', 'description', 'targetUrl', 'defaultDestination', 'targetAccessToken', 'targetTokenType', 'allowedGroups']); } + public function configureFilters(Filters $filters): Filters + { + return $filters + ->add(TextFilter::new('name')) + ->add(BooleanFilter::new('enabled')) + ; + } + public function configureFields(string $pageName): iterable { - $name = TextField::new('name'); - $slug = TextField::new('slug'); - $description = TextareaField::new('description'); - $targetUrl = TextField::new('targetUrl') + yield IdField::new() + ->hideOnForm(); + yield TextField::new('slug'); + yield TextField::new('name'); + yield TextareaField::new('description') + ->hideOnIndex(); + yield CodeField::new('pullModeUrl', 'Pull mode URL') + ->onlyOnIndex(); + yield TextField::new('targetUrl') ->setHelp('Leave empty for pull mode. i.e: "https://phraseanet.phrasea.local/api/v1/upload/enqueue/" for Phraseanet, "http://databox-api/incoming-uploads" for Databox upload'); - $targetTokenType = TextField::new('targetTokenType') + yield TextField::new('targetTokenType') ->setHelp('Use "OAuth" for Phraseanet') - ->setFormTypeOptions(['attr' => ['placeholder' => 'Defaults to "Bearer"']]); - $targetAccessToken = TextField::new('targetAccessToken'); - $defaultDestination = TextField::new('defaultDestination') - ->setHelp('i.e: "42" (for Phraseanet collection), "cdc3679f-3f37-4260-8de7-b649ecc8c1cc" (for Databox collection)'); - $allowedGroups = GroupChoiceField::new('allowedGroups'); - $enabled = Field::new('enabled'); - $id = IdField::new(); - $createdAt = DateTimeField::new('createdAt'); - $pullModeUrl = CodeField::new('pullModeUrl', 'Pull mode URL'); - - if (Crud::PAGE_INDEX === $pageName) { - return [$id, $slug, $name, $pullModeUrl, $targetUrl, $enabled, $createdAt]; - } elseif (Crud::PAGE_NEW === $pageName) { - return [$slug, $name, $description, $targetUrl, $targetTokenType, $targetAccessToken, $defaultDestination, $allowedGroups, $enabled]; - } elseif (Crud::PAGE_EDIT === $pageName) { - return [$slug, $name, $description, $targetUrl, $targetTokenType, $targetAccessToken, $defaultDestination, $allowedGroups, $enabled]; - } + ->setFormTypeOptions(['attr' => ['placeholder' => 'Defaults to "Bearer"']]) + ->onlyOnForms(); + yield TextField::new('targetAccessToken'); + yield TextField::new('defaultDestination') + ->setHelp('i.e: "42" (for Phraseanet collection), "cdc3679f-3f37-4260-8de7-b649ecc8c1cc" (for Databox collection)') + ->hideOnIndex(); + yield GroupChoiceField::new('allowedGroups') + ->hideOnIndex(); + yield BooleanField::new('enabled'); + yield DateTimeField::new('createdAt') + ->hideOnForm(); - return []; } } diff --git a/uploader/api/src/Controller/Admin/TargetParamsCrudController.php b/uploader/api/src/Controller/Admin/TargetParamsCrudController.php index 30c8df891..f9c001094 100644 --- a/uploader/api/src/Controller/Admin/TargetParamsCrudController.php +++ b/uploader/api/src/Controller/Admin/TargetParamsCrudController.php @@ -2,14 +2,17 @@ namespace App\Controller\Admin; -use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; +use App\Entity\TargetParams; use Alchemy\AdminBundle\Field\IdField; use Alchemy\AdminBundle\Field\JsonField; -use App\Entity\TargetParams; use EasyCorp\Bundle\EasyAdminBundle\Config\Crud; -use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use EasyCorp\Bundle\EasyAdminBundle\Config\Filters; use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField; use EasyCorp\Bundle\EasyAdminBundle\Field\TextareaField; +use EasyCorp\Bundle\EasyAdminBundle\Filter\DateTimeFilter; +use Alchemy\AdminBundle\Filter\AssociationIdentifierFilter; +use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField; +use Alchemy\AdminBundle\Controller\Acl\AbstractAclAdminCrudController; class TargetParamsCrudController extends AbstractAclAdminCrudController { @@ -26,25 +29,25 @@ public function configureCrud(Crud $crud): Crud ->setSearchFields(['id', 'data']); } - public function configureFields(string $pageName): iterable + public function configureFilters(Filters $filters): Filters { - $target = AssociationField::new('target'); - $jsonData = TextareaField::new('jsonData'); - $id = IdField::new(); - $data = JsonField::new('data'); - $createdAt = DateTimeField::new('createdAt'); - $updatedAt = DateTimeField::new('updatedAt'); - - if (Crud::PAGE_INDEX === $pageName) { - return [$id, $target, $createdAt]; - } elseif (Crud::PAGE_DETAIL === $pageName) { - return [$id, $createdAt, $updatedAt, $target, $data]; - } elseif (Crud::PAGE_NEW === $pageName) { - return [$target, $jsonData]; - } elseif (Crud::PAGE_EDIT === $pageName) { - return [$target, $jsonData]; - } + return $filters + ->add(AssociationIdentifierFilter::new('target')) + ->add(DateTimeFilter::new('createdAt')) + ; + } - return []; + public function configureFields(string $pageName): iterable + { + yield IdField::new(); + yield AssociationField::new('target'); + yield TextareaField::new('jsonData') + ->hideOnIndex(); + yield JsonField::new('data') + ->onlyOnDetail(); + yield DateTimeField::new('createdAt') + ->hideOnForm(); + yield DateTimeField::new('updatedAt') + ->onlyOnDetail(); } }