forked from elefan-grenoble/gestion-compte
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Membre & Profil : améliorations de la gestion des badges (elefan-gren…
…oble#978) * Profile: move template to beneficiary partials * Create member partial * Refactor add_modal template * Common image template * Cleanup enable, disable and delete views
- Loading branch information
1 parent
b9bbf8d
commit 4dfbae6
Showing
10 changed files
with
277 additions
and
286 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
30 changes: 30 additions & 0 deletions
30
app/Resources/views/beneficiary/_partial/swipe_cards.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{% if beneficiary.getEnabledSwipeCards | length %} | ||
{% if (show_badge_image ?? false) %} | ||
{% include "swipeCard/_partial/image.html.twig" with { card: beneficiary.getEnabledSwipeCards.first, with_badge_card: true } %} | ||
{% endif %} | ||
<a href="#swipe_disable_{{ beneficiary.getEnabledSwipeCards.first.id }}" class="red-text modal-trigger">Badge perdu ?</a> | ||
{% include "swipeCard/_partial/disable_modal.html.twig" with { card: beneficiary.getEnabledSwipeCards.first } %} | ||
{% else %} | ||
<p><b class="red-text">Aucun badge actif</b></p> | ||
<a href="#swipe_add" class="btn waves-effect waves-light modal-trigger"> | ||
<i class="material-icons left">add</i>Associer un badge à ton compte | ||
</a> | ||
{% include "swipeCard/_partial/add_modal.html.twig" with { beneficiary: beneficiary } %} | ||
{% endif %} | ||
|
||
{% if beneficiary.getSwipeCards | length %} | ||
<br /> | ||
<br /> | ||
<a class="waves-effect waves-light btn modal-trigger blue-grey" href="#all_swipecards"> | ||
<i class="material-icons left">credit_card</i>{% if beneficiary.getSwipeCards | length > 1 %}Vos badges{% else %}Ton badge{% endif %} | ||
</a> | ||
<div id="all_swipecards" class="modal bottom-sheet"> | ||
<div class="modal-content"> | ||
<h4>Tous vos badges</h4> | ||
{% include "swipeCard/_partial/list.html.twig" with { beneficiairy: beneficiary } %} | ||
</div> | ||
<div class="modal-footer"> | ||
<a href="#!" class="modal-close waves-effect waves-green btn-flat red-text">Fermer</a> | ||
</div> | ||
</div> | ||
{% endif %} |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
<div class="row"> | ||
{% for beneficiary in member.beneficiaries %} | ||
<div class="col s12 m6"> | ||
<h4>{{ beneficiary.firstname }}</h4> | ||
{% if beneficiary.getEnabledSwipeCards | length %} | ||
{% include "swipeCard/_partial/image.html.twig" with { card: beneficiary.getEnabledSwipeCards.first, with_badge_card: true } %} | ||
{% else %} | ||
<p><b class="red-text">Aucun badge actif</b></p> | ||
<a href="#swipe_add_b{{ beneficiary.id }}" class="btn waves-effect waves-light modal-trigger"> | ||
<i class="material-icons left">add</i>Associer un badge à ce compte | ||
</a> | ||
{% include "swipeCard/_partial/add_modal.html.twig" with { beneficiary: beneficiary, from_admin: true } %} | ||
{% endif %} | ||
|
||
{% if beneficiary.getSwipeCards | length %} | ||
<br /> | ||
<br /> | ||
<a class="waves-effect waves-light btn modal-trigger blue-grey" href="#all_swipecards_b{{ beneficiary.id }}"> | ||
<i class="material-icons left">credit_card</i>Badges de {{ beneficiary.firstname }} | ||
</a> | ||
<div id="all_swipecards_b{{ beneficiary.id }}" class="modal bottom-sheet"> | ||
<div class="modal-content"> | ||
<h4>Tous les badges {{ beneficiary.firstname }}</h4> | ||
{% include "swipeCard/_partial/list.html.twig" with { beneficiary: beneficiary, from_admin: true } %} | ||
</div> | ||
<div class="modal-footer"> | ||
<a href="#!" class="modal-close waves-effect waves-green btn-flat red-text">Fermer</a> | ||
</div> | ||
</div> | ||
{% endif %} | ||
</div> | ||
{% endfor %} | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
app/Resources/views/swipeCard/_partial/add_modal.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
{% set from_admin = from_admin ?? false %} | ||
|
||
<div id="swipe_add{% if from_admin %}_b{{ beneficiary.id }}{% endif %}" class="modal"> | ||
<form action="{{ path('activate_swipe')}}" method="POST"> | ||
<div class="modal-content"> | ||
<h4>Entrez {% if from_admin %}le{% else %}votre{% endif %} numéro de badge</h4> | ||
<div class="row"> | ||
<div class="col s12 m6 input-field"> | ||
<input type="hidden" name="beneficiary" value="{{ beneficiary.id }}" /> | ||
<input pattern=".{13,13}" type="text" name="code" autocomplete="off" /> | ||
<span class="helper-text" data-error="wrong" data-success="right">Code du badge à 13 chiffres</span> | ||
</div> | ||
<div class="col s12 m6"> | ||
<div class="swiftcard_exemple"> | ||
{{ ("421234567890" | barcode | raw) }} | ||
<canvas id="badge_canvas" class="focus" width="300" height="60"></canvas> | ||
</div> | ||
</div> | ||
</div> | ||
</div> | ||
<div class="modal-footer"> | ||
<a href="#!" class="modal-close waves-effect red-text btn-flat">Annuler</a> | ||
<button type="submit" class="btn green"> | ||
<i class="material-icons left">check</i>Associer | ||
</button> | ||
</div> | ||
</form> | ||
</div> | ||
|
||
<script> | ||
var canvas = document.getElementById('badge_canvas'); | ||
var context = canvas.getContext('2d'); | ||
var centerX = 0; | ||
var centerY = 0; | ||
var radius = 25; | ||
// save state | ||
context.save(); | ||
// translate context | ||
context.translate(canvas.width / 2, canvas.height / 2); | ||
// scale context horizontally | ||
context.scale(4, 1); | ||
// draw circle which will be stretched into an oval | ||
context.beginPath(); | ||
context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false); | ||
// restore to original state | ||
context.restore(); | ||
// apply styling | ||
context.lineWidth = 3; | ||
context.strokeStyle = 'red'; | ||
context.stroke(); | ||
</script> |
18 changes: 18 additions & 0 deletions
18
app/Resources/views/swipeCard/_partial/disable_modal.html.twig
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
<div id="swipe_disable_{{ card.id }}" class="modal"> | ||
<form action="{{ path('disable_swipe')}}" method="POST"> | ||
<div class="modal-content"> | ||
<h4>Badge n°{{ card.number }}</h4> | ||
{% include "swipeCard/_partial/image.html.twig" with { card: card, with_badge_card: true } %} | ||
<p> | ||
Alors comme ça tu ne retrouves plus ton badge ? Désactive-le ici. | ||
</p> | ||
<input type="hidden" name="code" value="{{ card.code | vigenere_encode }}"/> | ||
</div> | ||
<div class="modal-footer"> | ||
<a href="#!" class="modal-close waves-effect red-text btn-flat">Annuler</a> | ||
<button type="submit" class="waves-effect waves-light btn-flat red white-text"> | ||
<i class="material-icons left">close</i>Désactiver<span class="hide-on-small-only"> ce badge</span> | ||
</button> | ||
</div> | ||
</form> | ||
</div> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
{% set with_badge_card = with_badge_card ?? false %} | ||
|
||
<div {% if with_badge_card %}class="badge_card"{% endif %}> | ||
<img src="{{ absolute_url(path('swipe_br', {"code": card.code | vigenere_encode | url_encode})) }}" alt="barcode"> | ||
</div> |
Oops, something went wrong.