You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

85 lines
3.3KB

  1. <?php
  2. namespace Lc\SovBundle\Controller\Ticket;
  3. use App\Entity\Ticket\Ticket;
  4. use EasyCorp\Bundle\EasyAdminBundle\Config\Action;
  5. use EasyCorp\Bundle\EasyAdminBundle\Config\Actions;
  6. use EasyCorp\Bundle\EasyAdminBundle\Config\Crud;
  7. use EasyCorp\Bundle\EasyAdminBundle\Config\Filters;
  8. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  9. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  10. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  11. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  12. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  13. use Lc\SovBundle\Field\StatusField;
  14. use Lc\SovBundle\Model\Ticket\TicketInterface;
  15. use Lc\SovBundle\Controller\AbstractAdminController;
  16. abstract class TicketAdminController extends AbstractAdminController
  17. {
  18. public static function getEntityFqcn(): string
  19. {
  20. return TicketInterface::class;
  21. }
  22. public function configureFields(string $pageName): iterable
  23. {
  24. return [
  25. IntegerField::new('id')
  26. ->hideOnForm(),
  27. DateField::new('createdAt')->setFormat('short')
  28. ->hideOnForm(),
  29. TextField::new('visitorFirstName')
  30. ->setTemplatePath('@LcSov/admin/ticket/index-username.html.twig')
  31. ->hideOnForm(),
  32. TextField::new('visitorEmail')
  33. ->setTemplatePath('@LcSov/admin/ticket/index-email.html.twig')
  34. ->hideOnForm(),
  35. AssociationField::new('user')
  36. ->hideOnIndex(),
  37. TextField::new('subject'),
  38. TextField::new('lastMessage')
  39. ->setTemplatePath('@LcSov/admin/ticket/index-lastmessage.html.twig')
  40. ->hideOnForm(),
  41. ChoiceField::new('type')
  42. ->autocomplete()
  43. ->setChoices(
  44. [
  45. 'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_GENERAL_QUESTION => Ticket::TYPE_GENERAL_QUESTION,
  46. 'entity.Ticket.fields.typeOptions.' . Ticket::TYPE_TECHNICAL_PROBLEM => Ticket::TYPE_TECHNICAL_PROBLEM,
  47. ]
  48. ),
  49. ChoiceField::new('status')
  50. ->autocomplete()
  51. ->setChoices(
  52. [
  53. 'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_OPEN => Ticket::TICKET_STATUS_OPEN,
  54. 'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_BEING_PROCESSED => Ticket::TICKET_STATUS_BEING_PROCESSED,
  55. 'entity.Ticket.fields.statusOptions.' . Ticket::TICKET_STATUS_CLOSED => Ticket::TICKET_STATUS_CLOSED,
  56. ]
  57. )
  58. ->setTemplatePath('@LcSov/admin/ticket/index-status.html.twig')
  59. ->hideOnForm(),
  60. ];
  61. }
  62. // public function configureCrud(Crud $crud): Crud
  63. // {
  64. // $crud
  65. // ->overrideTemplate('layout', '@LcSov/admin/layout.html.twig');
  66. //// ->overrideTemplate('layout', '@LcCaracole/adminlte/layout.html.twig');
  67. //
  68. // return parent::configureCrud($crud);
  69. // }
  70. public function configureActions(Actions $actions): Actions
  71. {
  72. $actions
  73. ->add(Crud::PAGE_INDEX, Action::DETAIL);
  74. // ->remove(Crud::PAGE_EDIT, Action::EDIT);
  75. return parent::configureActions($actions);
  76. }
  77. }