apply ckeditor on multiple entities

Apply ckeditor into:

* activity;
* task;
* document;
* accompanying periods
This commit is contained in:
Julien Fastré 2021-03-25 21:59:48 +01:00
parent 66e590972a
commit b79ec18a38
12 changed files with 33 additions and 33 deletions

View File

@ -15,7 +15,6 @@ use Symfony\Component\Form\Extension\Core\DataTransformer\DateTimeToTimestampTra
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType; use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Chill\ActivityBundle\Form\Type\TranslatableActivityType; use Chill\ActivityBundle\Form\Type\TranslatableActivityType;
use Chill\ActivityBundle\Form\Type\TranslatableActivityReason; use Chill\ActivityBundle\Form\Type\TranslatableActivityReason;
use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Form\Type\UserPickerType;

View File

@ -46,12 +46,7 @@
<td>{{ activity.durationTime|date('H:i') }}</td> <td>{{ activity.durationTime|date('H:i') }}</td>
<td> <td>
{% if activity.comment.comment is not empty %} {% if activity.comment.comment is not empty %}
<blockquote class="chill-user-quote"> {{ activity.comment|chill_entity_render_box( { 'limit_lines': 3, 'metadata': false } ) }}
{{ activity.comment.comment|slice(0, 250) }} {#
sf4 check: if 'slice' could replace 'truncate' filter ?
truncate come with twig-extensions, in conflict with twig 3
#}
</blockquote>
{% endif %} {% endif %}
{%- if activity.reasons is empty -%} {%- if activity.reasons is empty -%}
{{ 'No reason associated'|trans }} {{ 'No reason associated'|trans }}

View File

@ -13,7 +13,7 @@
{% if is_granted(constant('Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter::SEE_DETAILS'), activity) %} {% if is_granted(constant('Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter::SEE_DETAILS'), activity) %}
<dl class="chill_view_data"> <dl class="chill_view_data">
<dd>{% if activity.comment.comment is empty %}{{ 'No comments'|trans }}{% else %}<blockquote class="chill-user-quote">{{ activity.comment.comment|nl2br }}</blockquote>{% endif %}</dd> <dd>{% if activity.comment.comment is empty %}{{ 'No comments'|trans }}{% else %}{{ activity.comment|chill_entity_render_box({'metadata': false}) }}{% endif %}</dd>
<dt class="inline">{{ 'Reasons'|trans }}</dt> <dt class="inline">{{ 'Reasons'|trans }}</dt>
{%- if activity.reasons is empty -%} {%- if activity.reasons is empty -%}

View File

@ -4,7 +4,6 @@ namespace Chill\DocStoreBundle\Form;
use Chill\DocStoreBundle\Entity\Document; use Chill\DocStoreBundle\Entity\Document;
use Chill\DocStoreBundle\Entity\DocumentCategory;
use Chill\DocStoreBundle\Entity\PersonDocument; use Chill\DocStoreBundle\Entity\PersonDocument;
use Chill\MainBundle\Entity\User; use Chill\MainBundle\Entity\User;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
@ -12,15 +11,13 @@ use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Bridge\Doctrine\Form\Type\EntityType; use Symfony\Bridge\Doctrine\Form\Type\EntityType;
use Doctrine\ORM\EntityRepository; use Doctrine\ORM\EntityRepository;
use Chill\MainBundle\Form\Type\AppendScopeChoiceTypeTrait;
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorageInterface;
use Chill\MainBundle\Security\Authorization\AuthorizationHelper; use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
use Doctrine\Persistence\ObjectManager; use Doctrine\Persistence\ObjectManager;
use Chill\MainBundle\Templating\TranslatableStringHelper; use Chill\MainBundle\Templating\TranslatableStringHelper;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Form\Type\ScopePickerType;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
class PersonDocumentType extends AbstractType class PersonDocumentType extends AbstractType
@ -62,7 +59,7 @@ class PersonDocumentType extends AbstractType
{ {
$builder $builder
->add('title', TextType::class) ->add('title', TextType::class)
->add('description', TextareaType::class, [ ->add('description', ChillTextareaType::class, [
'required' => false 'required' => false
]) ])
->add('object', StoredObjectType::class, [ ->add('object', StoredObjectType::class, [

View File

@ -45,7 +45,7 @@
<span class="chill-no-data-statement">{{ 'Any description'|trans }}</span> <span class="chill-no-data-statement">{{ 'Any description'|trans }}</span>
{% else %} {% else %}
<blockquote class="chill-user-quote"> <blockquote class="chill-user-quote">
{{ document.description }} {{ document.description|chill_markdown_to_html }}
</blockquote> </blockquote>
{% endif %} {% endif %}
</dd> </dd>

View File

@ -20,7 +20,7 @@ namespace Chill\MainBundle\Form\Type;
use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable; use Chill\MainBundle\Entity\Embeddable\CommentEmbeddable;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType; use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\Form\FormEvent; use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormEvents; use Symfony\Component\Form\FormEvents;
@ -44,8 +44,8 @@ class CommentType extends AbstractType
public function buildForm(FormBuilderInterface $builder, array $options) public function buildForm(FormBuilderInterface $builder, array $options)
{ {
$builder $builder
->add('comment', TextareaType::class, [ ->add('comment', ChillTextareaType::class, [
'disable_editor' => $options['disable_editor']
]) ])
; ;
@ -72,8 +72,12 @@ class CommentType extends AbstractType
public function configureOptions(OptionsResolver $resolver) public function configureOptions(OptionsResolver $resolver)
{ {
$resolver->setDefaults([ $resolver
'data_class' => CommentEmbeddable::class, ->setDefined('disable_editor')
]); ->setAllowedTypes('disable_editor', 'bool')
->setDefaults([
'data_class' => CommentEmbeddable::class,
'disable_editor' => false
]);
} }
} }

View File

@ -2,3 +2,7 @@
.ck-editor__editable { .ck-editor__editable {
min-height: 150px; min-height: 150px;
} }
.ck-editor.ck-reset {
margin-bottom: 1.5em;
}

View File

@ -6,17 +6,16 @@ use Chill\MainBundle\Entity\Center;
use Symfony\Component\Form\AbstractType; use Symfony\Component\Form\AbstractType;
use Symfony\Component\Form\FormBuilderInterface; use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Form\FormEvents;
use Symfony\Component\Form\FormEvent;
use Symfony\Component\Form\FormView; use Symfony\Component\Form\FormView;
use Symfony\Component\Form\FormInterface; use Symfony\Component\Form\FormInterface;
use Symfony\Component\Form\Extension\Core\Type\TextareaType; use Chill\MainBundle\Form\Type\ChillTextareaType;
use Symfony\Component\Form\Extension\Core\Type\DateType; use Symfony\Component\Form\Extension\Core\Type\DateType;
use Chill\PersonBundle\Security\Authorization\PersonVoter; use Chill\PersonBundle\Security\Authorization\PersonVoter;
use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Form\Type\UserPickerType;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Chill\PersonBundle\Form\Type\ClosingMotivePickerType; use Chill\PersonBundle\Form\Type\ClosingMotivePickerType;
/** /**
* Class AccompanyingPeriodType * Class AccompanyingPeriodType
* *
@ -89,7 +88,7 @@ class AccompanyingPeriodType extends AbstractType
]); ]);
} }
$builder->add('remark', TextareaType::class, [ $builder->add('remark', ChillTextareaType::class, [
'required' => false 'required' => false
]); ]);
} }

View File

@ -48,8 +48,13 @@
</td> </td>
{% endif %} {% endif %}
<td> <td>
{% if accompanying_period is not empty %}
{{ accompanying_period.remark|chill_print_or_message('No remark', 'blockquote') }} <blockquote class="chill-user-quote">
{{ accompanying_period.remark|chill_markdown_to_html }}
</blockquote>
{% else %}
{{ null|chill_print_or_message('No remark', 'blockquote') }}
{% endif %}
</td> </td>
<td> <td>
<ul class="record_actions"> <ul class="record_actions">

View File

@ -22,15 +22,12 @@ use Symfony\Component\Form\FormBuilderInterface;
use Chill\MainBundle\Form\Type\ChillDateType; use Chill\MainBundle\Form\Type\ChillDateType;
use Chill\MainBundle\Entity\Center; use Chill\MainBundle\Entity\Center;
use Symfony\Component\Form\Extension\Core\Type\TextType; use Symfony\Component\Form\Extension\Core\Type\TextType;
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
use Chill\MainBundle\Form\Type\UserPickerType; use Chill\MainBundle\Form\Type\UserPickerType;
use Chill\MainBundle\Form\Type\ScopePickerType; use Chill\MainBundle\Form\Type\ScopePickerType;
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
use Symfony\Component\OptionsResolver\OptionsResolver; use Symfony\Component\OptionsResolver\OptionsResolver;
use Symfony\Component\Security\Core\Role\Role; use Symfony\Component\Security\Core\Role\Role;
use Chill\TaskBundle\Security\Authorization\TaskVoter;
use Chill\MainBundle\Form\Type\DateIntervalType; use Chill\MainBundle\Form\Type\DateIntervalType;
use Chill\MainBundle\Form\Type\ChillTextareaType;
/** /**
* *
@ -43,7 +40,7 @@ class SingleTaskType extends AbstractType
{ {
$builder $builder
->add('title', TextType::class) ->add('title', TextType::class)
->add('description', TextareaType::class, [ ->add('description', ChillTextareaType::class, [
'required' => false 'required' => false
]) ])
->add('assignee', UserPickerType::class, [ ->add('assignee', UserPickerType::class, [

View File

@ -37,7 +37,7 @@
<span class="chill-no-data-statement">{{"No description"|trans}}</span> <span class="chill-no-data-statement">{{"No description"|trans}}</span>
{% else %} {% else %}
<blockquote class="chill-user-quote"> <blockquote class="chill-user-quote">
{{ task.description }} {{ task.description|chill_markdown_to_html }}
</blockquote> </blockquote>
{% endif %} {% endif %}
</dd> </dd>

View File

@ -18,7 +18,7 @@
<dt class="inline">{{ 'Description'|trans }}</dt> <dt class="inline">{{ 'Description'|trans }}</dt>
<dd> <dd>
<blockquote class="chill-user-quote"> <blockquote class="chill-user-quote">
{{ event.task.description }} {{ event.task.description|chill_markdown_to_html }}
</blockquote> </blockquote>
</dd> </dd>
{% endif %} {% endif %}