diff --git a/src/Bundle/ChillMainBundle/Controller/GenderController.php b/src/Bundle/ChillMainBundle/Controller/GenderController.php new file mode 100644 index 000000000..8a949294f --- /dev/null +++ b/src/Bundle/ChillMainBundle/Controller/GenderController.php @@ -0,0 +1,17 @@ +addOrderBy('e.order', 'ASC'); + + return parent::orderQuery($action, $query, $request, $paginator); + } +} diff --git a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php index 9d788c64e..b406f56f1 100644 --- a/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php +++ b/src/Bundle/ChillMainBundle/DependencyInjection/ChillMainExtension.php @@ -17,6 +17,7 @@ use Chill\MainBundle\Controller\CivilityApiController; use Chill\MainBundle\Controller\CivilityController; use Chill\MainBundle\Controller\CountryApiController; use Chill\MainBundle\Controller\CountryController; +use Chill\MainBundle\Controller\GenderController; use Chill\MainBundle\Controller\GeographicalUnitApiController; use Chill\MainBundle\Controller\LanguageController; use Chill\MainBundle\Controller\LocationController; @@ -52,6 +53,7 @@ use Chill\MainBundle\Doctrine\Type\PointType; use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Civility; use Chill\MainBundle\Entity\Country; +use Chill\MainBundle\Entity\Gender; use Chill\MainBundle\Entity\GeographicalUnitLayer; use Chill\MainBundle\Entity\Language; use Chill\MainBundle\Entity\Location; @@ -63,6 +65,7 @@ use Chill\MainBundle\Entity\UserJob; use Chill\MainBundle\Form\CenterType; use Chill\MainBundle\Form\CivilityType; use Chill\MainBundle\Form\CountryType; +use Chill\MainBundle\Form\GenderType; use Chill\MainBundle\Form\LanguageType; use Chill\MainBundle\Form\LocationFormType; use Chill\MainBundle\Form\LocationTypeType; @@ -485,6 +488,28 @@ class ChillMainExtension extends Extension implements ], ], ], + [ + 'class' => Gender::class, + 'name' => 'main_gender', + 'base_path' => '/admin/main/gender', + 'base_role' => 'ROLE_ADMIN', + 'form_class' => GenderType::class, + 'controller' => GenderController::class, + 'actions' => [ + 'index' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Gender/index.html.twig', + ], + 'new' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Gender/new.html.twig', + ], + 'edit' => [ + 'role' => 'ROLE_ADMIN', + 'template' => '@ChillMain/Gender/edit.html.twig', + ], + ], + ], [ 'class' => Language::class, 'name' => 'main_language', diff --git a/src/Bundle/ChillMainBundle/Entity/Gender.php b/src/Bundle/ChillMainBundle/Entity/Gender.php new file mode 100644 index 000000000..8bc94e473 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Entity/Gender.php @@ -0,0 +1,93 @@ + '0.0'])] + private float $order = 0; + + public function getId(): int + { + return $this->id; + } + + public function getLabel(): array + { + return $this->label; + } + + public function setLabel(array $label): void + { + $this->label = $label; + } + + public function isActive(): bool + { + return $this->active; + } + + public function setActive(bool $active): void + { + $this->active = $active; + } + + public function isGrammatical(): bool + { + return $this->isGrammatical; + } + + public function setIsGrammatical(bool $isGrammatical): void + { + $this->isGrammatical = $isGrammatical; + } + + public function getIcon(): string + { + return $this->icon; + } + + public function setIcon(string $icon): void + { + $this->icon = $icon; + } + + public function getOrder(): float + { + return $this->order; + } + + public function setOrder(float $order): void + { + $this->order = $order; + } +} diff --git a/src/Bundle/ChillMainBundle/Form/GenderType.php b/src/Bundle/ChillMainBundle/Form/GenderType.php new file mode 100644 index 000000000..2f188ba58 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Form/GenderType.php @@ -0,0 +1,44 @@ +add('label', TranslatableStringFormType::class, [ + 'required' => true, + ]) + ->add('icon', TextType::class) + ->add('isGrammatical', ChoiceType::class, [ + 'choices' => [ + 'Grammatical' => true, + 'Not grammatical' => false, + ], + ]) + ->add('active', ChoiceType::class, [ + 'choices' => [ + 'Active' => true, + 'Inactive' => false, + ], + ]) + ->add('order', IntegerType::class); + } + + public function configureOptions(OptionsResolver $resolver): void + { + $resolver->setDefaults([ + 'data_class' => Gender::class, + ]); + } +} diff --git a/src/Bundle/ChillMainBundle/Repository/GenderRepository.php b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php new file mode 100644 index 000000000..357e301b5 --- /dev/null +++ b/src/Bundle/ChillMainBundle/Repository/GenderRepository.php @@ -0,0 +1,7 @@ +id + {{ 'gender.label'|trans }} + {{ 'gender.icon'|trans }} + {{ 'gender.isGrammatical'|trans }} + {{ 'gender.active'|trans }} + {{ 'gender.ordering'|trans }} + + {% endblock %} + {% block table_entities_tbody %} + {% for entity in entities %} + + {{ entity.id }} + {{ entity.label|localize_translatable_string }} +{# todo: decide which icon source to use#} + + + {%- if entity.isGrammatical -%} + + {%- else -%} + + {%- endif -%} + + + {%- if entity.active -%} + + {%- else -%} + + {%- endif -%} + + {{ entity.order }} + + + + + {% endfor %} + {% endblock %} + + {% block actions_before %} +
  • + {{'Back to the admin'|trans}} +
  • + {% endblock %} + {% endembed %} +{% endblock %} diff --git a/src/Bundle/ChillMainBundle/Resources/views/Gender/new.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Gender/new.html.twig new file mode 100644 index 000000000..7c204dddd --- /dev/null +++ b/src/Bundle/ChillMainBundle/Resources/views/Gender/new.html.twig @@ -0,0 +1,11 @@ +{% extends '@ChillMain/CRUD/Admin/index.html.twig' %} + +{% block title %} + {% include('@ChillMain/CRUD/_new_title.html.twig') %} +{% endblock %} + +{% block admin_content %} + {% embed '@ChillMain/CRUD/_new_content.html.twig' %} + {% block content_form_actions_save_and_show %}{% endblock %} + {% endembed %} +{% endblock admin_content %} diff --git a/src/Bundle/ChillMainBundle/migrations/Version20240925133053.php b/src/Bundle/ChillMainBundle/migrations/Version20240925133053.php new file mode 100644 index 000000000..4767ff3bd --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20240925133053.php @@ -0,0 +1,28 @@ +addSql('CREATE SEQUENCE chill_main_gender_id_seq INCREMENT BY 1 MINVALUE 1 START 1'); + $this->addSql('CREATE TABLE chill_main_gender (id INT NOT NULL, label JSON NOT NULL, active BOOLEAN NOT NULL, isGrammatical BOOLEAN NOT NULL, icon VARCHAR(255) NOT NULL, ordering DOUBLE PRECISION DEFAULT \'0.0\', PRIMARY KEY(id))'); + } + + public function down(Schema $schema): void + { + $this->addSql('DROP SEQUENCE chill_main_gender_id_seq CASCADE'); + $this->addSql('DROP TABLE chill_main_gender'); + } +} diff --git a/src/Bundle/ChillPersonBundle/Menu/AdminPersonMenuBuilder.php b/src/Bundle/ChillPersonBundle/Menu/AdminPersonMenuBuilder.php index ee2dad9dc..c3d369f00 100644 --- a/src/Bundle/ChillPersonBundle/Menu/AdminPersonMenuBuilder.php +++ b/src/Bundle/ChillPersonBundle/Menu/AdminPersonMenuBuilder.php @@ -45,13 +45,17 @@ class AdminPersonMenuBuilder implements LocalMenuBuilderInterface 'route' => 'chill_crud_main_civility_index', ])->setExtras(['order' => 2010]); + $menu->addChild('Gender', [ + 'route' => 'chill_crud_main_gender_index', + ])->setExtras(['order' => 2020]); + $menu->addChild('Marital status', [ 'route' => 'chill_crud_person_marital-status_index', - ])->setExtras(['order' => 2020]); + ])->setExtras(['order' => 2030]); $menu->addChild('person_admin.person_resource_kind', [ 'route' => 'chill_crud_person_resource-kind_index', - ])->setExtras(['order' => 2030]); + ])->setExtras(['order' => 2040]); } public static function getMenuIds(): array