mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
fix misc in activity (WIP)
This commit is contained in:
parent
a947634f30
commit
0aa909f060
@ -31,7 +31,6 @@ use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
|||||||
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 Chill\MainBundle\Form\Type\ChillDateType;
|
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||||
|
|
||||||
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
||||||
use Symfony\Component\Form\CallbackTransformer;
|
use Symfony\Component\Form\CallbackTransformer;
|
||||||
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
use Chill\PersonBundle\Form\DataTransformer\PersonToIdTransformer;
|
||||||
@ -104,7 +103,7 @@ class ActivityType extends AbstractType
|
|||||||
if ($options['accompanyingPeriod']) {
|
if ($options['accompanyingPeriod']) {
|
||||||
$accompanyingPeriod = $options['accompanyingPeriod'];
|
$accompanyingPeriod = $options['accompanyingPeriod'];
|
||||||
}
|
}
|
||||||
|
dump($options['data']->getType());
|
||||||
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
if ($activityType->isVisible('socialIssues') && $accompanyingPeriod) {
|
||||||
$builder->add('socialIssues', EntityType::class, [
|
$builder->add('socialIssues', EntityType::class, [
|
||||||
'label' => $activityType->getLabel('socialIssues'),
|
'label' => $activityType->getLabel('socialIssues'),
|
||||||
@ -255,6 +254,8 @@ class ActivityType extends AbstractType
|
|||||||
'label' => $activityType->getLabel('documents'),
|
'label' => $activityType->getLabel('documents'),
|
||||||
'required' => $activityType->isRequired('documents'),
|
'required' => $activityType->isRequired('documents'),
|
||||||
'allow_add' => true,
|
'allow_add' => true,
|
||||||
|
'button_add_label' => 'activity.Insert a document',
|
||||||
|
'button_remove_label' => 'activity.Remove a document'
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -34,7 +34,7 @@ class AccompanyingCourseMenuBuilder implements LocalMenuBuilderInterface
|
|||||||
{
|
{
|
||||||
$period = $parameters['accompanyingCourse'];
|
$period = $parameters['accompanyingCourse'];
|
||||||
|
|
||||||
$menu->addChild($this->translator->trans('List of activities'), [
|
$menu->addChild($this->translator->trans('Activity list'), [
|
||||||
'route' => 'chill_activity_activity_list',
|
'route' => 'chill_activity_activity_list',
|
||||||
'routeParameters' => [
|
'routeParameters' => [
|
||||||
'accompanying_period_id' => $period->getId(),
|
'accompanying_period_id' => $period->getId(),
|
||||||
|
@ -19,12 +19,12 @@
|
|||||||
{{ form_row(edit_form.scope) }}
|
{{ form_row(edit_form.scope) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if form.socialActions is defined -%}
|
{%- if edit_form.socialActions is defined -%}
|
||||||
{{ form_row(form.socialActions) }}
|
{{ form_row(edit_form.socialActions) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if form.socialIssues is defined -%}
|
{%- if edit_form.socialIssues is defined -%}
|
||||||
{{ form_row(form.socialIssues) }}
|
{{ form_row(edit_form.socialIssues) }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if edit_form.reasons is defined -%}
|
{%- if edit_form.reasons is defined -%}
|
||||||
@ -86,7 +86,6 @@
|
|||||||
{% set accompanying_course_id = accompanyingCourse.id %}
|
{% set accompanying_course_id = accompanyingCourse.id %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{{ form_widget(edit_form) }}
|
|
||||||
<ul class="record_actions sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<li class="cancel">
|
<li class="cancel">
|
||||||
<a href="{{ path('chill_activity_activity_show', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id } ) }}" class="sc-button bt-cancel">
|
<a href="{{ path('chill_activity_activity_show', { 'id': entity.id, 'person_id': person_id, 'accompanying_period_id': accompanying_course_id } ) }}" class="sc-button bt-cancel">
|
||||||
|
@ -30,21 +30,24 @@
|
|||||||
</thead>
|
</thead>
|
||||||
-->
|
-->
|
||||||
{% for activity in activities %}
|
{% for activity in activities %}
|
||||||
|
{% set t = activity.type %}
|
||||||
<div class="item-bloc">
|
<div class="item-bloc">
|
||||||
<div class="item-row main">
|
<div class="item-row main">
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
|
|
||||||
{% if activity.date %}
|
{% if activity.date %}
|
||||||
<h3>{{ activity.date|format_date('long') }}</h3>
|
<h3>{{ activity.date|format_date('long') }}</h3>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<div class="duration">
|
<div class="duration">
|
||||||
|
{% if t.durationTimeVisible > 0 %}
|
||||||
<p>
|
<p>
|
||||||
<i class="fa fa-fw fa-hourglass-end"></i>
|
<i class="fa fa-fw fa-hourglass-end"></i>
|
||||||
{{ activity.durationTime|date('H:i') }}
|
{{ activity.durationTime|date('H:i') }}
|
||||||
</p>
|
</p>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% if activity.travelTime %}
|
{% if activity.travelTime and t.travelTimeVisible %}
|
||||||
<p>
|
<p>
|
||||||
<i class="fa fa-fw fa-car"></i>
|
<i class="fa fa-fw fa-car"></i>
|
||||||
{{ activity.travelTime|date('H:i') }}
|
{{ activity.travelTime|date('H:i') }}
|
||||||
@ -55,8 +58,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="item-col">
|
<div class="item-col">
|
||||||
<ul class="list-content">
|
<ul class="list-content">
|
||||||
|
{% if activity.user and t.userVisible %}
|
||||||
{% if activity.user %}
|
|
||||||
<li>
|
<li>
|
||||||
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
|
<b>{{ 'by'|trans }}{{ activity.user.usernameCanonical }}</b>
|
||||||
</li>
|
</li>
|
||||||
@ -65,7 +67,7 @@
|
|||||||
<li>
|
<li>
|
||||||
<b>{{ activity.type.name | localize_translatable_string }}</b>
|
<b>{{ activity.type.name | localize_translatable_string }}</b>
|
||||||
|
|
||||||
{% if activity.attendee is not null %}
|
{% if activity.attendee is not null and t.attendeeVisible %}
|
||||||
{% if activity.attendee %}
|
{% if activity.attendee %}
|
||||||
{{ '→ ' ~ 'present'|trans|capitalize }}
|
{{ '→ ' ~ 'present'|trans|capitalize }}
|
||||||
{% else %}
|
{% else %}
|
||||||
@ -82,7 +84,7 @@
|
|||||||
#}
|
#}
|
||||||
</li>
|
</li>
|
||||||
|
|
||||||
{%- if activity.reasons is defined -%}
|
{%- if t.reasonsVisible -%}
|
||||||
<li>
|
<li>
|
||||||
{%- if activity.reasons is empty -%}
|
{%- if activity.reasons is empty -%}
|
||||||
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
||||||
@ -94,24 +96,19 @@
|
|||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if activity.socialIssues is defined -%}
|
{%- if t.socialIssuesVisible %}
|
||||||
<li class="social-issues">
|
<li class="social-issues">
|
||||||
{%- if activity.socialIssues is empty -%}
|
{%- if activity.socialIssues is empty -%}
|
||||||
<span class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'No social issues associated'|trans }}</span>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
{% for r in activity.socialIssues %}
|
{% for r in activity.socialIssues %}
|
||||||
<span class="badge badge-primary">
|
{{ r|chill_entity_render_box }}
|
||||||
{% if r.parent %}
|
|
||||||
{{ r.parent.title|localize_translatable_string ~ ' > ' }}
|
|
||||||
{% endif %}
|
|
||||||
{{ r.title|localize_translatable_string }}
|
|
||||||
</span>
|
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
</li>
|
</li>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
{%- if activity.socialActions is defined -%}
|
{%- if t.socialActionsVisible -%}
|
||||||
<li class="social-actions">
|
<li class="social-actions">
|
||||||
{%- if activity.socialActions is empty -%}
|
{%- if activity.socialActions is empty -%}
|
||||||
<span class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</span>
|
<span class="chill-no-data-statement">{{ 'No social actions associated'|trans }}</span>
|
||||||
|
@ -78,7 +78,23 @@
|
|||||||
|
|
||||||
.. status
|
.. status
|
||||||
|
|
||||||
<div class="grid-12 centered sticky-form-buttons">
|
<ul class="record_actions sticky-form-buttons">
|
||||||
<button class="sc-button green margin-10" type="submit"><i class="fa fa-save"></i> {{ 'Add a new activity'|trans }}</button>
|
<li class="cancel">
|
||||||
</div>
|
<a
|
||||||
|
class="sc-button bt-cancel"
|
||||||
|
{%- if context == 'person' -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'person_id': person.id } )}}"
|
||||||
|
{%- else -%}
|
||||||
|
href="{{ chill_return_path_or('chill_activity_activity_list', { 'accompanying_period_id': accompanyingCourse.id } )}}"
|
||||||
|
{%- endif -%}
|
||||||
|
>
|
||||||
|
{{ 'Cancel'|trans|chill_return_path_label }}
|
||||||
|
</a>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<button class="sc-button bt-create" type="submit">
|
||||||
|
{{ 'Add a new activity'|trans }}
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</ul>
|
||||||
{{ form_end(form) }}
|
{{ form_end(form) }}
|
||||||
|
@ -6,11 +6,11 @@
|
|||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
<div id="activity"></div> {# <=== vue component #}
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:new.html.twig' with {'context': 'accompanyingCourse'} %}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
{% block js %}
|
{% block js %}
|
||||||
<script src="{{ asset('build/async_upload.js') }}" type="text/javascript"></script>
|
{{ encore_entry_script_tags('async_upload') }}
|
||||||
<script type="text/javascript">
|
<script type="text/javascript">
|
||||||
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
chill.displayAlertWhenLeavingUnsubmittedForm('form[name="{{ form.vars.form.vars.name }}"]',
|
||||||
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
'{{ "You are going to leave a page with unsubmitted data. Are you sure you want to leave ?"|trans }}');
|
||||||
|
@ -5,7 +5,7 @@
|
|||||||
{% block title 'Activity creation' |trans %}
|
{% block title 'Activity creation' |trans %}
|
||||||
|
|
||||||
{% block personcontent %}
|
{% block personcontent %}
|
||||||
{% include 'ChillActivityBundle:Activity:new.html.twig' %}
|
{% include 'ChillActivityBundle:Activity:new.html.twig' with {'context': 'person'} %}
|
||||||
<div id="activity"></div> {# <=== vue component #}
|
<div id="activity"></div> {# <=== vue component #}
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|
||||||
|
@ -1,48 +1,102 @@
|
|||||||
<h1 >{{ "Activity"|trans }}</h1>
|
{%- set t = entity.type -%}
|
||||||
|
{%- import "@ChillDocStore/Macro/macro.html.twig" as m -%}
|
||||||
|
|
||||||
|
<h1>
|
||||||
|
{{ "Activity"|trans }}
|
||||||
|
{%- if t.emergencyVisible and entity.emergency -%}
|
||||||
|
<span class="badge badge-secondary">
|
||||||
|
{{- 'Emergency'|trans -}}
|
||||||
|
</span>
|
||||||
|
{%- endif -%}
|
||||||
|
</h1>
|
||||||
|
|
||||||
<dl class="chill_view_data">
|
<dl class="chill_view_data">
|
||||||
<dt class="inline">{{ 'User'|trans }}</dt>
|
|
||||||
|
<dt class="inline">{{ 'by'|trans|capitalize }}</dt>
|
||||||
<dd>{{ entity.user }}</dd>
|
<dd>{{ entity.user }}</dd>
|
||||||
|
|
||||||
|
<dt class="inline">{{ 'Type'|trans }}</dt>
|
||||||
|
<dd>{{ entity.type.name | localize_translatable_string }}</dd>
|
||||||
|
|
||||||
{%- if entity.scope -%}
|
{%- if entity.scope -%}
|
||||||
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
<dt class="inline">{{ 'Scope'|trans }}</dt>
|
||||||
<dd><span class="scope">{{ entity.scope.name|localize_translatable_string }}</span></dd>
|
<dd><span class="scope">{{ entity.scope.name|localize_translatable_string }}</span></dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
</dl>
|
|
||||||
|
|
||||||
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
{% if t.socialIssuesVisible %}
|
||||||
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc' } %}
|
<dt class="inline">{{ 'Social issues'|trans }}</dt>
|
||||||
|
<dd>
|
||||||
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
{% if entity.socialIssues|length == 0 %}
|
||||||
<dl class="chill_view_data">
|
<p class="chill-no-data-statement">{{ 'Any social issues'|trans }}</p>
|
||||||
|
{% else %}
|
||||||
{%- if entity.person is defined -%}
|
{% for si in entity.socialIssues %}{{ si|chill_entity_render_box }}{% endfor %}
|
||||||
<dt class="inline">{{ 'Person'|trans }}</dt>
|
{% endif %}
|
||||||
<dd>{{ entity.person }}</dd>
|
</dd>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
<dt class="inline">{{ 'Date'|trans }}</dt>
|
{% if t.socialActionsVisible %}
|
||||||
<dd>{{ entity.date|format_date('long') }}</dd>
|
<dt class="inline">{{ 'Social actions'|trans }}</dt>
|
||||||
<dt class="inline">{{ 'Duration Time'|trans }}</dt>
|
<dd>
|
||||||
<dd>{{ entity.durationTime|date('H:i') }}</dd>
|
{% if entity.socialActions|length == 0 %}
|
||||||
<dt class="inline">{{ 'Type'|trans }}</dt>
|
<p class="chill-no-data-statement">{{ 'Any social actions'|trans }}</p>
|
||||||
<dd>{{ entity.type.name | localize_translatable_string }}</dd>
|
{% else %}
|
||||||
|
{% for sa in entity.socialActions %}{{ sa|chill_entity_render_box }}{% endfor %}
|
||||||
<dt class="inline">{{ 'Attendee'|trans }}</dt>
|
{% endif %}
|
||||||
<dd>{% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}</dd>
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if t.reasonsVisible %}
|
||||||
<dt class="inline">{{ 'Reasons'|trans }}</dt>
|
<dt class="inline">{{ 'Reasons'|trans }}</dt>
|
||||||
{%- if entity.reasons is empty -%}
|
{%- if entity.reasons is empty -%}
|
||||||
<dd><span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span></dd>
|
<dd><span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span></dd>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<dd>{% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}</dd>
|
<dd>{% for r in entity.reasons %}{{ r|chill_entity_render_box }} {% endfor %}</dd>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Concerned groups'|trans }}</h2>
|
||||||
|
{% include 'ChillActivityBundle:Activity:concernedGroups.html.twig' with {'context': context, 'with_display': 'bloc' } %}
|
||||||
|
|
||||||
|
<h2 class="chill-red">{{ 'Activity data'|trans }}</h2>
|
||||||
|
|
||||||
|
<dt class="inline">{{ 'Date'|trans }}</dt>
|
||||||
|
<dd>{{ entity.date|format_date('long') }}</dd>
|
||||||
|
|
||||||
|
{% if t.durationTimeVisible %}
|
||||||
|
<dt class="inline">{{ 'Duration Time'|trans }}</dt>
|
||||||
|
<dd>{{ entity.durationTime|date('H:i') }}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if t.travelTimeVisible %}
|
||||||
|
<dt class="inline">{{ 'Travel Time'|trans }}</dt>
|
||||||
|
<dd>{{ entity.travelTime|date('H:i') }}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if t.commentVisible %}
|
||||||
<dt class="inline">{{ 'Comment'|trans }}</dt>
|
<dt class="inline">{{ 'Comment'|trans }}</dt>
|
||||||
{%- if entity.comment is empty -%}
|
{%- if entity.comment.empty -%}
|
||||||
<dd><span class="chill-no-data-statement">{{ 'No comment associated'|trans }}</span></dd>
|
<dd><span class="chill-no-data-statement">{{ 'No comment associated'|trans }}</span></dd>
|
||||||
{%- else -%}
|
{%- else -%}
|
||||||
<dd>{{ entity.comment|chill_entity_render_box }}</dd>
|
<dd>{{ entity.comment|chill_entity_render_box }}</dd>
|
||||||
{%- endif -%}
|
{%- endif -%}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if t.documentsVisible and entity.documents|length > 0 %}
|
||||||
|
<dt>{{ 'Documents'|trans }}</dt>
|
||||||
|
<dd>
|
||||||
|
<ul>
|
||||||
|
{% for d in entity.documents %}
|
||||||
|
<li>{{ m.download_button(d) }}</li>
|
||||||
|
{% endfor %}
|
||||||
|
</ul>
|
||||||
|
</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if t.attendeeVisible %}
|
||||||
|
<dt class="inline">{{ 'Attendee'|trans }}</dt>
|
||||||
|
<dd>{% if entity.attendee is not null %}{% if entity.attendee %}{{ 'present'|trans|capitalize }} {% else %} {{ 'not present'|trans|capitalize }}{% endif %}{% else %}{{ 'None'|trans|capitalize }}{% endif %}</dd>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
</dl>
|
</dl>
|
||||||
|
|
||||||
{% set person_id = null %}
|
{% set person_id = null %}
|
||||||
|
@ -71,6 +71,9 @@ Third persons: Tiers non-pro.
|
|||||||
Others persons: Usagers
|
Others persons: Usagers
|
||||||
Third parties: Tiers professionnels
|
Third parties: Tiers professionnels
|
||||||
Users concerned: T(M)S
|
Users concerned: T(M)S
|
||||||
|
activity:
|
||||||
|
Insert a document: Insérer un document
|
||||||
|
Remove a document: Supprimer le document
|
||||||
|
|
||||||
|
|
||||||
#timeline
|
#timeline
|
||||||
|
@ -37,6 +37,11 @@ class CommentEmbeddable
|
|||||||
return $this->comment;
|
return $this->comment;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public function isEmpty()
|
||||||
|
{
|
||||||
|
return empty($this->getComment());
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param string $comment
|
* @param string $comment
|
||||||
*/
|
*/
|
||||||
|
@ -52,6 +52,9 @@ Centers: Centres
|
|||||||
comment: commentaire
|
comment: commentaire
|
||||||
Comment: Commentaire
|
Comment: Commentaire
|
||||||
|
|
||||||
|
# comment embeddable
|
||||||
|
No comment associated: Aucun commentaire
|
||||||
|
|
||||||
#pagination
|
#pagination
|
||||||
Previous: Précédent
|
Previous: Précédent
|
||||||
Next: Suivant
|
Next: Suivant
|
||||||
|
@ -0,0 +1,13 @@
|
|||||||
|
{% set reversed_parents = parents|reverse %}
|
||||||
|
<span class="chill-entity chill-entity__social-action">
|
||||||
|
<span class="badge badge-primary">
|
||||||
|
{%- for p in reversed_parents %}
|
||||||
|
<span class="chill-entity__social-action__parent--{{ loop.revindex0 }}">
|
||||||
|
{{ p.title|localize_translatable_string }}{{ options['default.separator'] }}
|
||||||
|
</span>
|
||||||
|
{%- endfor -%}
|
||||||
|
<span class="chill-entity__social-action__child">
|
||||||
|
{{ socialIssue.title|localize_translatable_string }}
|
||||||
|
</span>
|
||||||
|
</span>
|
||||||
|
</span>
|
@ -0,0 +1,71 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Templating\Entity;
|
||||||
|
|
||||||
|
use Chill\MainBundle\Templating\Entity\ChillEntityRenderInterface;
|
||||||
|
use Chill\PersonBundle\Entity\SocialWork\SocialAction;
|
||||||
|
use Chill\MainBundle\Templating\TranslatableStringHelper;
|
||||||
|
use Symfony\Component\Templating\EngineInterface;
|
||||||
|
|
||||||
|
class SocialActionRender implements ChillEntityRenderInterface
|
||||||
|
{
|
||||||
|
private TranslatableStringHelper $translatableStringHelper;
|
||||||
|
private EngineInterface $engine;
|
||||||
|
|
||||||
|
public const SEPARATOR_KEY = 'default.separator';
|
||||||
|
|
||||||
|
public const DEFAULT_ARGS = [
|
||||||
|
self::SEPARATOR_KEY => ' > ',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function __construct(TranslatableStringHelper $translatableStringHelper, EngineInterface $engine)
|
||||||
|
{
|
||||||
|
$this->translatableStringHelper = $translatableStringHelper;
|
||||||
|
$this->engine = $engine;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function supports($entity, array $options): bool
|
||||||
|
{
|
||||||
|
return $entity instanceof SocialAction;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderString($socialAction, array $options): string
|
||||||
|
{
|
||||||
|
/** @var $socialAction SocialAction */
|
||||||
|
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||||
|
|
||||||
|
$str = $this->translatableStringHelper->localize($socialAction->getTitle());
|
||||||
|
|
||||||
|
while ($socialAction->hasParent()) {
|
||||||
|
$socialAction = $socialAction->getParent();
|
||||||
|
$str .= $options[self::SEPARATOR_KEY].$this->translatableStringHelper->localize(
|
||||||
|
$socialAction->getTitle()
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
return $str;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected function buildParents($socialAction): array
|
||||||
|
{
|
||||||
|
$parents = [];
|
||||||
|
while ($socialAction->hasParent()) {
|
||||||
|
$socialAction = $parents[] = $socialAction->getParent();
|
||||||
|
}
|
||||||
|
|
||||||
|
return $parents;
|
||||||
|
}
|
||||||
|
|
||||||
|
public function renderBox($socialAction, array $options): string
|
||||||
|
{
|
||||||
|
$options = \array_merge(self::DEFAULT_ARGS, $options);
|
||||||
|
// give some help to twig: an array of parents
|
||||||
|
$parents = $this->buildParents($socialAction);
|
||||||
|
|
||||||
|
return $this->engine->render('@ChillPerson/Entity/social_action.html.twig', [
|
||||||
|
'socialAction' => $socialAction,
|
||||||
|
'parents' => $parents,
|
||||||
|
'options' => $options
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,8 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Chill\PersonBundle\Validator\Constraints\Household;
|
||||||
|
|
||||||
|
class MaxHolderValidator
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user