Nevar pievienot vairāk kā 25 tēmas Tēmai ir jāsākas ar burtu vai ciparu, tā var saturēt domu zīmes ('-') un var būt līdz 35 simboliem gara.

96 rindas
3.3KB

  1. <?php
  2. namespace Lc\SovBundle\Definition\Field\User;
  3. use EasyCorp\Bundle\EasyAdminBundle\Field\ArrayField;
  4. use EasyCorp\Bundle\EasyAdminBundle\Field\ChoiceField;
  5. use EasyCorp\Bundle\EasyAdminBundle\Field\DateField;
  6. use EasyCorp\Bundle\EasyAdminBundle\Field\IntegerField;
  7. use EasyCorp\Bundle\EasyAdminBundle\Field\TextField;
  8. use Lc\CaracoleBundle\Field\AssociationField;
  9. use Lc\SovBundle\Definition\Field\AbstractFieldDefinition;
  10. use Lc\SovBundle\Definition\RolesDefinition;
  11. use Lc\SovBundle\Solver\Ticket\TicketSolver;
  12. use Lc\SovBundle\Solver\User\UserSolver;
  13. use Lc\SovBundle\Translation\TranslatorAdmin;
  14. class UserFieldDefinition extends AbstractFieldDefinition
  15. {
  16. protected RolesDefinition $rolesDefinition;
  17. public function __construct(TranslatorAdmin $translatorAdmin, RolesDefinition $rolesDefinition)
  18. {
  19. parent::__construct($translatorAdmin);
  20. $this->rolesDefinition = $rolesDefinition;
  21. }
  22. public function configureFieldsIndex(): array
  23. {
  24. return [
  25. 'id',
  26. 'gender',
  27. 'lastname',
  28. 'firstname',
  29. 'email',
  30. 'groupUsers'
  31. ];
  32. }
  33. public function configureFieldsForm(): array
  34. {
  35. return [
  36. 'id',
  37. 'gender',
  38. 'lastname',
  39. 'firstname',
  40. 'email',
  41. 'phone',
  42. 'birthdate',
  43. 'groupUsers',
  44. 'ticketTypesNotification'
  45. ];
  46. }
  47. public function configurePanels(): array
  48. {
  49. return [];
  50. }
  51. public function configureFields(): array
  52. {
  53. return [
  54. 'id' => IntegerField::new('id')->onlyOnIndex()->setSortable(true),
  55. 'gender' => ChoiceField::new('gender')->setChoices(
  56. $this->translatorAdmin->transChoices(UserSolver::getGenderChoices(), 'User', 'gender')
  57. )
  58. ->setFormTypeOption('expanded', true)
  59. ->setFormTypeOption('multiple', false)
  60. ->setSortable(true),
  61. 'lastname' => TextField::new('lastname')->setSortable(true),
  62. 'firstname' => TextField::new('firstname')->setSortable(true),
  63. 'email' => TextField::new('email')->setSortable(true),
  64. 'phone' => TextField::new('phone')->setSortable(true),
  65. 'birthdate' => DateField::new('birthdate')
  66. ->setFormTypeOption('required', false)
  67. ->setSortable(true),
  68. 'groupUsers' => AssociationField::new('groupUsers')->setSortable(true),
  69. 'ticketTypesNotification' => ChoiceField::new('ticketTypesNotification')
  70. ->setSortable(true)
  71. ->setFormTypeOption('expanded', false)
  72. ->setFormTypeOption('multiple', true)
  73. ->setChoices($this->translatorAdmin->transChoices(
  74. TicketSolver::getTypeChoices(),
  75. 'Ticket',
  76. 'type'
  77. )),
  78. 'roles' => ChoiceField::new('roles')
  79. ->allowMultipleChoices()
  80. ->autocomplete()
  81. ->setChoices($this->rolesDefinition->getRolesList()),
  82. ];
  83. }
  84. }