Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Time logs : utiliser la méthode DELETE lors de la suppression #856

Merged
merged 3 commits into from
May 17, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 9 additions & 9 deletions app/Resources/views/default/tools/_postit.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,12 @@
{{ child.textWithBr | markdown | raw }}
</p>
</div>
{{ form_start(notes_delete_form[child.id], {'attr': {'id': 'form_note_delete_'~child.id }}) }}
{{ form_widget(notes_delete_form[child.id]) }}
{{ form_end(notes_delete_form[child.id]) }}
{{ form_start(note_delete_forms[child.id], {'attr': {'id': 'form_note_delete_'~child.id }}) }}
{{ form_widget(note_delete_forms[child.id]) }}
{{ form_end(note_delete_forms[child.id]) }}
{% endfor %}
{{ form_start(new_notes_form[note.id], {'attr': {'id': 'new_note_form_child_'~note.id ,'class':'reply'}}) }}
{{ form_row(new_notes_form[note.id].text, {'id': 'note_text_reply_'~note.id}) }}
{{ form_row(new_notes_form[note.id].text, {'id': 'note_text_reply_'~note.id}) }}
{{ form_end(new_notes_form[note.id]) }}
</div>
<div class="modal-footer">
Expand All @@ -54,7 +54,7 @@
Ajouter une réponse
</h4>
{{ form_start(new_notes_form[note.id], {'attr': {'id': 'new_note_form_'~note.id ,'class':'reply'}}) }}
{{ form_row(new_notes_form[note.id].text, {'id': 'note_text_reply_'~note.id}) }}
{{ form_row(new_notes_form[note.id].text, {'id': 'note_text_reply_'~note.id}) }}
{{ form_end(new_notes_form[note.id]) }}
</div>
<div class="modal-footer">
Expand All @@ -70,13 +70,13 @@
<div class="modal-content">
<h4>Editer ce post-it</h4>
{{ form_start(notes_form[note.id], {'attr': {'id': 'form_note_edit_'~note.id,'class': 'edit-post-it' }}) }}
{{ form_row(notes_form[note.id].text, {'id': 'note_text_edit_'~note.id}) }}
{{ form_row(notes_form[note.id].text, {'id': 'note_text_edit_'~note.id}) }}
{{ form_end(notes_form[note.id]) }}

{% if is_granted('delete',note) %}
{{ form_start(notes_delete_form[note.id], {'attr': {'id': 'form_note_delete_'~note.id }}) }}
{{ form_widget(notes_delete_form[note.id]) }}
{{ form_end(notes_delete_form[note.id]) }}
{{ form_start(note_delete_forms[note.id], {'attr': {'id': 'form_note_delete_'~note.id }}) }}
{{ form_widget(note_delete_forms[note.id]) }}
{{ form_end(note_delete_forms[note.id]) }}
{% endif %}
</div>
<div class="modal-footer">
Expand Down
107 changes: 59 additions & 48 deletions app/Resources/views/member/_partial/time_logs.html.twig
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
{% set from_admin = from_admin ?? false %}
{% set time_log_delete_forms = time_log_delete_forms ?? [] %}

<table>
<thead>
<tr>
Expand All @@ -24,64 +27,72 @@
</tbody>
</table>

{% if (from_admin ?? false) and is_granted("ROLE_SHIFT_MANAGER") %}
<div style="max-height:500px;overflow:scroll;">
<table>
<thead>
<tr class="grey lighten-2">
<th>Date du log</th>
<th>Auteur</th>
<th>Temps</th>
<th>Motif</th>
<th>Créneau</th>
{% if from_admin and is_granted("ROLE_ADMIN") %}
<th>Route</th>
{% endif %}
{% if from_admin and is_granted("ROLE_SUPER_ADMIN") %}
<th>Actions</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for timeLog in member.timeLogs %}
<tr class="{% if timeLog.type == 20 %}blue{% elseif timeLog.time > 0 %}green{% elseif timeLog.time < 0 %}red{% else %}grey{% endif %} lighten-5">
<td title="{{ timeLog.createdAt | date_fr_full_with_time }}">{{ timeLog.createdAt | date('d/m/Y') }}</td>
<td>{{ timeLog.createdBy }}</td>
<td>{{ timeLog.time | duration_from_minutes }}</td>
<td>{{ timeLog.typeDisplay }}</td>
<td>
{% if timeLog.shift %}
{{ timeLog.shift.job.name }} du {{ timeLog.shift.start | date('d/m/Y') }} de {{ timeLog.shift.start | date('H:i') }} à {{ timeLog.shift.end | date('H:i') }}
{% if timeLog.shift.shifter %}
({{ timeLog.shift.shifter }})
{% endif %}
{% endif %}
</td>
{% if from_admin and is_granted("ROLE_ADMIN") %}
<td>{{ timeLog.requestRoute }}</td>
{% endif %}
{% if from_admin and is_granted("ROLE_SUPER_ADMIN") %}
<td>
{{ form_start(time_log_delete_forms[timeLog.id], {'attr': {'id': 'form_time_log_delete_'~timeLog.id }}) }}
{{ form_widget(time_log_delete_forms[timeLog.id]) }}
<button type="submit" class="btn-floating red" title="Supprimer" onclick="return confirm('Etes-vous sûr de vouloir supprimer ce time log ?!');">
<i class="material-icons left">delete</i>
</button>
{{ form_end(time_log_delete_forms[timeLog.id]) }}
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
</div>

