mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-08-20 14:43:49 +00:00
improvements on private comments
This commit is contained in:
@@ -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
|
||||
|
Reference in New Issue
Block a user