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