notification, list item: manage option fold_item with macro

This commit is contained in:
Mathieu Jaumotte 2022-01-15 20:33:31 +01:00
parent 120ce40dbe
commit d806551477

View File

@ -1,118 +1,119 @@
{% macro title(c) %}
<div class="item-row title">
<h2 class="notification-title">
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': c.notification.id}) }}">
{{ 'notification.object_prefix'|trans ~ c.notification.title }}
</a>
</h2>
</div>
{% endmacro %}
{% macro header(c) %}
<div class="item-row notification-header mt-2">
<div class="item-col">
<ul class="small_in_title">
{% if c.step is not defined or c.step == 'inbox' %}
<li class="notification-from">
<span class="item-key">
<abbr title="{{ 'notification.received_from'|trans }}">
{{ 'notification.from'|trans }} :
</abbr>
</span>
{% if not c.notification.isSystem %}
<span class="badge-user">
{{ c.notification.sender|chill_entity_render_string }}
</span>
{% else %}
<span class="badge-user system">{{ 'notification.is_system'|trans }}</span>
{% endif %}
</li>
{% endif %}
{% if c.notification.addressees|length > 0 %}
<li class="notification-to">
<span class="item-key">
<abbr title="{{ 'notification.sent_to'|trans }}">
{{ 'notification.to'|trans }} :
</abbr>
</span>
{% for a in c.notification.addressees %}
<span class="badge-user">
{{ a|chill_entity_render_string }}
</span>
{% endfor %}
</li>
{% endif %}
</ul>
</div>
<div class="item-col">
{{ c.notification.date|format_datetime('long', 'short') }}
</div>
</div>
{% endmacro %}
{% macro content(c) %}
<div class="item-row separator">
<div class="mx-3 flex-grow-1">
{% include c.data.template with c.data.template_data %}
</div>
</div>
<div class="item-row">
<div class="notification-content">
{% if c.full_content is defined and c.full_content == 'true' %}
{{ c.notification.message|chill_markdown_to_html }}
{% else %}
{{ c.notification.message|u.truncate(250, '…', false)|chill_markdown_to_html }}
{% endif %}
</div>
</div>
{% if c.action_button is not defined or c.action_button != 'false' %}
<div class="item-row separator">
<ul class="record_actions">
<li>
{# Vue component #}
<span class="notification_toggle_read_status"
data-notification-id="{{ c.notification.id }}"
data-notification-current-is-read="{{ c.notification.isReadBy(app.user) }}"
data-container="notification-status"
></span>
</li>
{% if is_granted('CHILL_MAIN_NOTIFICATION_UPDATE', c.notification) %}
<li>
<a href="{{ chill_path_add_return_path('chill_main_notification_edit', {'id': c.notification.id}) }}"
class="btn btn-edit" title="{{ 'Edit'|trans }}"></a>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_NOTIFICATION_SEE', c.notification) %}
<li>
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': c.notification.id}) }}"
class="btn btn-show change-icon" title="{{ 'notification.see_comments_thread'|trans }}"><i class="fa fa-comment"></i></a>
</li>
{% endif %}
</ul>
</div>
{% endif %}
{% endmacro %}
<div class="item-bloc notification-status {% if notification.isReadBy(app.user) %}read{% else %}unread{% endif %}"> <div class="item-bloc notification-status {% if notification.isReadBy(app.user) %}read{% else %}unread{% endif %}">
{% if fold_item is defined and fold_item != 'false' %} {% if fold_item is defined and fold_item != 'false' %}
<div class="accordion-header" id="flush-heading-{{ notification.id }}"> <div class="accordion-header" id="flush-heading-{{ notification.id }}">
<button class="accordion-button collapsed" <button type="button" class="accordion-button collapsed"
type="button" data-bs-toggle="collapse" data-bs-target="#flush-collapse-{{ notification.id }}"
data-bs-toggle="collapse" aria-expanded="false" aria-controls="flush-collapse-{{ notification.id }}">
data-bs-target="#flush-collapse-{{ notification.id }}" {{ _self.title(_context) }}
aria-expanded="false" </button>
aria-controls="flush-collapse-{{ notification.id }}"> {{ _self.header(_context) }}
{% endif %}
<div class="item-row title">
<h2 class="notification-title">
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': notification.id}) }}">
{{ 'notification.object_prefix'|trans ~ notification.title }}
</a>
</h2>
</div>
{% if fold_item is defined and fold_item != 'false' %}
</button>
{% endif %}
<div class="item-row notification-header mt-2">
<div class="item-col">
<ul class="small_in_title">
{% if step is not defined or step == 'inbox' %}
<li class="notification-from">
<span class="item-key">
<abbr title="{{ 'notification.received_from'|trans }}">
{{ 'notification.from'|trans }} :
</abbr>
</span>
{% if not notification.isSystem %}
<span class="badge-user">
{{ notification.sender|chill_entity_render_string }}
</span>
{% else %}
<span class="badge-user system">{{ 'notification.is_system'|trans }}</span>
{% endif %}
</li>
{% endif %}
{% if notification.addressees|length > 0 %}
<li class="notification-to">
<span class="item-key">
<abbr title="{{ 'notification.sent_to'|trans }}">
{{ 'notification.to'|trans }} :
</abbr>
</span>
{% for a in notification.addressees %}
<span class="badge-user">
{{ a|chill_entity_render_string }}
</span>
{% endfor %}
</li>
{% endif %}
</ul>
</div>
<div class="item-col">
{{ notification.date|format_datetime('long', 'short') }}
</div>
</div> </div>
<div id="flush-collapse-{{ notification.id }}"
{% if fold_item is defined and fold_item != 'false' %} class="accordion-collapse collapse"
</div> aria-labelledby="flush-heading-{{ notification.id }}"
<div id="flush-collapse-{{ notification.id }}" data-bs-parent="#notification-fold">
class="accordion-collapse collapse" {{ _self.content(_context) }}
aria-labelledby="flush-heading-{{ notification.id }}"
data-bs-parent="#notification-fold">
{% endif %}
<div class="item-row separator">
<div class="mx-3 flex-grow-1">
{% include data.template with data.template_data %}
</div>
</div> </div>
<div class="item-row"> {% else %}
<div class="notification-content"> {{ _self.title(_context) }}
{% if full_content is defined and full_content == 'true' %} {{ _self.header(_context) }}
{{ notification.message|chill_markdown_to_html }} {{ _self.content(_context) }}
{% else %}
{{ notification.message|u.truncate(250, '…', false)|chill_markdown_to_html }}
{% endif %}
</div>
</div>
{% if action_button is not defined or action_button != 'false' %}
<div class="item-row separator">
<ul class="record_actions">
<li>
{# Vue component #}
<span class="notification_toggle_read_status"
data-notification-id="{{ notification.id }}"
data-notification-current-is-read="{{ notification.isReadBy(app.user) }}"
data-container="notification-status"
></span>
</li>
{% if is_granted('CHILL_MAIN_NOTIFICATION_UPDATE', notification) %}
<li>
<a href="{{ chill_path_add_return_path('chill_main_notification_edit', {'id': notification.id}) }}"
class="btn btn-edit" title="{{ 'Edit'|trans }}"></a>
</li>
{% endif %}
{% if is_granted('CHILL_MAIN_NOTIFICATION_SEE', notification) %}
<li>
<a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': notification.id}) }}"
class="btn btn-show change-icon" title="{{ 'notification.see_comments_thread'|trans }}"><i class="fa fa-comment"></i></a>
</li>
{% endif %}
</ul>
</div>
{% endif %}
{% if fold_item is defined and fold_item != 'false' %}
</div>
{% endif %} {% endif %}
</div> </div>