Skip to content

Commit

Permalink
PS-679 : Admin expose and uploader - More filters (yield) (#471)
Browse files Browse the repository at this point in the history
  • Loading branch information
aynsix authored Oct 28, 2024
1 parent 186fcbd commit 7eeded3
Show file tree
Hide file tree
Showing 11 changed files with 224 additions and 185 deletions.
30 changes: 23 additions & 7 deletions expose/api/src/Controller/Admin/AssetCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
Expand Down
22 changes: 14 additions & 8 deletions expose/api/src/Controller/Admin/PublicationCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
Expand Down
26 changes: 20 additions & 6 deletions expose/api/src/Controller/Admin/SubDefinitionCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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');
Expand Down
21 changes: 18 additions & 3 deletions lib/php/admin-bundle/Controller/MultipartUploadCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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();
Expand Down
37 changes: 25 additions & 12 deletions uploader/api/src/Controller/Admin/AssetCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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')
Expand Down
33 changes: 24 additions & 9 deletions uploader/api/src/Controller/Admin/CommitCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -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();
Expand Down
47 changes: 23 additions & 24 deletions uploader/api/src/Controller/Admin/FormSchemaCrudController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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');
}
}
Loading

0 comments on commit 7eeded3

Please sign in to comment.