{% if from_admin and is_granted("ROLE_SHIFT_MANAGER") %}
<br />
<a href="#add-time-log" class="modal-trigger waves-effect waves-light btn teal">
<i class="material-icons left">add</i>Ajouter un log de temps
</a>
{{ form_start(time_log_form) }}
{{ form_start(time_log_new_form) }}
<div id="add-time-log" class="modal">
<div class="modal-content">
<h5><i class="material-icons left small">access_time</i>Ajouter un log de temps</h5>
{{ form_widget(time_log_form) }}
{{ form_widget(time_log_new_form) }}
</div>
<div class="modal-footer">
<a href="#!" class="modal-action modal-close waves-effect waves-green btn-flat orange-text">Annuler</a>
<button type="submit" class="btn green"><i class="material-icons left">add</i>Ajouter le log de temps</button>
</div>
</div>
{{ form_end(time_log_form) }}
{{ form_end(time_log_new_form) }}
{% endif %}

<table>
<thead>
<tr class="grey lighten-2">
<th>Date du log</th>
<th>Auteur</th>
<th>Temps</th>
<th>Motif</th>
<th>Créneau</th>
{% if (from_admin ?? false) and is_granted("ROLE_ADMIN") %}
<th>Route</th>
{% endif %}
{% if (from_admin ?? false) and is_granted("ROLE_SUPER_ADMIN") %}
<th>Actions</th>
{% endif %}
</tr>
</thead>
<tbody>
{% for timeLog in member.timeLogs %}
<tr class="{% if timeLog.type == 20 %}blue{% elseif timeLog.time > 0 %}green{% elseif timeLog.time < 0 %}red{% else %}grey{% endif %} lighten-5">
<td title="{{ timeLog.createdAt | date_fr_full_with_time }}">{{ timeLog.createdAt | date('d/m/Y') }}</td>
<td>{{ timeLog.createdBy }}</td>
<td>{{ timeLog.time | duration_from_minutes }}</td>
<td>{{ timeLog.typeDisplay }}</td>
<td>
{% if timeLog.shift %}
{{ timeLog.shift.job.name }} du {{ timeLog.shift.start | date('d/m/Y') }} de {{ timeLog.shift.start | date('H:i') }} à {{ timeLog.shift.end | date('H:i') }}
{% if timeLog.shift.shifter %}
({{ timeLog.shift.shifter }})
{% endif %}
{% endif %}
</td>
{% if (from_admin ?? false) and is_granted("ROLE_ADMIN") %}
<td>{{ timeLog.requestRoute }}</td>
{% endif %}
{% if (from_admin ?? false) and is_granted("ROLE_SUPER_ADMIN") %}
<td title="Supprimer">
<a href="{{ path('member_timelog_delete', { "id": member.id, "timelog_id": timeLog.id }) }}" class="red-text">X</a>
</td>
{% endif %}
</tr>
{% endfor %}
</tbody>
</table>
17 changes: 15 additions & 2 deletions app/Resources/views/member/show.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
{% endif %}
</h4>

