Ви не можете вибрати більше 25 тем Теми мають розпочинатися з літери або цифри, можуть містити дефіси (-) і не повинні перевищувати 35 символів.

109 lines
3.8KB

  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. 'updatedAt',
  29. 'visitorFirstname',
  30. 'visitorLastname',
  31. 'visitorEmail',
  32. 'subject',
  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. 'createdAt' => DateTimeField::new('createdAt')
  56. ->setSortable(true),
  57. 'visitorFirstname' => TextField::new('visitorFirstname')
  58. ->setTemplatePath('@LcSov/admin/ticket/field/firstname.html.twig')
  59. ->setCustomOption('filter_fqcn', TicketFirstnameFilter::class),
  60. 'visitorLastname' => TextField::new('visitorLastname')
  61. ->setTemplatePath('@LcSov/admin/ticket/field/lastname.html.twig')
  62. ->setCustomOption('filter_fqcn', TicketLastnameFilter::class),
  63. 'visitorEmail' => TextField::new('visitorEmail')
  64. ->setTemplatePath('@LcSov/admin/ticket/field/email.html.twig')
  65. ->setCustomOption('filter_fqcn', TicketEmailFilter::class),
  66. 'user' => AssociationField::new('user'),
  67. 'subject' => TextField::new('subject')
  68. ->setSortable(true),
  69. 'updatedAt' => DateTimeField::new('updatedAt')
  70. ->setTemplatePath('@LcSov/admin/ticket/field/lastmessage.html.twig')
  71. ->setSortable(true),
  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. 'ticketMessages' => CollectionField::new('ticketMessages')
  94. ->setFormTypeOption('entry_type', TicketMessageAdminFormType::class)
  95. ->setFormTypeOption('allow_add', false)
  96. ->setFormTypeOption('allow_delete', false)
  97. ];
  98. }
  99. }