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

Modale au clic sur un créneau de la page planning #1122

Merged
Show file tree
Hide file tree
Changes from 1 commit
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
170 changes: 98 additions & 72 deletions app/Resources/views/admin/booking/_partial/bucket_modal.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ Template for the modal popup used to change the user register for a shift bucket
It use the materialize modal class https://materializeweb.com/modals.html
id = "modal-bucket"
#}
{% if (display_names ?? true) %}
{% set display_names = display_name_shifters %}
{% endif %}
{% set nbBookableShifts = shifts | filter ( shift => not shift.shifter) | length %}
{% set nbShifts = (shifts | length) %}
{% set nbBookedShifts = nbShifts - nbBookableShifts %}
Expand Down Expand Up @@ -33,7 +36,9 @@ id = "modal-bucket"
{% if use_card_reader_to_validate_shifts and shift.isPastOrCurrent %}
<span class="{% if shift.wasCarriedOut %}green-text{% else %}red-text{% endif %}">&#9673;</span>&nbsp;
{% endif %}
{{ shift.shifter.displayNameWithMemberNumber }}
{% if display_names %}
{{ shift.shifter.displayNameWithMemberNumber }}
{% endif %}
{% if shift.formation %}&nbsp;({{ shift.formation.name }}){% endif %}
{% if not shift.formation and shift.shifter.formations | length > 0 %}
&nbsp;<strong class="orange-text">({{ shift.shifter.formations | join(', ') }})</strong>
Expand All @@ -54,7 +59,7 @@ id = "modal-bucket"
<strong>{% if shift.fixe %}fixe{% else %}volant{% endif %}</strong>
{% endif %}
réservé
{% if shift.shifter != shift.booker.beneficiary %}
{% if shift.shifter != shift.booker.beneficiary and display_names %}
pour <a href="{{ path("member_show", { 'member_number': shift.shifter.membership.memberNumber }) }}" target="_blank">{{ shift.shifter }}</a>
{% endif %}
le <i>{{ shift.bookedTime | date_fr_full_with_time }}</i>
Expand All @@ -75,18 +80,20 @@ id = "modal-bucket"
{% endif %}
{{ form_end(shift_validate_invalidate_forms[shift.id]) }}
{% endif %}
{{ form_start(shift_free_forms[shift.id], {'attr': { 'style': 'display:inline;' }}) }}
{% do shift_free_forms[shift.id].reason.setRendered() %} <!-- hidden -->
{% if shift.isPast %}
<button type="submit" class="btn red" title="Supprimer la participation">
<i class="material-icons left">delete</i>Supprimer la participation
</button>
{% else %}
<button type="submit" class="btn orange" title="Libérer">
<i class="material-icons left">lock_open</i>Libérer
</button>
{% endif %}
{{ form_end(shift_free_forms[shift.id]) }}
{% if shift_free_forms is defined %}
Copy link
Collaborator Author

@njean42 njean42 Aug 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne sais pas trop ce que sont les shift_free_forms, et donc je ne sais pas si vérifier leur présence est la meilleure façon de faire ici.

Idem pour les autres if … is defined plus bas :

  • shift_book_forms
  • bucket_shift_add_form
  • bucket_lock_unlock_form

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ce ne sont pas des free_form, mais des shift_free forms ;) Le créneaux libres sont une fonctionnalités offerte par Elefan que l'on n'utilise pas nous. Une variable existe pour activer la fonctionnalité.

