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
*/
div.notification-list {
div.notification-list,
div.notification-show {
div.item-bloc {
div.item-row.header {

View File

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

View File

@ -13,73 +13,87 @@
{% endblock %}
{% 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>
{% include handler.getTemplate(notification) with handler.getTemplateData(notification) %}
</div>
<div>
{# à remplacer par un commentEmbeddable #}
à remplacer par un commentEmbeddable
{{ notification.message|chill_markdown_to_html }}
</div>
#}
{% if notification.comments|length > 0 %}
{% for comment in notification.comments %}
{% if editedCommentForm is null or editedCommentId != comment.id %}
<div>
<a id="comment-{{ comment.id }}"></a>
<blockquote class="chill-user-quote">
{{ comment.content|chill_markdown_to_html }}
</blockquote>
<div class="comments thread m-5">
{% if notification.comments|length > 0 %}
{% for comment in notification.comments %}
{% if editedCommentForm is null or editedCommentId != comment.id %}
<div>
<a id="comment-{{ comment.id }}"></a>
<blockquote class="chill-user-quote">
{{ 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">
<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>
<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>
</ul>
{% endif %}
</div>
{% else %}
<div>
<a id="comment-{{ comment.id }}"></a>
{{ form_start(editedCommentForm) }}
{{ form_widget(editedCommentForm) }}
{{ form_end(editedCommentForm) }}
</div>
{% endif %}
{% endfor %}
{% endif %}
<input type="hidden" name="form" value="edit" />
{% if appendCommentForm is not null %}
<div>
{{ form_start(appendCommentForm) }}
{{ form_widget(appendCommentForm) }}
<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>
<button type="submit" class="btn btn-save"></button>
</li>
</ul>
{{ form_end(editedCommentForm) }}
</div>
{% endif %}
{% endfor %}
{% endif %}
<input type="hidden" name="form" value="append" />
{% if appendCommentForm is not null %}
<div>
{{ form_start(appendCommentForm) }}
{{ form_widget(appendCommentForm) }}
<input type="hidden" name="form" value="append" />
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-save">{{ 'notification.append_comment'|trans }}</button>
</li>
</ul>
{{ form_end(appendCommentForm) }}
</div>
{% endif %}
<ul class="record_actions">
<li>
<button type="submit" class="btn btn-save">{{ 'notification.append_comment'|trans }}</button>
</li>
</ul>
{{ form_end(appendCommentForm) }}
</div>
{% endif %}
</div>
<ul class="record_actions sticky-form-buttons">
<li class="cancel">