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.

107 lines
4.0KB

  1. <?php
  2. namespace Lc\SovBundle\Definition\Field\Ticket;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\AssociationField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\DateTimeField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\IdField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  8. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  9. use Lc\SovBundle\Field\Filter\Ticket\EmailTicketFilter;
  10. use Lc\SovBundle\Field\Filter\Ticket\FirstnameTicketFilter;
  11. use Lc\SovBundle\Field\Filter\Ticket\LastnameTicketFilter;
  12. use Lc\SovBundle\Solver\Ticket\TicketSolver;
  13. class TicketFieldDefinition extends AbstractFieldDefinition
  14. {
  15. public function configureIndex(): array
  16. {
  17. return [
  18. 'id',
  19. 'createdAt',
  20. 'visitorFirstname',
  21. 'visitorLastname',
  22. 'visitorEmail',
  23. 'subject',
  24. 'updatedAt',
  25. 'type',
  26. 'status'
  27. ];
  28. }
  29. public function configureForm(): array
  30. {
  31. return [
  32. 'user',
  33. 'subject'
  34. ];
  35. }
  36. public function configurePanels(): array
  37. {
  38. return [];
  39. }
  40. public function configureFields(): array
  41. {
  42. return [
  43. 'id' => IdField::new('id')
  44. ->setSortable(true)
  45. ->hideOnForm(),
  46. 'createdAt' => DateTimeField::new('createdAt')
  47. ->setSortable(true)
  48. ->hideOnForm(),
  49. 'visitorFirstname' => TextField::new('visitorFirstname')
  50. ->setTemplatePath('@LcSov/admin/ticket/field/firstname.html.twig')
  51. ->setCustomOption('filter_fqcn', FirstnameTicketFilter::class)
  52. ->setSortable(true)
  53. ->hideOnForm(),
  54. 'visitorLastname' => TextField::new('visitorLastname')
  55. ->setTemplatePath('@LcSov/admin/ticket/field/lastname.html.twig')
  56. ->setCustomOption('filter_fqcn', LastnameTicketFilter::class)
  57. ->setSortable(true)
  58. ->hideOnForm(),
  59. 'visitorEmail' => TextField::new('visitorEmail')
  60. ->setTemplatePath('@LcSov/admin/ticket/field/email.html.twig')
  61. ->setCustomOption('filter_fqcn', EmailTicketFilter::class)
  62. ->setSortable(true)
  63. ->hideOnForm(),
  64. 'user' => AssociationField::new('user')
  65. ->hideOnIndex(),
  66. 'subject' => TextField::new('subject')
  67. ->setSortable(true),
  68. 'updatedAt' => DateTimeField::new('updatedAt')
  69. ->setTemplatePath('@LcSov/admin/ticket/field/lastmessage.html.twig')
  70. ->setSortable(true)
  71. ->hideOnForm(),
  72. 'type' => ChoiceField::new('type')
  73. ->autocomplete()
  74. ->setSortable(true)
  75. ->setChoices(
  76. $this->translatorAdmin->transChoices(
  77. TicketSolver::getTypeChoices(),
  78. 'Ticket',
  79. 'type'
  80. )
  81. ),
  82. 'status' => ChoiceField::new('status')
  83. ->autocomplete()
  84. ->setSortable(true)
  85. ->setChoices(
  86. $this->translatorAdmin->transChoices(
  87. TicketSolver::getStatusChoices(),
  88. 'Ticket',
  89. 'status'
  90. )
  91. )
  92. ->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig')
  93. ->hideOnForm(),
  94. ];
  95. }
  96. }