Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

119 lines
4.6KB

  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\Field\Filter\Ticket\TicketEmailFilter;
  9. use Lc\SovBundle\Field\Filter\Ticket\TicketFirstnameFilter;
  10. use Lc\SovBundle\Field\Filter\Ticket\TicketLastnameFilter;
  11. use Lc\SovBundle\Form\Ticket\TicketMessageAdminFormType;
  12. use Lc\SovBundle\Solver\Ticket\TicketSolver;
  13. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  14. use Lc\SovBundle\Field\CollectionField;
  15. use Lc\SovBundle\Form\Ticket\TicketMessageType;
  16. use Lc\SovBundle\Translation\TranslatorAdmin;
  17. class TicketFieldDefinition extends AbstractFieldDefinition
  18. {
  19. public function __construct(TranslatorAdmin $translatorAdmin)
  20. {
  21. parent::__construct($translatorAdmin);
  22. }
  23. public function configureIndex(): array
  24. {
  25. return [
  26. 'id',
  27. 'createdAt',
  28. 'visitorFirstname',
  29. 'visitorLastname',
  30. 'visitorEmail',
  31. 'subject',
  32. 'updatedAt',
  33. 'type',
  34. 'status'
  35. ];
  36. }
  37. public function configureForm(): array
  38. {
  39. return [
  40. 'user',
  41. 'type',
  42. 'subject',
  43. 'ticketMessages'
  44. ];
  45. }
  46. public function configurePanels(): array
  47. {
  48. return [];
  49. }
  50. public function configureFields(): array
  51. {
  52. return [
  53. 'id' => IdField::new('id')
  54. ->setSortable(true)
  55. ->hideOnForm(),
  56. 'createdAt' => DateTimeField::new('createdAt')
  57. ->setSortable(true)
  58. ->hideOnForm(),
  59. 'visitorFirstname' => TextField::new('visitorFirstname')
  60. ->setTemplatePath('@LcSov/admin/ticket/field/firstname.html.twig')
  61. ->setCustomOption('filter_fqcn', TicketFirstnameFilter::class)
  62. ->setSortable(true)
  63. ->hideOnForm(),
  64. 'visitorLastname' => TextField::new('visitorLastname')
  65. ->setTemplatePath('@LcSov/admin/ticket/field/lastname.html.twig')
  66. ->setCustomOption('filter_fqcn', TicketLastnameFilter::class)
  67. ->setSortable(true)
  68. ->hideOnForm(),
  69. 'visitorEmail' => TextField::new('visitorEmail')
  70. ->setTemplatePath('@LcSov/admin/ticket/field/email.html.twig')
  71. ->setCustomOption('filter_fqcn', TicketEmailFilter::class)
  72. ->setSortable(true)
  73. ->hideOnForm(),
  74. 'user' => AssociationField::new('user')
  75. ->hideOnIndex(),
  76. 'subject' => TextField::new('subject')
  77. ->setSortable(true),
  78. 'updatedAt' => DateTimeField::new('updatedAt')
  79. ->setTemplatePath('@LcSov/admin/ticket/field/lastmessage.html.twig')
  80. ->setSortable(true)
  81. ->hideOnForm(),
  82. 'type' => ChoiceField::new('type')
  83. ->autocomplete()
  84. ->setSortable(true)
  85. ->setChoices(
  86. $this->translatorAdmin->transChoices(
  87. TicketSolver::getTypeChoices(),
  88. 'Ticket',
  89. 'type'
  90. )
  91. ),
  92. 'status' => ChoiceField::new('status')
  93. ->autocomplete()
  94. ->setSortable(true)
  95. ->setChoices(
  96. $this->translatorAdmin->transChoices(
  97. TicketSolver::getStatusChoices(),
  98. 'Ticket',
  99. 'status'
  100. )
  101. )
  102. ->setTemplatePath('@LcSov/admin/ticket/field/status.html.twig'),
  103. 'ticketMessages' => CollectionField::new('ticketMessages')
  104. ->setFormTypeOption('entry_type', TicketMessageAdminFormType::class)
  105. ->setFormTypeOption('allow_add', false)
  106. ->setFormTypeOption('allow_delete', false)
  107. ];
  108. }
  109. }