{{ form_start(shift_free_forms[shift.id], {'attr': { 'style': 'display:inline;' }}) }}
{% do shift_free_forms[shift.id].reason.setRendered() %} <!-- hidden -->
{% if shift.isPast %}
<button type="submit" class="btn red" title="Supprimer la participation">
<i class="material-icons left">delete</i>Supprimer la participation
</button>
{% else %}
<button type="submit" class="btn orange" title="Libérer">
<i class="material-icons left">lock_open</i>Libérer
</button>
{% endif %}
{{ form_end(shift_free_forms[shift.id]) }}
{% endif %}
{% endif %}
<!-- shift.createdBy -->
{% if shift.createdBy %}
Expand All @@ -104,8 +111,13 @@ id = "modal-bucket"
<div class="col s12">
<b>
<span style="font-style: italic">
{% if shift.lastShifter %}réservé à {{ shift.lastShifter.displayNameWithMemberNumber }}
{% else %}libre
{% if shift.lastShifter %}
réservé
{% if display_names %}
à {{ shift.lastShifter.displayNameWithMemberNumber }}
{% endif %}
{% else %}
libre
{% endif %}
</span>
</b>
Expand All @@ -119,27 +131,30 @@ id = "modal-bucket"
</div>
<div class="collapsible-body">
<!-- shift book form -->
{{ form_start(shift_book_forms[shift.id], {'attr': { 'style': 'display:inline;' }}) }}
<div class="row">
<div class="col {% if use_fly_and_fixed %}s7{% else %}s9{% endif %} input-field">
{{ form_label(shift_book_forms[shift.id].shifter) }}
{{ form_widget(shift_book_forms[shift.id].shifter) }}
</div>
{% if use_fly_and_fixed %}
<div class="col s2 input-field">
{{ form_widget(shift_book_forms[shift.id].fixe) }}
{% if shift_book_forms is defined %}
{{ form_start(shift_book_forms[shift.id], {'attr': { 'style': 'display:inline;' }}) }}
<div class="row">
<div class="col {% if use_fly_and_fixed %}s7{% else %}s9{% endif %} input-field">
{{ form_label(shift_book_forms[shift.id].shifter) }}
{{ form_widget(shift_book_forms[shift.id].shifter) }}
</div>
{% endif %}
<div class="col s3 input-field">
{% if not use_fly_and_fixed %}
{{ form_widget(shift_book_forms[shift.id].fixe) }}
{% if use_fly_and_fixed %}
<div class="col s2 input-field">
{{ form_widget(shift_book_forms[shift.id].fixe) }}
</div>
{% endif %}
<button type="submit" class="btn">
<i class="material-icons left">add</i>Ajouter
</button>
<div class="col s3 input-field">
{% if not use_fly_and_fixed %}
{{ form_widget(shift_book_forms[shift.id].fixe) }}
{% endif %}
<button type="submit" class="btn">
<i class="material-icons left">add</i>Ajouter
</button>
</div>
</div>
</div>
{{ form_end(shift_book_forms[shift.id]) }}
{{ form_end(shift_book_forms[shift.id]) }}
{% endif %}

<!-- shift delete form -->
{% if is_granted("ROLE_ADMIN") %}
{% if not shift.lastShifter %}
Expand All @@ -164,48 +179,59 @@ id = "modal-bucket"
</ul>

