From 4bdfddc89ac2e397a52abc6b54001694a40af252 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Th=C3=A9o=20Boyer?= <t.boyer@soluris.fr>
Date: Tue, 11 Feb 2025 15:20:44 +0100
Subject: [PATCH] [Actions de protection] Champ observations en textarea

---
 .../registry/validation/mesurement.yaml       |  4 ---
 migrations/Version20250211143000.php          | 35 +++++++++++++++++++
 .../Registry/Form/Type/MesurementType.php     |  4 +--
 .../Registry/Form/Type/MesurementTypeTest.php |  4 +--
 4 files changed, 39 insertions(+), 8 deletions(-)
 create mode 100644 migrations/Version20250211143000.php

diff --git a/config/domain/registry/validation/mesurement.yaml b/config/domain/registry/validation/mesurement.yaml
index e4ec4ce9b..870f89b4b 100644
--- a/config/domain/registry/validation/mesurement.yaml
+++ b/config/domain/registry/validation/mesurement.yaml
@@ -15,10 +15,6 @@ App\Domain\Registry\Model\Mesurement:
             - Length:
                 max: 255
                 groups: ['default']
-        comment:
-            - Length:
-                max: 255
-                groups: ['default']
         priority:
             - Knp\DictionaryBundle\Validator\Constraints\Dictionary:
                 name: 'registry_mesurement_priority'
diff --git a/migrations/Version20250211143000.php b/migrations/Version20250211143000.php
new file mode 100644
index 000000000..10b524873
--- /dev/null
+++ b/migrations/Version20250211143000.php
@@ -0,0 +1,35 @@
+<?php
+
+declare(strict_types=1);
+
+namespace DoctrineMigrations;
+
+use Doctrine\DBAL\Schema\Schema;
+use Doctrine\Migrations\AbstractMigration;
+
+/**
+ * Auto-generated Migration: Please modify to your needs!
+ */
+final class Version20250211143000 extends AbstractMigration
+{
+    public function getDescription(): string
+    {
+        return '';
+    }
+
+    public function up(Schema $schema): void
+    {
+        // this up() migration is auto-generated, please modify it to your needs
+        $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('ALTER TABLE registry_mesurement CHANGE comment comment LONGTEXT DEFAULT NULL');
+    }
+
+    public function down(Schema $schema): void
+    {
+        // this down() migration is auto-generated, please modify it to your needs
+        $this->abortIf('mysql' !== $this->connection->getDatabasePlatform()->getName(), 'Migration can only be executed safely on \'mysql\'.');
+
+        $this->addSql('ALTER TABLE registry_mesurement CHANGE comment comment VARCHAR(255) DEFAULT NULL');
+    }
+}
diff --git a/src/Domain/Registry/Form/Type/MesurementType.php b/src/Domain/Registry/Form/Type/MesurementType.php
index f7a51a956..2ab2d5564 100644
--- a/src/Domain/Registry/Form/Type/MesurementType.php
+++ b/src/Domain/Registry/Form/Type/MesurementType.php
@@ -133,11 +133,11 @@ class MesurementType extends LinkableType
                     'class' => 'datepicker',
                 ],
             ])
-            ->add('comment', TextType::class, [
+            ->add('comment', TextareaType::class, [
                 'label'    => 'registry.mesurement.label.comment',
                 'required' => false,
                 'attr'     => [
-                    'maxlength' => 255,
+                    'rows' => 3,
                 ],
                 'purify_html' => true,
             ])
diff --git a/tests/Domain/Registry/Form/Type/MesurementTypeTest.php b/tests/Domain/Registry/Form/Type/MesurementTypeTest.php
index 311a69411..231298977 100644
--- a/tests/Domain/Registry/Form/Type/MesurementTypeTest.php
+++ b/tests/Domain/Registry/Form/Type/MesurementTypeTest.php
@@ -72,7 +72,7 @@ class MesurementTypeTest extends FormTypeHelper
             'charge'            => TextType::class,
             'status'            => DictionaryType::class,
             'planificationDate' => DateType::class,
-            'comment'           => TextType::class,
+            'comment'           => TextareaType::class,
             'priority'          => DictionaryType::class,
             'manager'           => TextType::class,
             'service'           => EntityType::class,
@@ -102,7 +102,7 @@ class MesurementTypeTest extends FormTypeHelper
             'charge'            => TextType::class,
             'status'            => DictionaryType::class,
             'planificationDate' => DateType::class,
-            'comment'           => TextType::class,
+            'comment'           => TextareaType::class,
             'priority'          => DictionaryType::class,
             'manager'           => TextType::class,
             'mesurements'       => EntityType::class,
-- 
GitLab