diff --git a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php index 4702e18e7..2840e3f27 100644 --- a/src/Bundle/ChillActivityBundle/Controller/ActivityController.php +++ b/src/Bundle/ChillActivityBundle/Controller/ActivityController.php @@ -431,8 +431,6 @@ final class ActivityController extends AbstractController 'accompanyingPeriod' => $accompanyingPeriod, ]); - dump($form); - if ($form->has('documents')) { $form->add('gendocTemplateId', HiddenType::class, [ 'mapped' => false, diff --git a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php index bdf75ed05..deb28184c 100644 --- a/src/Bundle/ChillActivityBundle/Entity/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Entity/ActivityType.php @@ -76,6 +76,16 @@ class ActivityType */ private int $commentVisible = self::FIELD_OPTIONAL; + /** + * @ORM\Column(type="string", nullable=false, options={"default": ""}) + */ + private string $privateCommentLabel = ''; + + /** + * @ORM\Column(type="smallint", nullable=false, options={"default": 1}) + */ + private int $privateCommentVisible = self::FIELD_OPTIONAL; + /** * @ORM\Column(type="string", nullable=false, options={"default": ""}) */ @@ -314,6 +324,16 @@ class ActivityType return $this->commentVisible; } + public function getPrivateCommentLabel(): string + { + return $this->privateCommentLabel; + } + + public function getPrivateCommentVisible(): int + { + return $this->privateCommentVisible; + } + public function getDateLabel(): string { return $this->dateLabel; @@ -573,6 +593,20 @@ class ActivityType return $this; } + public function setPrivateCommentLabel(string $privateCommentLabel): self + { + $this->privateCommentLabel = $privateCommentLabel; + + return $this; + } + + public function setPrivateCommentVisible(int $privateCommentVisible): self + { + $this->privateCommentVisible = $privateCommentVisible; + + return $this; + } + public function setDateLabel(string $dateLabel): self { $this->dateLabel = $dateLabel; diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityType.php b/src/Bundle/ChillActivityBundle/Form/ActivityType.php index 7ff07ba3f..0fa2fdf76 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityType.php @@ -252,10 +252,12 @@ class ActivityType extends AbstractType ]); } - $builder->add('privateComment', PrivateCommentType::class, [ - 'label' => 'activity.private comment', - 'required' => false - ]); + if($activityType->isVisible('privateComment')) { + $builder->add('privateComment', PrivateCommentType::class, [ + 'label' => empty($activityType->getLabel('privateComment')) ? 'activity.private comment' : $activityType->getPrivateCommentLabel(), + 'required' => false + ]); + } if ($activityType->isVisible('persons')) { $builder->add('persons', HiddenType::class); diff --git a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php index 28947d72b..75e79fd5b 100644 --- a/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php +++ b/src/Bundle/ChillActivityBundle/Form/ActivityTypeType.php @@ -57,7 +57,7 @@ class ActivityTypeType extends AbstractType $fields = [ 'persons', 'user', 'date', 'location', 'persons', 'thirdParties', 'durationTime', 'travelTime', 'attendee', - 'reasons', 'comment', 'sentReceived', 'documents', + 'reasons', 'comment', 'privateComment', 'sentReceived', 'documents', 'emergency', 'socialIssues', 'socialActions', 'users', ]; diff --git a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig index 53817c1c4..512557491 100644 --- a/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig +++ b/src/Bundle/ChillActivityBundle/Resources/views/Activity/show.html.twig @@ -146,8 +146,12 @@ {% endif %} - {% if is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) and entity.privateComment.userId is same as(app.user.id) %} -
{{ 'activity.private comment'|trans }}
+ {% if t.privateCommentVisible and is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) and entity.privateComment.userId is same as(app.user.id) %} + {% if t.privateCommentLabel is not empty %} +
{{ t.privateCommentLabel }}
+ {% else %} +
{{ 'activity.private comment'|trans }}
+ {% endif %}
{%- if entity.privateComment.empty -%} {{ 'No comment associated'|trans }} diff --git a/src/Bundle/ChillActivityBundle/migrations/Version20220425133027.php b/src/Bundle/ChillActivityBundle/migrations/Version20220425133027.php new file mode 100644 index 000000000..c29f2d66e --- /dev/null +++ b/src/Bundle/ChillActivityBundle/migrations/Version20220425133027.php @@ -0,0 +1,33 @@ +addSql('ALTER TABLE activitytype ADD privateCommentLabel VARCHAR(255) DEFAULT \'\' NOT NULL'); + $this->addSql('ALTER TABLE activitytype ADD privateCommentVisible SMALLINT DEFAULT 1 NOT NULL'); + } + + public function down(Schema $schema): void + { + // this down() migration is auto-generated, please modify it to your needs + $this->addSql('ALTER TABLE activitytype DROP privateCommentLabel'); + $this->addSql('ALTER TABLE activitytype DROP privateCommentVisible'); + } +} diff --git a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml index 912f3368f..00639f46b 100644 --- a/src/Bundle/ChillActivityBundle/translations/messages.fr.yml +++ b/src/Bundle/ChillActivityBundle/translations/messages.fr.yml @@ -169,6 +169,8 @@ Reasons visible: Visibilité du champ Sujet Reasons label: Libellé du champ Sujet Comment visible: Visibilité du champ Commentaire Comment label: Libellé du champ Commentaire +Private comment visible: Visibilité du champ Commentaire Privé +Private comment label: Libellé du champ Commentaire Privé Emergency visible: Visibilité du champ Urgent Emergency label: Libellé du champ Urgent Accompanying period visible: Visibilité du champ Période d'accompagnement