<!-- Détails sur le(s) bénéficiaire(s) -->
{% if member.beneficiaries | length %}
<div class="row">
{% for beneficiary in member.beneficiariesWithMainInFirstPosition %}
Expand All @@ -41,6 +42,7 @@
</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">
Expand All @@ -54,11 +56,12 @@
</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">
<li>
<div class="collapsible-header"><i class="material-icons">person_add</i>Ajouter un bénéficiaire</div>
<div class="collapsible-body new_registration_form">
<div class="collapsible-body white new_registration_form">
{{ form_start(new_beneficiary_form) }}
{% include "beneficiary/_partial/beneficiary_form.html.twig" with { form: new_beneficiary_form } %}
<div class="col s3">
Expand All @@ -71,6 +74,7 @@
{% endif %}

<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">
<i class="material-icons">card_membership</i>Adhésions
Expand Down Expand Up @@ -126,6 +130,8 @@
{% endif %}
</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 %}">
Expand All @@ -142,15 +148,17 @@
</li>
{% endif %}

<!-- Compteur de temps -->
<li id="time_log">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.time_log_open is defined and frontend_cookie.user_show.time_log_open %}active{% endif %}">
<i class="material-icons">access_time</i>Compteur de temps
</div>
<div class="collapsible-body white">
{% include "member/_partial/time_logs.html.twig" with { member: member, from_admin: true, time_log_form: time_log_form } %}
{% include "member/_partial/time_logs.html.twig" with { member: member, from_admin: true, time_log_new_form: time_log_new_form, time_log_delete_forms: time_log_delete_forms } %}
</div>
</li>

<!-- Créneaux -->
<li id="shifts">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.shifts_open is defined and frontend_cookie.user_show.shifts_open %}active{% endif %}">
<i class="material-icons">date_range</i>Créneaux
Expand All @@ -160,6 +168,7 @@
</div>
</li>

<!-- Badges -->
{% if is_granted("ROLE_USER_MANAGER") %}
<li id="badges">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.badges_open is defined and frontend_cookie.user_show.badges_open %}active{% endif %}">
Expand Down Expand Up @@ -219,6 +228,7 @@
</li>
{% endif %}

<!-- Geler/Dégeler le compte -->
{% if is_granted("ROLE_USER_MANAGER") %}
<li id="freeze">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.freeze_open is defined and frontend_cookie.user_show.freeze_open %}active{% endif %}">
Expand Down Expand Up @@ -305,6 +315,7 @@
</li>
{% endif %}

<!-- Fermer le compte -->
{% if is_granted("ROLE_USER_MANAGER") and is_granted("close",member) %}
<li id="close">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.close_open is defined and frontend_cookie.user_show.close_open %}active{% endif %}">
Expand Down Expand Up @@ -370,6 +381,7 @@
</li>
{% endif %}

<!-- Rôles -->
{% if is_granted("ROLE_ADMIN") %}
<li id="super">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.admin_open is defined and frontend_cookie.user_show.admin_open %}active{% endif %}">
Expand All @@ -381,6 +393,7 @@
</li>
{% endif %}

<!-- Actions super admin (supprimer le membre ; adhésions enregistrées) -->
{% if is_granted("ROLE_SUPER_ADMIN") %}
<li id="super">
<div class="collapsible-header {% if frontend_cookie and frontend_cookie.user_show is defined and frontend_cookie.user_show.super_admin_open is defined and frontend_cookie.user_show.super_admin_open %}active{% endif %}">
Expand Down
18 changes: 9 additions & 9 deletions app/Resources/views/user/_partial/note.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@
</div>
</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 class="row">
<div class="col s12">
{% for child in note.children %}
{% include "user/_partial/note.html.twig" with { note: child } %}
{% endfor %}
</div>
</div>
</div>
{% endif %}
</div>

Expand Down Expand Up @@ -62,9 +62,9 @@
</p>
{% endif %}
</div>
{{ form_start(notes_delete_form[note.id], {'attr': {'id': 'form_note_delete_'~note.id }}) }}
{{ form_widget(notes_delete_form[note.id]) }}
{{ form_end(notes_delete_form[note.id]) }}
{{ form_start(note_delete_forms[note.id], {'attr': {'id': 'form_note_delete_'~note.id }}) }}
{{ form_widget(note_delete_forms[note.id]) }}
{{ form_end(note_delete_forms[note.id]) }}
<div class="modal-footer">
<a href="#!" class="modal-action modal-close btn-flat">Retour</a>
{% if is_granted("delete",note) %}
Expand Down
Loading