From b5178c3be32b8e397f179113847aca931a8d768b Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 12:35:17 +0100 Subject: [PATCH 1/5] main: add order field to civility --- .../ChillMainBundle/Entity/Civility.php | 17 +++++++++++ .../migrations/Version20211213112628.php | 29 +++++++++++++++++++ .../ChillPersonBundle/Form/PersonType.php | 3 +- 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 src/Bundle/ChillMainBundle/migrations/Version20211213112628.php diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 48b2a7569..3b832aede 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -32,6 +32,11 @@ class Civility */ private bool $active = true; + /** + * @ORM\Column(type="integer", nullable=true) + */ + private ?int $order = null; + /** * @ORM\Id * @ORM\GeneratedValue @@ -62,6 +67,11 @@ class Civility return $this->id; } + public function getOrder(): ?int + { + return $this->order; + } + public function getName(): ?array { return $this->name; @@ -84,6 +94,13 @@ class Civility return $this; } + public function setOrder(int $order): self + { + $this->order = $order; + + return $this; + } + public function setName(array $name): self { $this->name = $name; diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php new file mode 100644 index 000000000..905a24048 --- /dev/null +++ b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php @@ -0,0 +1,29 @@ +addSql('ALTER TABLE chill_main_civility ADD "order" INT DEFAULT NULL'); + } + + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_civility DROP "order"'); + } +} diff --git a/src/Bundle/ChillPersonBundle/Form/PersonType.php b/src/Bundle/ChillPersonBundle/Form/PersonType.php index 47baafe2b..99382dec2 100644 --- a/src/Bundle/ChillPersonBundle/Form/PersonType.php +++ b/src/Bundle/ChillPersonBundle/Form/PersonType.php @@ -197,7 +197,8 @@ class PersonType extends AbstractType }, 'query_builder' => static function (EntityRepository $er): QueryBuilder { return $er->createQueryBuilder('c') - ->where('c.active = true'); + ->where('c.active = true') + ->orderBy('c.order'); }, 'placeholder' => 'choose civility', 'required' => false, From eaf7ae6f2f7dc414bfb1918ce7130beda868853c Mon Sep 17 00:00:00 2001 From: nobohan Date: Mon, 13 Dec 2021 12:38:18 +0100 Subject: [PATCH 2/5] php cs fixer --- .../ChillMainBundle/Entity/Civility.php | 34 +++++++++---------- .../migrations/Version20211213112628.php | 9 ++++- 2 files changed, 25 insertions(+), 18 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 3b832aede..431ca6428 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -32,11 +32,6 @@ class Civility */ private bool $active = true; - /** - * @ORM\Column(type="integer", nullable=true) - */ - private ?int $order = null; - /** * @ORM\Id * @ORM\GeneratedValue @@ -52,6 +47,11 @@ class Civility */ private array $name = []; + /** + * @ORM\Column(type="integer", nullable=true) + */ + private ?int $order = null; + public function getAbbreviation(): array { return $this->abbreviation; @@ -67,16 +67,16 @@ class Civility return $this->id; } - public function getOrder(): ?int - { - return $this->order; - } - public function getName(): ?array { return $this->name; } + public function getOrder(): ?int + { + return $this->order; + } + /** * @return Civility */ @@ -94,17 +94,17 @@ class Civility return $this; } - public function setOrder(int $order): self - { - $this->order = $order; - - return $this; - } - public function setName(array $name): self { $this->name = $name; return $this; } + + public function setOrder(int $order): self + { + $this->order = $order; + + return $this; + } } diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php index 905a24048..4cacd9478 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php @@ -1,5 +1,12 @@ Date: Mon, 13 Dec 2021 12:39:09 +0100 Subject: [PATCH 3/5] upd CHANGELOG --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 209bf858e..a7ad5b114 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [main] add order field to civility + * [main] change address format in case the country is France, in Address render box and address normalizer * [person] add validator for accompanying period with a test on social issues (https://gitlab.com/champs-libres/departement-de-la-vendee/accent-suivi-developpement/-/issues/76) * [activity] fix visibility for location From de262bbc28c92a1d754af2c06d619d528ee76042 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 14:12:48 +0100 Subject: [PATCH 4/5] civility::order: replace int by a float --- src/Bundle/ChillMainBundle/Entity/Civility.php | 8 ++++---- .../migrations/Version20211213112628.php | 12 ++++++------ 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 431ca6428..2cab636b1 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -48,9 +48,9 @@ class Civility private array $name = []; /** - * @ORM\Column(type="integer", nullable=true) + * @ORM\Column(type="float", nullable=true, options={"default": 0.0}) */ - private ?int $order = null; + private float $order = 0.0; public function getAbbreviation(): array { @@ -72,7 +72,7 @@ class Civility return $this->name; } - public function getOrder(): ?int + public function getOrder(): ?float { return $this->order; } @@ -101,7 +101,7 @@ class Civility return $this; } - public function setOrder(int $order): self + public function setOrder(float $order): self { $this->order = $order; diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php index 4cacd9478..624b0eac4 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php @@ -19,6 +19,11 @@ use Doctrine\Migrations\AbstractMigration; */ final class Version20211213112628 extends AbstractMigration { + public function down(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_main_civility DROP "order"'); + } + public function getDescription(): string { return 'Add order to civility'; @@ -26,11 +31,6 @@ final class Version20211213112628 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('ALTER TABLE chill_main_civility ADD "order" INT DEFAULT NULL'); - } - - public function down(Schema $schema): void - { - $this->addSql('ALTER TABLE chill_main_civility DROP "order"'); + $this->addSql('ALTER TABLE chill_main_civility ADD "order" FLOAT DEFAULT 0.0'); } } From cc849e279dfb1811ec8c8336cd8f537cf066b521 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Mon, 13 Dec 2021 14:38:33 +0100 Subject: [PATCH 5/5] fix column name --- src/Bundle/ChillMainBundle/Entity/Civility.php | 4 ++-- .../ChillMainBundle/migrations/Version20211213112628.php | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/Bundle/ChillMainBundle/Entity/Civility.php b/src/Bundle/ChillMainBundle/Entity/Civility.php index 2cab636b1..c91016a63 100644 --- a/src/Bundle/ChillMainBundle/Entity/Civility.php +++ b/src/Bundle/ChillMainBundle/Entity/Civility.php @@ -48,9 +48,9 @@ class Civility private array $name = []; /** - * @ORM\Column(type="float", nullable=true, options={"default": 0.0}) + * @ORM\Column(type="float", name="ordering", nullable=true, options={"default": 0.0}) */ - private float $order = 0.0; + private float $order = 0; public function getAbbreviation(): array { diff --git a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php index 624b0eac4..012ab27d9 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20211213112628.php @@ -21,7 +21,7 @@ final class Version20211213112628 extends AbstractMigration { public function down(Schema $schema): void { - $this->addSql('ALTER TABLE chill_main_civility DROP "order"'); + $this->addSql('ALTER TABLE chill_main_civility DROP "ordering"'); } public function getDescription(): string @@ -31,6 +31,6 @@ final class Version20211213112628 extends AbstractMigration public function up(Schema $schema): void { - $this->addSql('ALTER TABLE chill_main_civility ADD "order" FLOAT DEFAULT 0.0'); + $this->addSql('ALTER TABLE chill_main_civility ADD "ordering" FLOAT DEFAULT 0.0'); } }