Skip to content

Commit

Permalink
Membre (coté admin) : améliorer la section "Notes" (#973)
Browse files Browse the repository at this point in the history
* Member: move notes to collapsible

* Move to own template

* Hide badge if no notes
  • Loading branch information
raphodn authored Sep 1, 2023
1 parent b5d615a commit e65d192
Show file tree
Hide file tree
Showing 3 changed files with 76 additions and 64 deletions.
30 changes: 30 additions & 0 deletions app/Resources/views/member/_partial/notes.html.twig
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
{% if member.notes | length > 0 %}
<div class="row">
{% for note in member.notes %}
{% if not note.parent %}
<div class="col s12 m6 offset-m2 l6">
{% include "user/_partial/note.html.twig" with { note: note } %}
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}

{% if is_granted("create", note) %}
<button class="btn waves-effect waves-light modal-trigger" href="#modal-note"><i class="material-icons left">add</i>Ajouter une note</button>
{% endif %}

<div id="modal-note" class="modal">
<div class="modal-content">
<h4>Ajouter une note</h4>
{{ form_start(note_form, {'attr': {'id': 'form_note_create'}}) }}
{{ form_row(note_form.text) }}
{{ form_end(note_form) }}
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close btn-flat">Retour</a>
{% if is_granted("create",note) %}
<a href="#!" class="modal-action modal-close green waves-effect waves-green btn" onclick="document.getElementById('form_note_create').submit();"><i class="material-icons left">add</i>Créer</a>
{% endif %}
</div>
</div>
46 changes: 14 additions & 32 deletions app/Resources/views/member/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -42,20 +42,6 @@
</div>
{% endif %}

<!-- Note(s) -->
{% if member.notes | length %}
<h5>Note{% if member.notes | length > 1 %}s{% endif %} à propos de ce membre</h5>
<div class="row">
{% for note in member.notes %}
{% if not note.parent %}
<div class="col s12 m6 offset-m2 l6">
{% include "user/_partial/note.html.twig" with { note: note } %}
</div>
{% endif %}
{% endfor %}
</div>
{% endif %}

<!-- Ajouter un bénéficiaire -->
{% if is_granted("beneficiary_add", member) and member.beneficiaries | length < maximum_nb_of_beneficiaries_in_membership %}
<ul class="collapsible">
Expand All @@ -75,31 +61,27 @@

<ul class="collapsible collapsible-expandable">
<!-- Adhésion(s) -->
<li id="registration" class="{% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.registration_open is defined and frontend_cookie.user_show.registration_open %}active{% endif %}">
<div class="collapsible-header">
<li id="registration">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.registration_open is defined and frontend_cookie.user_show.registration_open %}active{% endif %}">
<i class="material-icons">card_membership</i>Adhésions
</div>
<div class="collapsible-body white">
{% include "member/_partial/registrations.html.twig" with { member: member, from_admin: true, new_registration_form: new_registration_form } %}
</div>
</li>

<!-- Ajouter une note -->
{% if is_granted("create", note) %}
<li id="note">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.note_open is defined and frontend_cookie.user_show.note_open %}active{% endif %}">
<i class="material-icons">add</i>Ajouter une note
</div>
<div class="collapsible-body white">
{{ form_start(note_form) }}
{{ form_row(note_form.text) }}
<div>
<button type="submit" class="btn waves-effect waves-light"><i class="material-icons left">add</i>Ajouter une note</button>
</div>
{{ form_end(note_form) }}
</div>
</li>
{% endif %}
<!-- Notes -->
<li id="note">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.note_open is defined and frontend_cookie.user_show.note_open %}active{% endif %}">
<i class="material-icons">chat_bubble_outline</i>Notes
{% if member.notes | length > 0 %}
<span class="badge teal white-text" style="margin-left:14px;">{{ member.notes | length }}</span>
{% endif %}
</div>
<div class="collapsible-body white">
{% include "member/_partial/notes.html.twig" with { member: member, note: note, note_form: note_form, notes_form: notes_form, note_delete_forms: note_delete_forms, new_notes_form: new_notes_form } %}
</div>
</li>

