diff --git a/CHANGELOG.md b/CHANGELOG.md index fa4fcd96d..3f61f05de 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,8 @@ 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) * [person] add closing motive to closed acc course (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/603) * [person] household filiation: fetch person info when unfolding person (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/586) * [admin] repair edit of social action in the admin (https://gitlab.com/champs-libres/departement-de-la-vendee/chill/-/issues/601) 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; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 4c767cd54..898f39e56 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -321,6 +321,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/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 8b47f4de2..bf4c5c7b6 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -168,7 +168,7 @@ {% if entity.documents|length > 0 %} {% else %} 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); 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/Form/StoredObjectType.php b/src/Bundle/ChillDocStoreBundle/Form/StoredObjectType.php index f9cb645f7..aaf1e80da 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; @@ -40,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) @@ -70,6 +78,10 @@ class StoredObjectType extends AbstractType { $resolver ->setDefault('data_class', StoredObject::class); + + $resolver + ->setDefault('has_title', 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 3ab0ff255..e971e2aa0 100644 --- a/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig +++ b/src/Bundle/ChillDocStoreBundle/Resources/views/Form/fields.html.twig @@ -1,9 +1,10 @@ {% block stored_object_widget %} -
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/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 e25045131..c5ab02d6b 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 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;