diff --git a/src/Bundle/ChillEventBundle/Controller/Admin/EventBudgetKindController.php b/src/Bundle/ChillEventBundle/Controller/Admin/EventBudgetKindController.php new file mode 100644 index 000000000..063ca4c0d --- /dev/null +++ b/src/Bundle/ChillEventBundle/Controller/Admin/EventBudgetKindController.php @@ -0,0 +1,28 @@ +addOrderBy('e.type', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillEventBundle/DependencyInjection/ChillEventExtension.php b/src/Bundle/ChillEventBundle/DependencyInjection/ChillEventExtension.php index ecc072a58..cb59bb390 100644 --- a/src/Bundle/ChillEventBundle/DependencyInjection/ChillEventExtension.php +++ b/src/Bundle/ChillEventBundle/DependencyInjection/ChillEventExtension.php @@ -11,8 +11,11 @@ declare(strict_types=1); namespace Chill\EventBundle\DependencyInjection; +use Chill\EventBundle\Controller\Admin\EventBudgetKindController; use Chill\EventBundle\Controller\EventThemeController; +use Chill\EventBundle\Entity\EventBudgetKind; use Chill\EventBundle\Entity\EventTheme; +use Chill\EventBundle\Form\EventBudgetKindType; use Chill\EventBundle\Form\EventThemeType; use Chill\EventBundle\Security\EventVoter; use Chill\EventBundle\Security\ParticipationVoter; @@ -114,6 +117,27 @@ class ChillEventExtension extends Extension implements PrependExtensionInterface ], ], ], + [ + 'class' => EventBudgetKind::class, + 'name' => 'event_budget_kind', + 'base_path' => '/admin/event/budget', + 'form_class' => EventBudgetKindType::class, + 'controller' => EventBudgetKindController::class, + 'actions' => [ + 'index' => [ + 'template' => '@ChillEvent/Admin/BudgetKind/index.html.twig', + 'role' => 'ROLE_ADMIN', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillEvent/Admin/BudgetKind/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillEvent/Admin/BudgetKind/edit.html.twig', + ], + ], + ], ], ]); } diff --git a/src/Bundle/ChillEventBundle/Entity/BudgetTypeEnum.php b/src/Bundle/ChillEventBundle/Entity/BudgetTypeEnum.php new file mode 100644 index 000000000..a0a02455c --- /dev/null +++ b/src/Bundle/ChillEventBundle/Entity/BudgetTypeEnum.php @@ -0,0 +1,18 @@ + true])] + private bool $isActive = true; + + #[ORM\Column(enumType: BudgetTypeEnum::class)] + private BudgetTypeEnum $type; + + #[ORM\Column(type: Types::JSON, length: 255, options: ['default' => '{}', 'jsonb' => true])] + private array $name = []; + + public function getId(): ?int + { + return $this->id; + } + + public function getIsActive(): bool + { + return $this->isActive; + } + + public function getType(): BudgetTypeEnum + { + return $this->type; + } + + public function getName(): ?array + { + return $this->name; + } + + public function setIsActive(bool $isActive): self + { + $this->isActive = $isActive; + + return $this; + } + + public function setType(BudgetTypeEnum $type): self + { + $this->type = $type; + + return $this; + } + + public function setName(array $name): self + { + $this->name = $name; + + return $this; + } +} diff --git a/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php b/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php new file mode 100644 index 000000000..807a0fdc3 --- /dev/null +++ b/src/Bundle/ChillEventBundle/Form/EventBudgetKindType.php @@ -0,0 +1,53 @@ +add('name', TranslatableStringFormType::class, [ + 'label' => 'Title', + ]) + ->add('type', EnumType::class, [ + 'class' => BudgetTypeEnum::class, + 'choice_label' => fn (BudgetTypeEnum $type): string => $this->translator->trans($type->value), + 'expanded' => true, + 'multiple' => false, + 'mapped' => true, + 'label' => 'event.admin.Select budget type', + ]) + ->add('isActive', CheckboxType::class, [ + 'label' => 'Actif ?', + 'required' => false, + ]); + } + + public function configureOptions(OptionsResolver $resolver) + { + $resolver + ->setDefault('class', ChargeKind::class); + } +} diff --git a/src/Bundle/ChillEventBundle/Menu/AdminMenuBuilder.php b/src/Bundle/ChillEventBundle/Menu/AdminMenuBuilder.php index 07fd81734..c67b095b6 100644 --- a/src/Bundle/ChillEventBundle/Menu/AdminMenuBuilder.php +++ b/src/Bundle/ChillEventBundle/Menu/AdminMenuBuilder.php @@ -53,6 +53,10 @@ class AdminMenuBuilder implements LocalMenuBuilderInterface $menu->addChild('event.theme.label', [ 'route' => 'chill_crud_event_theme_index', ])->setExtras(['order' => 6540]); + + $menu->addChild('event.budget.label', [ + 'route' => 'chill_crud_event_budget_kind_index', + ])->setExtras(['order' => 6550]); } public static function getMenuIds(): array diff --git a/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/edit.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/edit.html.twig new file mode 100644 index 000000000..3a60d3e9c --- /dev/null +++ b/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/edit.html.twig @@ -0,0 +1,12 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_edit_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_edit_content.html.twig' %} + {% block content_form_actions_view %}{% endblock %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/index.html.twig b/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/index.html.twig new file mode 100644 index 000000000..44bfe1155 --- /dev/null +++ b/src/Bundle/ChillEventBundle/Resources/views/Admin/BudgetKind/index.html.twig @@ -0,0 +1,51 @@ +{% extends '@ChillMain/Admin/layoutWithVerticalMenu.html.twig' %} + +{% block title %}{{ 'admin.title.Event budget element list'|trans }}{% endblock title %} + +{% block admin_content %} + +
{{ 'Name'|trans }} | +{{ 'Type'|trans }} | +{{ 'Active'|trans }} | ++ |
---|---|---|---|
{{ entity.name|localize_translatable_string }} | +{{ entity.type.value|trans }} | ++ {%- if entity.isActive -%} + + {%- else -%} + + {%- endif -%} + | ++ + | +