Accompanying periods list: move item in separate template (to share)

This commit is contained in:
Mathieu Jaumotte 2022-01-10 10:21:31 +01:00
parent b1cd85971a
commit 98ab3b66ba
2 changed files with 161 additions and 158 deletions

View File

@ -1,165 +1,47 @@
{% macro recordAction(period) %}
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': period.id }) }}"
class="btn btn-show" title="{{ 'See accompanying period'|trans }}">{# {{ 'See this period'|trans }} #}</a>
</li>
{# DISABLED if new accompanying course, this is not necessary
{% if person is defined %}
<li>
<a href="{{ path('chill_person_accompanying_period_update', {'person_id' : person.id, 'period_id' : period.id } ) }}"
class="btn btn-update" title="{{ 'Edit accompanying period'|trans }}"></a>
</li>
{% if period.isOpen == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_close', {'person_id' : person.id}) }}"
class="btn btn-update change-icon">
<i class="fa fa-fw fa-lock" aria-hidden="true"></i>
{{'Close accompanying period'|trans }}
</a>
</li>
{% endif %}
{% if period.canBeReOpened(person) == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_re_open', {'person_id' : person.id, 'period_id' : period.id } ) }}"
class="btn btn-create change-icon">
<i class="fa fa-fw fa-unlock" aria-hidden="true"></i>
{{'Re-open accompanying period'|trans }}
</a>
</li>
{% endif %}
{% elseif household is defined %}
TODO buttons specific for household ?
{% endif %}
#}
{% endmacro %}
{% block content %} {% block content %}
<div class="flex-table accompanyingcourse-list"> <div class="flex-table accompanyingcourse-list">
{% for accompanying_period in accompanying_periods %} {% for period in accompanying_periods %}
<div class="item-bloc">
<div class="item-row">
<div class="wrap-header"> {% include 'ChillPersonBundle:AccompanyingPeriod:_list_item.html.twig' with {
<div class="wh-row"> 'recordAction': _self.recordAction(period)
<div class="wh-col"> } %}
<span class="h3">
<i class="fa fa-fw fa-random"></i>
<b>{{ accompanying_period.id }}</b>
</span>
{% if accompanying_period.emergency %}
<span class="badge rounded-pill bg-danger">{{- 'Emergency'|trans|upper -}}</span>
{% endif %}
{% if accompanying_period.confidential %}
<span class="badge rounded-pill bg-danger">{{- 'Confidential'|trans|upper -}}</span>
{% endif %}
</div>
<div class="wh-col">
{% if accompanying_period.step == 'DRAFT' %}
<span class="badge bg-secondary">{{- 'Draft'|trans|upper -}}</span>
{% elseif accompanying_period.step == 'CONFIRMED' %}
<span class="badge bg-primary">{{- 'Confirmed'|trans|upper -}}</span>
{% else %}
<span class="badge bg-primary">{{- 'Closed'|trans|upper -}}</span>
{% endif %}
</div>
</div>
<div class="wh-row">
<div class="wh-col">
{% if accompanying_period.closingDate == null %}
{{ 'accompanying_period.dates_from_%opening_date%'|trans({ '%opening_date%': accompanying_period.openingDate|format_date('long') } ) }}
{% else %}
{{ 'accompanying_period.dates_from_%opening_date%_to_%closing_date%'|trans({
'%opening_date%': accompanying_period.openingDate|format_date('long'),
'%closing_date%': accompanying_period.closingDate|format_date('long')}
) }}
{% if accompanying_period.isOpen == false %}
<dl class="chill_view_data">
<dt>{{ 'Closing motive'|trans }}&nbsp;:</dt>
<dd>{{ accompanying_period.closingMotive|chill_entity_render_box }}</dd>
</dl>
{% endif %}
{% endif %}
</div>
<div class="wh-col">
{% if chill_accompanying_periods.fields.user == 'visible' %}
{% if accompanying_period.user %}
<abbr class="referrer" title="{{ 'Referrer'|trans }}">ref:</abbr>
{{ accompanying_period.user.username|chill_entity_render_box }}
{% else %}
<span class="chill-no-data-statement">{{ 'No accompanying user'|trans }}</span>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<div class="item-row separator">
<div class="wrap-list">
{% if accompanying_period.requestorPerson is not null or accompanying_period.requestorThirdParty is not null %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Requestor'|trans({'gender': null }) }}</h3></div>
<div class="wl-col list">
{% if accompanying_period.requestorPerson is not null %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'person', id: accompanying_period.requestorPerson.id },
buttonText: accompanying_period.requestorPerson|chill_entity_render_string
} %}
</span>
{% endif %}
{% if accompanying_period.requestorThirdParty is not null %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'thirdparty', id: accompanying_period.requestorThirdParty.id },
buttonText: accompanying_period.requestorThirdParty|chill_entity_render_string
} %}
</span>
{% endif %}
</div>
</div>
{% endif %}
{% if accompanying_period.participations.count > 0 %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div>
<div class="wl-col list">
{% for p in accompanying_period.getCurrentParticipations %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'person', id: p.person.id },
buttonText: p.person|chill_entity_render_string
} %}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if accompanying_period.socialIssues.count > 0 %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Social issues'|trans }}</h3></div>
<div class="wl-col list">
{% for si in accompanying_period.socialIssues %}
<p class="wl-item">
{{ si|chill_entity_render_box }}
</p>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
<div class="item-row separator">
<ul class="record_actions">
{# TODO if enable_accompanying_course_with_multiple_persons is true ... #}
<li>
<a href="{{ path('chill_person_accompanying_course_index', { 'accompanying_period_id': accompanying_period.id }) }}"
class="btn btn-show" title="{{ 'See accompanying period'|trans }}">{# {{ 'See this period'|trans }} #}</a>
</li>
<!-- if new accompanying course, this is not necessary
{% if person is defined %}
<li>
<a href="{{ path('chill_person_accompanying_period_update', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}"
class="btn btn-update" title="{{ 'Edit accompanying period'|trans }}"></a>
</li>
{% if accompanying_period.isOpen == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_close', {'person_id' : person.id}) }}"
class="btn btn-update change-icon">
<i class="fa fa-fw fa-lock" aria-hidden="true"></i>
{{'Close accompanying period'|trans }}
</a>
</li>
{% endif %}
{% if accompanying_period.canBeReOpened(person) == true %}
<li>
<a href="{{ path('chill_person_accompanying_period_re_open', {'person_id' : person.id, 'period_id' : accompanying_period.id } ) }}"
class="btn btn-create change-icon">
<i class="fa fa-fw fa-unlock" aria-hidden="true"></i>
{{'Re-open accompanying period'|trans }}
</a>
</li>
{% endif %}
{% elseif household is defined %}
{# TODO buttons specific for household ? #}
{% endif %}
-->
</ul>
</div>
</div>
{% endfor %} {% endfor %}
</div> </div>
{% endblock content %} {% endblock content %}

View File

@ -0,0 +1,121 @@
<div class="item-bloc">
<div class="item-row">
<div class="wrap-header">
<div class="wh-row">
<div class="wh-col">
<span class="h3">
<i class="fa fa-fw fa-random"></i>
<b>{{ period.id }}</b>
</span>
{% if period.emergency %}
<span class="badge rounded-pill bg-danger">{{- 'Emergency'|trans|upper -}}</span>
{% endif %}
{% if period.confidential %}
<span class="badge rounded-pill bg-danger">{{- 'Confidential'|trans|upper -}}</span>
{% endif %}
</div>
<div class="wh-col">
{% if period.step == 'DRAFT' %}
<span class="badge bg-secondary">{{- 'Draft'|trans|upper -}}</span>
{% elseif period.step == 'CONFIRMED' %}
<span class="badge bg-primary">{{- 'Confirmed'|trans|upper -}}</span>
{% else %}
<span class="badge bg-primary">{{- 'Closed'|trans|upper -}}</span>
{% endif %}
</div>
</div>
<div class="wh-row">
<div class="wh-col">
{% if period.closingDate == null %}
{{ 'accompanying_period.dates_from_%opening_date%'|trans({ '%opening_date%': period.openingDate|format_date('long') } ) }}
{% else %}
{{ 'accompanying_period.dates_from_%opening_date%_to_%closing_date%'|trans({
'%opening_date%': period.openingDate|format_date('long'),
'%closing_date%': period.closingDate|format_date('long')}
) }}
{% if period.isOpen == false %}
<dl class="chill_view_data">
<dt>{{ 'Closing motive'|trans }}&nbsp;:</dt>
<dd>{{ period.closingMotive|chill_entity_render_box }}</dd>
</dl>
{% endif %}
{% endif %}
</div>
<div class="wh-col">
{% if chill_accompanying_periods.fields.user == 'visible' %}
{% if period.user %}
<abbr class="referrer" title="{{ 'Referrer'|trans }}">{{ 'Referrer'|trans }}:</abbr>
{{ period.user.username|chill_entity_render_box }}
{% else %}
<span class="chill-no-data-statement">{{ 'No accompanying user'|trans }}</span>
{% endif %}
{% endif %}
</div>
</div>
</div>
</div>
<div class="item-row separator">
<div class="wrap-list">
{% if period.requestorPerson is not null or period.requestorThirdParty is not null %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Requestor'|trans({'gender': null }) }}</h3></div>
<div class="wl-col list">
{% if period.requestorPerson is not null %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'person', id: period.requestorPerson.id },
buttonText: period.requestorPerson|chill_entity_render_string
} %}
</span>
{% endif %}
{% if period.requestorThirdParty is not null %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'thirdparty', id: period.requestorThirdParty.id },
buttonText: period.requestorThirdParty|chill_entity_render_string
} %}
</span>
{% endif %}
</div>
</div>
{% endif %}
{% if period.participations.count > 0 %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Participants'|trans }}</h3></div>
<div class="wl-col list">
{% for p in period.getCurrentParticipations %}
<span class="wl-item">
{% include '@ChillMain/OnTheFly/_insert_vue_onthefly.html.twig' with {
action: 'show', displayBadge: true,
targetEntity: { name: 'person', id: p.person.id },
buttonText: p.person|chill_entity_render_string
} %}
</span>
{% endfor %}
</div>
</div>
{% endif %}
{% if period.socialIssues.count > 0 %}
<div class="wl-row">
<div class="wl-col title"><h3>{{ 'Social issues'|trans }}</h3></div>
<div class="wl-col list">
{% for si in period.socialIssues %}
<p class="wl-item">
{{ si|chill_entity_render_box }}
</p>
{% endfor %}
</div>
</div>
{% endif %}
</div>
</div>
{% if recordAction is defined %}
<div class="item-row separator">
<ul class="record_actions">
{{ recordAction }}
</ul>
</div>
{% endif %}
</div>