<!-- Compteur de temps -->
<li id="time_log">
Expand Down
64 changes: 32 additions & 32 deletions app/Resources/views/user/_partial/note.html.twig
Original file line number Diff line number Diff line change
@@ -1,37 +1,37 @@

<div class="card-panel {% if note.parent %}grey lighten-4{% else %}grey lighten-5{% endif %} z-depth-1 note">
<div class="row valign-wrapper" style="margin-bottom: 0;">
<div class="col s2">
<img src="{{ gravatar(note.author.email) }}" alt="" class="circle responsive-img"> <!-- notice the "circle" class -->
</div>
<div class="col s10">
{% if is_granted("edit",note) or is_granted("delete",note) %}
<a class="modal-trigger right grey-text" href="#modal{{ note.id }}"><i class="material-icons">settings</i></a>
{% endif %}
{% if is_granted("create",note) %}
<a class="modal-trigger right grey-text" href="#modal-reply{{ note.id }}"><i class="material-icons">reply</i></a>
{% endif %}
<strong class="black-text">
{{ note.author.username }} le {{ note.createdAt | date_fr_with_time }}
</strong>
<p class="black-text">
{{ note.text }}
</p>
</div>
<div class="card-panel {% if note.parent %}grey lighten-4{% else %}grey lighten-5{% endif %} z-depth-1 note">
<div class="row valign-wrapper" style="margin-bottom: 0;">
<div class="col s2">
<img src="{{ gravatar(note.author.email) }}" alt="" class="circle responsive-img">
</div>
<div class="col s10">
{% if is_granted("edit",note) or is_granted("delete",note) %}
<a class="modal-trigger right grey-text" href="#modal{{ note.id }}"><i class="material-icons">settings</i></a>
{% endif %}
{% if is_granted("create",note) %}
<a class="modal-trigger right grey-text" href="#modal-reply{{ note.id }}"><i class="material-icons">reply</i></a>
{% endif %}
<strong class="black-text">
{{ note.author.username }} le {{ note.createdAt | date_fr_with_time }}
</strong>
<p class="black-text">
{{ note.text }}
</p>
</div>
{% if note.children | length %}
<div class="row">
<div class="col s12">
{% for child in note.children %}
{% include "user/_partial/note.html.twig" with { note: child } %}
{% endfor %}
</div>
</div>
{% endif %}
</div>
{% if note.children | length %}
<div class="row">
<div class="col s12">
{% for child in note.children %}
{% include "user/_partial/note.html.twig" with { note: child } %}
{% endfor %}
</div>
</div>
{% endif %}
</div>

<!-- Modal for reply -->
<div id="modal-reply{{ note.id }}" class="modal modal-fixed-footer">
<div id="modal-reply{{ note.id }}" class="modal">
<div class="modal-content">
{% if is_granted("create",note) %}
<h4>Répondre à cette note</h4>
Expand All @@ -48,7 +48,7 @@
</div>
</div>
<!-- Modal for edit and delete -->
<div id="modal{{ note.id }}" class="modal modal-fixed-footer">
<div id="modal{{ note.id }}" class="modal">
<div class="modal-content">
{% if is_granted("edit",note) %}
<h4>Editer la note</h4>
Expand All @@ -68,12 +68,12 @@
<div class="modal-footer">
<a href="#!" class="modal-action modal-close btn-flat">Retour</a>
{% if is_granted("delete",note) %}
<a href="#!" class="modal-action modal-close red waves-effect waves-red btn" onclick="document.getElementById('form_note_delete_{{ note.id }}').submit();">
<a href="#!" class="btn modal-action modal-close red waves-effect waves-red pull-left" onclick="document.getElementById('form_note_delete_{{ note.id }}').submit();">
<i class="material-icons left">delete</i>Supprimer
</a>
{% endif %}
{% if is_granted("edit",note) %}
<a href="#!" class="modal-action modal-close waves-effect waves-teal btn teal" onclick="document.getElementById('form_note_edit_{{ note.id }}').submit();">
<a href="#!" class="btn modal-action modal-close waves-effect waves-teal teal" onclick="document.getElementById('form_note_edit_{{ note.id }}').submit();">
<i class="material-icons left">check</i>Enregistrer
</a>
{% endif %}
Expand Down

0 comments on commit e65d192

Please sign in to comment.