Add private comment options to activity type (visibility + label)

This commit is contained in:
Julie Lenaerts 2022-04-25 15:46:55 +02:00
parent 1f2638626c
commit b36fd57e4f
7 changed files with 82 additions and 9 deletions

View File

@ -431,8 +431,6 @@ final class ActivityController extends AbstractController
'accompanyingPeriod' => $accompanyingPeriod,
]);
dump($form);
if ($form->has('documents')) {
$form->add('gendocTemplateId', HiddenType::class, [
'mapped' => false,

View File

@ -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;

View File

@ -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);

View File

@ -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',
];

View File

@ -146,8 +146,12 @@
</dd>
{% endif %}
{% if is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) and entity.privateComment.userId is same as(app.user.id) %}
<dt class="inline">{{ 'activity.private comment'|trans }}</dt>
{% 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 %}
<dt class="inline">{{ t.privateCommentLabel }}</dt>
{% else %}
<dt class="inline">{{ 'activity.private comment'|trans }}</dt>
{% endif %}
<dd>
{%- if entity.privateComment.empty -%}
<span class="chill-no-data-statement">{{ 'No comment associated'|trans }}</span>

View File

@ -0,0 +1,33 @@
<?php
declare(strict_types=1);
namespace Chill\Migrations\Activity;
use Doctrine\DBAL\Schema\Schema;
use Doctrine\Migrations\AbstractMigration;
/**
* Auto-generated Migration: Please modify to your needs!
*/
final class Version20220425133027 extends AbstractMigration
{
public function getDescription(): string
{
return 'add private comment option to activity types';
}
public function up(Schema $schema): void
{
// this up() migration is auto-generated, please modify it to your needs
$this->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');
}
}

View File

@ -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