|
- <?php
-
- namespace Lc\SovBundle\Definition\Field\Ticket;
-
- use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
- use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
- use Lc\SovBundle\Field\Filter\Ticket\TicketEmailFilter;
- use Lc\SovBundle\Field\Filter\Ticket\TicketFirstnameFilter;
- use Lc\SovBundle\Field\Filter\Ticket\TicketLastnameFilter;
- use Lc\SovBundle\Form\Ticket\TicketMessageAdminFormType;
- use Lc\SovBundle\Solver\Ticket\TicketSolver;
- use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
- use Lc\SovBundle\Field\CollectionField;
- use Lc\SovBundle\Form\Ticket\TicketMessageType;
- use Lc\SovBundle\Translation\TranslatorAdmin;
-
- class TicketFieldDefinition extends AbstractFieldDefinition
- {
- public function __construct(TranslatorAdmin $translatorAdmin)
- {
- parent::__construct($translatorAdmin);
- }
-
- public function configureIndex(): array
- {
- return [
- 'id',
- 'createdAt',
- 'updatedAt',
- 'visitorFirstname',
- 'visitorLastname',
- 'visitorEmail',
- 'subject',
- 'type',
- 'status'
- ];
- }
-
- public function configureForm(): array
- {
- return [
- 'user',
- 'type',
- 'subject',
- 'ticketMessages'
- ];
- }
-
- public function configurePanels(): array
- {
- return [];
- }
-
- public function configureFields(): array
- {
- return [
- 'id' => IdField::new('id')
- ->setSortable(true),
- 'createdAt' => DateTimeField::new('createdAt')
- ->setSortable(true),
- 'visitorFirstname' => TextField::new('visitorFirstname')
- ->setTemplatePath('@LcSov/admin/ticket/field/firstname.html.twig')
- ->setCustomOption('filter_fqcn', TicketFirstnameFilter::class),
- 'visitorLastname' => TextField::new('visitorLastname')
- ->setTemplatePath('@LcSov/admin/ticket/field/lastname.html.twig')
- ->setCustomOption('filter_fqcn', TicketLastnameFilter::class),
- 'visitorEmail' => TextField::new('visitorEmail')
- ->setTemplatePath('@LcSov/admin/ticket/field/email.html.twig')
- ->setCustomOption('filter_fqcn', TicketEmailFilter::class),
- 'user' => AssociationField::new('user'),
- 'subject' => TextField::new('subject')
- ->setSortable(true),
- 'updatedAt' => DateTimeField::new('updatedAt')
- ->setTemplatePath('@LcSov/admin/ticket/field/lastmessage.html.twig')
- ->setSortable(true),
- 'type' => ChoiceField::new('type')
- ->autocomplete()
- ->setSortable(true)
- ->setChoices(
- $this->translatorAdmin->transChoices(
- TicketSolver::getTypeChoices(),
- 'Ticket',
- 'type'
- )
- ),
- 'status' => ChoiceField::new('status')
- ->autocomplete()
- ->setSortable(true)
- ->setChoices(
- $this->translatorAdmin->transChoices(
- TicketSolver::getStatusChoices(),
- 'Ticket',
- 'status'
- )
- )
- ->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig'),
-
- 'ticketMessages' => CollectionField::new('ticketMessages')
- ->setFormTypeOption('entry_type', TicketMessageAdminFormType::class)
- ->setFormTypeOption('allow_add', false)
- ->setFormTypeOption('allow_delete', false)
- ];
- }
-
- }
|