reuse notification item in show template

This commit is contained in:
Mathieu Jaumotte 2022-01-06 19:42:45 +01:00
parent 7d4ca8d149
commit 18959f60e2
3 changed files with 90 additions and 73 deletions

View File

@ -2,7 +2,8 @@
* Notifications List * Notifications List
*/ */
div.notification-list { div.notification-list,
div.notification-show {
div.item-bloc { div.item-bloc {
div.item-row.header { div.item-row.header {

View File

@ -10,7 +10,7 @@
<div class="item-col"> <div class="item-col">
<ul class="small_in_title"> <ul class="small_in_title">
{% if step == 'inbox' %} {% if step is not defined or 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 }}">
@ -60,27 +60,29 @@
</blockquote> </blockquote>
</div> </div>
</div> </div>
<div class="item-row separator"> {% if action_button is not defined or action_button != 'false' %}
<ul class="record_actions"> <div class="item-row separator">
<li> <ul class="record_actions">
{# Vue component #}
<span class="notification_toggle_read_status"
data-notification-id="{{ notification.id }}"
data-notification-current-is-read="{{ notification.isReadBy(app.user) }}"
></span>
</li>
{% if is_granted('CHILL_MAIN_NOTIFICATION_UPDATE', notification) %}
<li> <li>
<a href="{{ chill_path_add_return_path('chill_main_notification_edit', {'id': notification.id}) }}" {# Vue component #}
class="btn btn-edit" title="{{ 'Edit'|trans }}"></a> <span class="notification_toggle_read_status"
data-notification-id="{{ notification.id }}"
data-notification-current-is-read="{{ notification.isReadBy(app.user) }}"
></span>
</li> </li>
{% endif %} {% if is_granted('CHILL_MAIN_NOTIFICATION_UPDATE', notification) %}
{% if is_granted('CHILL_MAIN_NOTIFICATION_SEE', 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_show', {'id': notification.id}) }}" class="btn btn-edit" title="{{ 'Edit'|trans }}"></a>
class="btn btn-show" title="{{ 'Show'|trans }}"></a> </li>
</li> {% endif %}
{% endif %} {% if is_granted('CHILL_MAIN_NOTIFICATION_SEE', notification) %}
</ul> <li>
</div> <a href="{{ chill_path_add_return_path('chill_main_notification_show', {'id': notification.id}) }}"
class="btn btn-show" title="{{ 'Show'|trans }}"></a>
</li>
{% endif %}
</ul>
</div>
{% endif %}
</div> </div>

View File

@ -13,73 +13,87 @@
{% endblock %} {% endblock %}
{% block content %} {% block content %}
<div class="col-10"> <div class="col-10 notification notification-show">
<h1>{{ notification.title }}</h1> <h1 class="visually-hidden">{{ notification.title }}</h1>
<div class="flex-table">
{% include 'ChillMainBundle:Notification:_list_item.html.twig' with {
'data': {
'template': handler.getTemplate(notification),
'template_data': handler.getTemplateData(notification)
},
'action_button': 'false'
} %}
</div>
{#
{{ dump() }}
<div> <div>
{% include handler.getTemplate(notification) with handler.getTemplateData(notification) %} {% include handler.getTemplate(notification) with handler.getTemplateData(notification) %}
</div> </div>
<div> <div>
{# à remplacer par un commentEmbeddable #} à remplacer par un commentEmbeddable
{{ notification.message|chill_markdown_to_html }} {{ notification.message|chill_markdown_to_html }}
</div> </div>
#}
{% if notification.comments|length > 0 %} <div class="comments thread m-5">
{% for comment in notification.comments %} {% if notification.comments|length > 0 %}
{% if editedCommentForm is null or editedCommentId != comment.id %} {% for comment in notification.comments %}
<div> {% if editedCommentForm is null or editedCommentId != comment.id %}
<a id="comment-{{ comment.id }}"></a> <div>
<blockquote class="chill-user-quote"> <a id="comment-{{ comment.id }}"></a>
{{ comment.content|chill_markdown_to_html }} <blockquote class="chill-user-quote">
</blockquote> {{ comment.content|chill_markdown_to_html }}
</blockquote>
{% if is_granted('CHILL_MAIN_NOTIFICATION_COMMENT_EDIT', comment) %}
<ul class="record_actions">
<li>
<a href="{{ chill_path_forward_return_path('chill_main_notification_show', { '_fragment': 'comment-'~comment.id, 'edit': comment.id, 'id': notification.id }) }}" class="btn btn-edit"></a>
</li>
</ul>
{% endif %}
</div>
{% else %}
<div>
<a id="comment-{{ comment.id }}"></a>
{{ form_start(editedCommentForm) }}
{{ form_widget(editedCommentForm) }}
<input type="hidden" name="form" value="edit" />
{% if is_granted('CHILL_MAIN_NOTIFICATION_COMMENT_EDIT', comment) %}
<ul class="record_actions"> <ul class="record_actions">
<li class="cancel">
<a href="{{ chill_path_forward_return_path('chill_main_notification_show', { '_fragment': 'comment-'~comment.id, 'id': notification.id }) }}" class="btn btn-cancel"></a>
</li>
<li> <li>
<a href="{{ chill_path_forward_return_path('chill_main_notification_show', { '_fragment': 'comment-'~comment.id, 'edit': comment.id, 'id': notification.id }) }}" class="btn btn-edit"></a> <button type="submit" class="btn btn-save"></button>
</li> </li>
</ul> </ul>
{% endif %} {{ form_end(editedCommentForm) }}
</div> </div>
{% else %} {% endif %}
<div> {% endfor %}
<a id="comment-{{ comment.id }}"></a> {% endif %}
{{ form_start(editedCommentForm) }}
{{ form_widget(editedCommentForm) }}
<input type="hidden" name="form" value="edit" /> {% if appendCommentForm is not null %}
<div>
{{ form_start(appendCommentForm) }}
{{ form_widget(appendCommentForm) }}
<ul class="record_actions"> <input type="hidden" name="form" value="append" />
<li class="cancel">
<a href="{{ chill_path_forward_return_path('chill_main_notification_show', { '_fragment': 'comment-'~comment.id, 'id': notification.id }) }}" class="btn btn-cancel"></a>
</li>
<li>
<button type="submit" class="btn btn-save"></button>
</li>
</ul>
{{ form_end(editedCommentForm) }}
</div>
{% endif %}
{% endfor %}
{% endif %}
{% if appendCommentForm is not null %} <ul class="record_actions">
<div> <li>
{{ form_start(appendCommentForm) }} <button type="submit" class="btn btn-save">{{ 'notification.append_comment'|trans }}</button>
{{ form_widget(appendCommentForm) }} </li>
</ul>
<input type="hidden" name="form" value="append" /> {{ form_end(appendCommentForm) }}
</div>
<ul class="record_actions"> {% endif %}
<li> </div>
<button type="submit" class="btn btn-save">{{ 'notification.append_comment'|trans }}</button>
</li>
</ul>
{{ form_end(appendCommentForm) }}
</div>
{% endif %}
<ul class="record_actions sticky-form-buttons"> <ul class="record_actions sticky-form-buttons">
<li class="cancel"> <li class="cancel">