mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
improvements on private comments
This commit is contained in:
parent
e19cac168b
commit
014c460eef
@ -254,7 +254,7 @@ class ActivityType extends AbstractType
|
||||
|
||||
if ($activityType->isVisible('privateComment')) {
|
||||
$builder->add('privateComment', PrivateCommentType::class, [
|
||||
'label' => empty($activityType->getLabel('privateComment')) ? 'activity.private comment' : $activityType->getPrivateCommentLabel(),
|
||||
'label' => '' === $activityType->getLabel('privateComment') ? 'private comment' : $activityType->getPrivateCommentLabel(),
|
||||
'required' => false,
|
||||
]);
|
||||
}
|
||||
|
@ -147,6 +147,21 @@
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
||||
{% if t.privateCommentVisible and is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) and entity.privateComment.hasCommentForUser(app.user) %}
|
||||
{% if t.privateCommentLabel is not empty %}
|
||||
<dt class="inline">{{ t.privateCommentLabel }}</dt>
|
||||
{% else %}
|
||||
<dt class="inline">{{ 'Private comment'|trans }}</dt>
|
||||
{% endif %}
|
||||
<dd>
|
||||
<section class="chill-entity entity-comment-embeddable">
|
||||
<blockquote class="chill-user-quote private-quote">
|
||||
{{ entity.privateComment.comments[userId] }}
|
||||
</blockquote>
|
||||
</section>
|
||||
</dd>
|
||||
{% endif %}
|
||||
|
||||
{% if t.documentsVisible and is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) %}
|
||||
<dt class="inline">{{ 'Documents'|trans }}</dt>
|
||||
<dd>
|
||||
@ -178,25 +193,6 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{% if t.privateCommentVisible and is_granted('CHILL_ACTIVITY_SEE_DETAILS', entity) and userId in entity.privateComment.comments|keys %}
|
||||
<div class="flex-table">
|
||||
<div class="item-bloc">
|
||||
{% if t.privateCommentLabel is not empty %}
|
||||
<dt class="inline">{{ t.privateCommentLabel }}</dt>
|
||||
{% else %}
|
||||
<dt class="inline">{{ 'Private comment'|trans }}</dt>
|
||||
{% endif %}
|
||||
<dd>
|
||||
<section class="chill-entity entity-comment-embeddable">
|
||||
<blockquote class="chill-user-quote private-quote">
|
||||
{{ entity.privateComment.comments[userId] }}
|
||||
</blockquote>
|
||||
</section>
|
||||
</dd>
|
||||
</div>
|
||||
</div>
|
||||
{% endif %}
|
||||
|
||||
<div class="notification notification-list">
|
||||
{% set notifications = chill_list_notifications('Chill\\ActivityBundle\\Entity\\Activity', entity.id) %}
|
||||
{% if notifications is not empty %}
|
||||
|
@ -14,14 +14,10 @@ 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 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');
|
||||
}
|
||||
@ -33,7 +29,6 @@ final class Version20220425133027 extends AbstractMigration
|
||||
|
||||
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');
|
||||
}
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Activity;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220527124438 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add private comment to activity';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activity ADD privateComment_comments JSON DEFAULT \'{}\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP privateComment_comments');
|
||||
}
|
||||
}
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Calendar;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220527124558 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add private comment to calendar';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ADD privateComment_comments JSON DEFAULT NULL');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP privateComment_comments');
|
||||
}
|
||||
}
|
@ -26,4 +26,3 @@ The calendar item has been successfully removed.: Le rendez-vous a été supprim
|
||||
From the day: Du
|
||||
to the day: au
|
||||
Transform to activity: Transformer en échange
|
||||
private comment: Notes privé
|
@ -20,15 +20,22 @@ use Doctrine\ORM\Mapping as ORM;
|
||||
class PrivateCommentEmbeddable
|
||||
{
|
||||
/**
|
||||
* @ORM\Column(type="json", nullable=true)
|
||||
* @ORM\Column(type="json", nullable=false, options={"default": "{}"})
|
||||
* @var array<int, string>
|
||||
*/
|
||||
private ?array $comments = [];
|
||||
private array $comments = [];
|
||||
|
||||
public function getCommentForUser(User $user): string
|
||||
{
|
||||
return $this->comments[$user->getId()] ?? '';
|
||||
}
|
||||
|
||||
public function hasCommentForUser(User $user): bool
|
||||
{
|
||||
return array_key_exists($user->getId(), $this->comments)
|
||||
&& "" !== $this->comments[$user->getId()];
|
||||
}
|
||||
|
||||
public function getComments(): ?array
|
||||
{
|
||||
return $this->comments;
|
||||
@ -47,7 +54,7 @@ class PrivateCommentEmbeddable
|
||||
|
||||
public function setCommentForUser(User $user, string $content): self
|
||||
{
|
||||
$this->comments[$user->getId()] = $content;
|
||||
$this->comments[$user->getId()] = trim($content);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
@ -38,19 +38,15 @@ class PrivateCommentType extends AbstractType
|
||||
{
|
||||
$builder
|
||||
->add('comments', ChillTextareaType::class, [
|
||||
'label' => 'private comment',
|
||||
'disable_editor' => $options['disable_editor'],
|
||||
'label' => false,
|
||||
])
|
||||
->setDataMapper($this->dataMapper);
|
||||
}
|
||||
|
||||
public function buildView(FormView $view, FormInterface $form, array $options)
|
||||
{
|
||||
$view->vars = array_replace(
|
||||
$view->vars,
|
||||
[
|
||||
'hideLabel' => true,
|
||||
]
|
||||
);
|
||||
$view->vars['hideLabel'] = true;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
|
@ -198,6 +198,23 @@
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
|
||||
{% block private_comment_row %}
|
||||
{{ form_label(form) }}
|
||||
{{ form_row(form) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block private_comment_widget %}
|
||||
{% for entry in form %}
|
||||
{{ form_widget(entry) }}
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
|
||||
{% block comment_row %}
|
||||
{{ form_label(form) }}
|
||||
{{ form_row(form) }}
|
||||
{% endblock %}
|
||||
|
||||
{% block comment_widget %}
|
||||
{% for entry in form %}
|
||||
{{ form_widget(entry) }}
|
||||
|
@ -1,42 +0,0 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* Chill is a software for social workers
|
||||
*
|
||||
* For the full copyright and license information, please view
|
||||
* the LICENSE file that was distributed with this source code.
|
||||
*/
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Main;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
/**
|
||||
* Auto-generated Migration: Please modify to your needs!
|
||||
*/
|
||||
final class Version20220426133048 extends AbstractMigration
|
||||
{
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
// this down() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work DROP privateComment_comments');
|
||||
$this->addSql('ALTER TABLE activity DROP privateComment_comments');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar DROP privateComment_comments');
|
||||
}
|
||||
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add private embeddable comment to activity, calendar and accompanyingperiod work';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
// this up() migration is auto-generated, please modify it to your needs
|
||||
$this->addSql('ALTER TABLE activity ADD privateComment_comments JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_calendar.calendar ADD privateComment_comments JSON DEFAULT NULL');
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD privateComment_comments JSON DEFAULT NULL');
|
||||
}
|
||||
}
|
@ -65,7 +65,7 @@ Read more: Lire la suite
|
||||
|
||||
# comment embeddable
|
||||
No comment associated: Aucun commentaire
|
||||
private comment: Notes privé
|
||||
private comment: Notes privées
|
||||
|
||||
#pagination
|
||||
Previous: Précédent
|
||||
|
@ -0,0 +1,26 @@
|
||||
<?php
|
||||
|
||||
declare(strict_types=1);
|
||||
|
||||
namespace Chill\Migrations\Person;
|
||||
|
||||
use Doctrine\DBAL\Schema\Schema;
|
||||
use Doctrine\Migrations\AbstractMigration;
|
||||
|
||||
final class Version20220527124737 extends AbstractMigration
|
||||
{
|
||||
public function getDescription(): string
|
||||
{
|
||||
return 'add private comment on accompanying period work';
|
||||
}
|
||||
|
||||
public function up(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE chill_person_accompanying_period_work ADD privateComment_comments JSON DEFAULT \'{}\'');
|
||||
}
|
||||
|
||||
public function down(Schema $schema): void
|
||||
{
|
||||
$this->addSql('ALTER TABLE activity DROP privateComment_comments');
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user