From 5948ac5b2a728d8900caeade2c9e70ee478df481 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 25 May 2022 14:18:38 +0200 Subject: [PATCH 01/10] [main] add a 'read more...' on comment embeddable when overflown --- CHANGELOG.md | 2 ++ .../Resources/views/Entity/CommentEmbeddable.html.twig | 6 +++++- src/Bundle/ChillMainBundle/translations/messages.fr.yml | 1 + 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 077cc0242..8a7c9bd1e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ and this project adheres to ## Unreleased +* [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) + * [admin] refactorisation of the admin section: reorganisation of the menu, translations, form types, new entities (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/592) * [admin] add admin section for languages and countries (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/596) * [activity] activity admin: translations + remove label field for comment on admin activity type (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/587) diff --git a/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig b/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig index e874819c0..1dcd9cbf7 100644 --- a/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig +++ b/src/Bundle/ChillMainBundle/Resources/views/Entity/CommentEmbeddable.html.twig @@ -9,7 +9,11 @@ #} {{ opening_box|raw }} {%- if options['limit_lines'] is not null -%} - {% set content = comment.comment|split('\n')|slice(0, options['limit_lines'])|join('\n') %} + {% if comment.comment|split('\n')|length > options['limit_lines'] %} + {% set content = comment.comment|split('\n')|slice(0, options['limit_lines'])|merge(['(more...)'|trans])|join('\n') %} + {% else %} + {% set content = comment.comment %} + {% endif %} {%- else -%} {% set content = comment.comment %} {%- endif -%} diff --git a/src/Bundle/ChillMainBundle/translations/messages.fr.yml b/src/Bundle/ChillMainBundle/translations/messages.fr.yml index 34ca5d7c9..0d364cd73 100644 --- a/src/Bundle/ChillMainBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillMainBundle/translations/messages.fr.yml @@ -62,6 +62,7 @@ Comment: Commentaire Pinned comment: Commentaire épinglé Any comment: Aucun commentaire Read more: Lire la suite +(more...): (suite...) # comment embeddable No comment associated: Aucun commentaire From dea554ced4e4781787796fa5f40f2e80ea4cae48 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 25 May 2022 16:32:52 +0200 Subject: [PATCH 02/10] storedObject: add title field on StoredObject entity --- .../Entity/StoredObject.php | 18 ++++++++++ .../migrations/Version20220525141646.php | 36 +++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php diff --git a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php index 56380ec74..f852e9f14 100644 --- a/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php +++ b/src/Bundle/ChillDocStoreBundle/Entity/StoredObject.php @@ -71,6 +71,12 @@ class StoredObject implements AsyncFileInterface, Document */ private array $keyInfos = []; + /** + * @ORM\Column(type="text", name="title") + * @Serializer\Groups({"read", "write"}) + */ + private string $title = ''; + /** * @ORM\Column(type="text", name="type") * @Serializer\Groups({"read", "write"}) @@ -127,6 +133,11 @@ class StoredObject implements AsyncFileInterface, Document return $this->getFilename(); } + public function getTitle() + { + return $this->title; + } + public function getType() { return $this->type; @@ -177,6 +188,13 @@ class StoredObject implements AsyncFileInterface, Document return $this; } + public function setTitle(?string $title) + { + $this->title = (string) $title; + + return $this; + } + public function setType(?string $type) { $this->type = (string) $type; diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php new file mode 100644 index 000000000..c3f92dd7b --- /dev/null +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php @@ -0,0 +1,36 @@ +addSql('ALTER TABLE chill_doc.stored_object DROP title'); + } + + public function up(Schema $schema): void + { + $this->addSql('ALTER TABLE chill_doc.stored_object ADD title TEXT NOT NULL DEFAULT \'\' '); + } +} From e8cf7ae8e123798a34d3d4930e3a1fcbab3874bc Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 25 May 2022 17:14:21 +0200 Subject: [PATCH 03/10] stored object: add has_title option to form type of StoredObject --- src/Bundle/ChillActivityBundle/Form/ActivityType.php | 1 + .../ChillDocStoreBundle/Form/StoredObjectType.php | 10 ++++++++++ 2 files changed, 11 insertions(+) diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 6e75bde25..ed6d3131f 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -313,6 +313,7 @@ class ActivityType extends AbstractType 'button_add_label' => 'activity.Insert a document', 'button_remove_label' => 'activity.Remove a document', 'empty_collection_explain' => 'No documents', + 'entry_options' => ['has_title' => true], ]); } diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index f9cb645f7..ebe25b9e6 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -17,6 +17,7 @@ use Doctrine\ORM\EntityManagerInterface; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\CallbackTransformer; use Symfony\Component\Form\Extension\Core\Type\HiddenType; +use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\OptionsResolver\OptionsResolver; @@ -64,12 +65,21 @@ class StoredObjectType extends AbstractType [$this, 'transformObject'], [$this, 'reverseTransformObject'] )); + + if ($options['has_title']) { + $builder + ->add('title', TextType::class); + } } public function configureOptions(OptionsResolver $resolver) { $resolver ->setDefault('data_class', StoredObject::class); + + $resolver + ->setDefault('has_title', false) + ->addAllowedValues('has_title', [true, false]); } public function getBlockPrefix() From 60c163ae9d047fc9fd53daa4de4a91775c80ff23 Mon Sep 17 00:00:00 2001 From: nobohan Date: Wed, 25 May 2022 17:30:26 +0200 Subject: [PATCH 04/10] storedObject: add title in form twig and in activity show --- .../Resources/views/Activity/show.html.twig | 2 +- src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php | 4 +++- .../Resources/views/Form/fields.html.twig | 9 +++++---- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index ce4c22304..59ed0c841 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -152,7 +152,7 @@ {% if entity.documents|length > 0 %}
    {% for d in entity.documents %} -
  • {{ m.download_button(d) }}
  • +
  • {{ d.title }}{{ m.download_button(d) }}
  • {% endfor %}
{% else %} diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index ebe25b9e6..4a61cbebc 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -68,7 +68,9 @@ class StoredObjectType extends AbstractType if ($options['has_title']) { $builder - ->add('title', TextType::class); + ->add('title', TextType::class, [ + 'label' => 'Title', + ]); } } diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig index 3ab0ff255..7e49863e0 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig @@ -1,9 +1,9 @@ {% block stored_object_widget %} -
{% endblock %} From cdbb70b9c51a62607e55f00fc75ebf32f1736b3a Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 27 May 2022 09:32:51 +0200 Subject: [PATCH 05/10] activity: add title to generated document --- .../ChillActivityBundle/Service/DocGenerator/ActivityContext.php | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php index a787e9ecd..55d64ef93 100644 --- a/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php +++ b/src/Bundle/ChillActivityBundle/Service/DocGenerator/ActivityContext.php @@ -209,6 +209,7 @@ class ActivityContext implements */ public function storeGenerated(DocGeneratorTemplate $template, StoredObject $storedObject, object $entity, array $contextGenerationData): void { + $storedObject->setTitle($this->translatableStringHelper->localize($template->getName())); $entity->addDocument($storedObject); $this->em->persist($storedObject); From dbdf435721980260ac1e4647c4aee6ea4d7706b8 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 27 May 2022 09:39:13 +0200 Subject: [PATCH 06/10] docstore: safer display of form.title --- .../ChillDocStoreBundle/Resources/views/Form/fields.html.twig | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig index 7e49863e0..42cfb6052 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig @@ -18,6 +18,6 @@ {{ form_widget(form.keyInfos, { 'attr': { 'data-stored-object-key': 1 } }) }} {{ form_widget(form.iv, { 'attr': { 'data-stored-object-iv': 1 } }) }} {{ form_widget(form.type, { 'attr': { 'data-async-file-type': 1 } }) }} - {{ form_row(form.title) }} + {% if form.title is defined %} {{ form_row(form.title) }} {% endif %}
{% endblock %} From 0a4ef3ad224e94f0fc77bfd598633946df0c3965 Mon Sep 17 00:00:00 2001 From: nobohan Date: Fri, 27 May 2022 09:39:36 +0200 Subject: [PATCH 07/10] php code style + upd CHANGELOG --- CHANGELOG.md | 1 + .../migrations/Version20220525141646.php | 12 ++++++------ .../migrations/Version20220513151853.php | 16 +++++++++++----- 3 files changed, 18 insertions(+), 11 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a7c9bd1e..a25b691ba 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ and this project adheres to ## Unreleased +* [storedobject] add title field on StoredObject entity + use it in activity documents (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) * [main] add a "read more..." on comment embeddable when overflown (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/604) * [admin] refactorisation of the admin section: reorganisation of the menu, translations, form types, new entities (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/592) diff --git a/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php b/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php index c3f92dd7b..71f251db7 100644 --- a/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php +++ b/src/Bundle/ChillDocStoreBundle/migrations/Version20220525141646.php @@ -15,20 +15,20 @@ use Doctrine\DBAL\Schema\Schema; use Doctrine\Migrations\AbstractMigration; /** - * Add title on storedObject + * Add title on storedObject. */ final class Version20220525141646 extends AbstractMigration { - public function getDescription(): string - { - return 'Add title on storedObject'; - } - public function down(Schema $schema): void { $this->addSql('ALTER TABLE chill_doc.stored_object DROP title'); } + public function getDescription(): string + { + return 'Add title on storedObject'; + } + public function up(Schema $schema): void { $this->addSql('ALTER TABLE chill_doc.stored_object ADD title TEXT NOT NULL DEFAULT \'\' '); diff --git a/src/Bundle/ChillMainBundle/migrations/Version20220513151853.php b/src/Bundle/ChillMainBundle/migrations/Version20220513151853.php index 31319ce1b..ec99ce2ba 100644 --- a/src/Bundle/ChillMainBundle/migrations/Version20220513151853.php +++ b/src/Bundle/ChillMainBundle/migrations/Version20220513151853.php @@ -1,5 +1,12 @@ addSql('update users set attributes = \'[]\'::json where attributes IS NULL'); } - - public function down(Schema $schema): void - { - - } } From c9ea9112f1e281cb62066df5e560d3d82ac4b8f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2022 22:24:25 +0200 Subject: [PATCH 08/10] do not add private comment into generated documents --- src/Bundle/ChillActivityBundle/Entity/Activity.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillActivityBundle/Entity/Activity.php b/src/Bundle/ChillActivityBundle/Entity/Activity.php index db0d5c7d1..5fa0bca35 100644 --- a/src/Bundle/ChillActivityBundle/Entity/Activity.php +++ b/src/Bundle/ChillActivityBundle/Entity/Activity.php @@ -137,7 +137,6 @@ class Activity implements AccompanyingPeriodLinkedWithSocialIssuesEntityInterfac /** * @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\PrivateCommentEmbeddable", columnPrefix="privateComment_") - * @Groups({"docgen:read"}) */ private PrivateCommentEmbeddable $privateComment; From d49859e4748b1401cd7d56397d878d4d9964b6ec Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2022 22:32:06 +0200 Subject: [PATCH 09/10] change order for title in stored object --- .../Form/StoredObjectType.php | 16 ++++++++-------- .../Resources/views/Form/fields.html.twig | 2 +- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index 4a61cbebc..aaf1e80da 100644 --- a/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php +++ b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php @@ -41,6 +41,13 @@ class StoredObjectType extends AbstractType public function buildForm(FormBuilderInterface $builder, array $options) { + if (true === $options['has_title']) { + $builder + ->add('title', TextType::class, [ + 'label' => 'Title', + ]); + } + $builder ->add('filename', AsyncUploaderType::class) ->add('type', HiddenType::class) @@ -65,13 +72,6 @@ class StoredObjectType extends AbstractType [$this, 'transformObject'], [$this, 'reverseTransformObject'] )); - - if ($options['has_title']) { - $builder - ->add('title', TextType::class, [ - 'label' => 'Title', - ]); - } } public function configureOptions(OptionsResolver $resolver) @@ -81,7 +81,7 @@ class StoredObjectType extends AbstractType $resolver ->setDefault('has_title', false) - ->addAllowedValues('has_title', [true, false]); + ->setAllowedTypes('has_title', ['bool']); } public function getBlockPrefix() diff --git a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig index 42cfb6052..e971e2aa0 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig @@ -1,4 +1,5 @@ {% block stored_object_widget %} + {% if form.title is defined %} {{ form_row(form.title) }} {% endif %}
{% endblock %} From 5d13a587dfe85815f33b3a213c6db8876de5df0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Julien=20Fastr=C3=A9?= Date: Fri, 27 May 2022 22:34:13 +0200 Subject: [PATCH 10/10] fix cs --- src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php | 1 - 1 file changed, 1 deletion(-) diff --git a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php index 812062137..ef459f8da 100644 --- a/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php +++ b/src/Bundle/ChillPersonBundle/Form/SocialWork/GoalType.php @@ -16,7 +16,6 @@ use Chill\MainBundle\Form\Type\TranslatableStringFormType; use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\PersonBundle\Entity\SocialWork\Goal; use Chill\PersonBundle\Entity\SocialWork\Result; -use Chill\PersonBundle\Entity\SocialWork\SocialAction; use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\FormBuilderInterface;