Add CommentEmbeddable to Activity (Ref #21)

This commit is contained in:
Jean-Francois Monfort 2021-03-11 12:30:11 +01:00
parent f4a76f659e
commit c1c3839c62
5 changed files with 66 additions and 32 deletions

View File

@ -20,6 +20,7 @@
namespace Chill\ActivityBundle\Entity;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Doctrine\ORM\Mapping as ORM;
use Chill\MainBundle\Entity\Scope;
use Chill\MainBundle\Entity\User;
@ -110,15 +111,20 @@ class Activity implements HasCenterInterface, HasScopeInterface
*/
private $person;
/**
* @ORM\Embedded(class="Chill\MainBundle\Entity\Embeddable\CommentEmbeddable", columnPrefix="comment_")
*/
private $comment;
/**
* Activity constructor.
*/
public function __construct()
{
$this->reasons = new ArrayCollection();
$this->comment = new CommentEmbeddable();
}
/**
* Get id
*
@ -354,5 +360,21 @@ class Activity implements HasCenterInterface, HasScopeInterface
{
return $this->person->getCenter();
}
/**
* @return \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable
*/
public function getComment()
{
return $this->comment;
}
/**
* @param \Chill\MainBundle\Entity\Embeddalbe\CommentEmbeddable $comment
*/
public function setComment($comment)
{
$this->comment = $comment;
}
}

View File

@ -2,6 +2,7 @@
namespace Chill\ActivityBundle\Form;
use Chill\MainBundle\Form\Type\CommentType;
use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
@ -120,6 +121,9 @@ class ActivityType extends AbstractType
'placeholder' => 'Choose a type',
'active_only' => true
))
->add('comment', CommentType::class, [
'required' => false,
])
;
$builder->get('durationTime')

View File

@ -35,7 +35,7 @@
{{ form_row(edit_form.remark) }}
{{ form_row(edit_form.attendee) }}
{{ form_row(edit_form.reasons) }}
{{ form_row(form.comment) }}
{{ form_widget(edit_form) }}
<ul class="record_actions sticky-form-buttons">

View File

@ -36,6 +36,7 @@
{{ form_row(form.remark) }}
{{ form_row(form.attendee) }}
{{ form_row(form.reasons) }}
{{ form_row(form.comment) }}
<div class="grid-12 centered sticky-form-buttons">
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button>

View File

@ -38,6 +38,13 @@
<dd>{% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}</dd>
{%- endif -%}
<dt class="inline">{{ 'Comment'|trans }}</dt>
{%- if entity.comment is empty -%}
<dd><span class="chill-no-data-statement">{{ 'No comment associated'|trans }}</span></dd>
{%- else -%}
<dd>{{ entity.comment|chill_entity_render_box }}</dd>
{%- endif -%}
</dl>
<ul class="record_actions">