{# add shift form #}
{{ form_start(bucket_shift_add_form, {'attr': { 'style': 'display:inline;' }}) }}
<input type="hidden" id="{{ bucket_shift_add_form.start.date.vars.id }}" name="{{ bucket_shift_add_form.start.date.vars.full_name }}" value="{{ bucket_shift_add_form.start.date.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.start.time.vars.id }}" name="{{ bucket_shift_add_form.start.time.vars.full_name }}" value="{{ bucket_shift_add_form.start.time.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.end.date.vars.id }}" name="{{ bucket_shift_add_form.end.date.vars.full_name }}" value="{{ bucket_shift_add_form.end.date.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.end.time.vars.id }}" name="{{ bucket_shift_add_form.end.time.vars.full_name }}" value="{{ bucket_shift_add_form.end.time.vars.value }}">
{{ form_widget(bucket_shift_add_form.job) }}
<div class="row valign-wrapper">
<div class="col s3">
{{ form_label(bucket_shift_add_form.number) }}
{{ form_widget(bucket_shift_add_form.number) }}
{% if bucket_shift_add_form is defined %}
{{ form_start(bucket_shift_add_form, {'attr': { 'style': 'display:inline;' }}) }}
<input type="hidden" id="{{ bucket_shift_add_form.start.date.vars.id }}" name="{{ bucket_shift_add_form.start.date.vars.full_name }}" value="{{ bucket_shift_add_form.start.date.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.start.time.vars.id }}" name="{{ bucket_shift_add_form.start.time.vars.full_name }}" value="{{ bucket_shift_add_form.start.time.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.end.date.vars.id }}" name="{{ bucket_shift_add_form.end.date.vars.full_name }}" value="{{ bucket_shift_add_form.end.date.vars.value }}">
<input type="hidden" id="{{ bucket_shift_add_form.end.time.vars.id }}" name="{{ bucket_shift_add_form.end.time.vars.full_name }}" value="{{ bucket_shift_add_form.end.time.vars.value }}">
{{ form_widget(bucket_shift_add_form.job) }}
<div class="row valign-wrapper">
<div class="col s3">
{{ form_label(bucket_shift_add_form.number) }}
{{ form_widget(bucket_shift_add_form.number) }}
</div>
<div class="col s6">
{{ form_label(bucket_shift_add_form.formation) }}
{{ form_widget(bucket_shift_add_form.formation) }}
</div>
<div class="col s3">
<button type="submit" class="btn waves-effect waves-light teal">
<i class="material-icons left">add</i>Ajouter
</button>
</div>
</div>
<div class="col s6">
{{ form_label(bucket_shift_add_form.formation) }}
{{ form_widget(bucket_shift_add_form.formation) }}
</div>
<div class="col s3">
<button type="submit" class="btn waves-effect waves-light teal">
<i class="material-icons left">add</i>Ajouter
</button>
</div>
</div>
{{ form_row(bucket_shift_add_form._token) }}
{{ form_end(bucket_shift_add_form, {'render_rest': false}) }}
{{ form_row(bucket_shift_add_form._token) }}
{{ form_end(bucket_shift_add_form, {'render_rest': false}) }}
{% endif %}

{# bucket actions #}
<a href="{{ path('mail_bucketshift', { 'id': bucket.id }) }}" class="btn">
<i class="material-icons left">mail</i>Envoyer un email
</a>
{{ form_start(bucket_lock_unlock_form, {'attr': { 'style': 'display:inline;' }}) }}
{% if bucket.locked %}
<button type="submit" class="btn orange">
<i class="material-icons left">lock_open</i>Déverrouiller
</button>
{% else %}
<button type="submit" class="btn orange">
<i class="material-icons left">lock</i>Verrouiller
</button>
{% if is_granted("ROLE_ADMIN_PANEL") %}
<a href="{{ path('mail_bucketshift', { 'id': bucket.id }) }}" class="btn">
<i class="material-icons left">mail</i>Envoyer un email
</a>
{% endif %}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Je ne suis pas sûr si le test sur ROLE_ADMIN_PANEL est le bon test pour savoir si on doit afficher le bouton Envoyer un email.
Je l'ai rajouté car un⋅e membre sans droits admin voit une page 403 si iel clique sur ce bouton.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tu as probablement résolu un autre bug :). Ce rôle est peut-être pas suffisant par contre :)

{{ form_end(bucket_lock_unlock_form) }}
<a href="{{ path('bucket_edit', { 'id': bucket.id }) }}" class="btn deep-purple">
<i class="material-icons left">edit</i>Editer
</a>

{% if bucket_lock_unlock_form is defined %}
{{ form_start(bucket_lock_unlock_form, {'attr': { 'style': 'display:inline;' }}) }}
{% if bucket.locked %}
<button type="submit" class="btn orange">
<i class="material-icons left">lock_open</i>Déverrouiller
</button>
{% else %}
<button type="submit" class="btn orange">
<i class="material-icons left">lock</i>Verrouiller
</button>
{% endif %}
{{ form_end(bucket_lock_unlock_form) }}
{% endif %}

{% if is_granted("ROLE_SHIFT_MANAGER") %}
<a href="{{ path('bucket_edit', { 'id': bucket.id }) }}" class="btn deep-purple">
<i class="material-icons left">edit</i>Editer
</a>
{% endif %}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

La route bucket_edit est bien réservée au rôle ROLE_SHIFT_MANAGER, mais est-ce le bon test pour autant ?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On va dire que oui. A voir si un admin peut bien y accéder également. Je ne sais pas si les droits sont bien gérés de ce point de vue. Raphaël semblait m'avoir dit un jour que ce n'était pas trop le cas :)


{% if is_granted("ROLE_ADMIN") %}
<!-- bucket delete is allowed only if all shifts are free -->
{{ form_start(bucket_delete_form, {'attr': { 'style': 'display:inline;' }}) }}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
{% if (display_names ?? true) %}
{% set display_names = display_name_shifters %}
{% endif %}
{% set target_blank = target_blank ?? false %}

{% if user %}
{% if user and display_names %}
{% if user.beneficiary %}
<a href="{{ path("member_show", { 'member_number': user.beneficiary.membership.memberNumber }) }}" {% if target_blank %}target="_blank"{% endif %}>
{{ user.beneficiary }}
</a>
{% else %}
{{ user }}
{% endif %}
{% else %}
quelqu'un⋅e
{% endif %}
11 changes: 10 additions & 1 deletion app/Resources/views/booking/_partial/shift.html.twig
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,12 @@
{% endfor %}
{% endif %}
</div>
<a {% if firstBookableShift %}href="#book{{ firstBookableShift.id }}"{% endif %}
<a
{% if firstBookableShift %}
href="#book{{ firstBookableShift.id }}"
{% else %}
href="#show{{ bucket.id }}"
{% endif %}
class="modal-trigger tooltipped" data-position="top" data-delay="100" data-tooltip="{{ bucket.sortedShifts.first.job.name }}">
<div class="z-depth-1 {{ bucket.sortedShifts.first.job.color }} lighten-5 black-text" style="position: relative">
<div class="shift-block">
Expand Down Expand Up @@ -65,4 +70,8 @@
</div>
{% if firstBookableShift %}
{% include "booking/_partial/modal.html.twig" with { beneficiary: beneficiary, user: app.user, bucket: bucket, cycle: cycle } %}
{% else %}
<div id="show{{ bucket.id }}" class="modal">
{% include "admin/booking/_partial/bucket_modal.html.twig" with { shifts: bucket.getSortedShifts() } %}
</div>
{% endif %}