Skip to content

Commit

Permalink
adapt favorite list
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastienReuiller committed Jul 29, 2024
1 parent 19df9a0 commit b544881
Show file tree
Hide file tree
Showing 7 changed files with 266 additions and 215 deletions.
99 changes: 49 additions & 50 deletions lemarche/templates/favorites/_favorite_item_add_modal.html
Original file line number Diff line number Diff line change
@@ -1,55 +1,54 @@
<div class="modal fade modal-siae" id="favorite_item_add_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="modalTitle">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modalTitle">Liste d'achat favoris</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>

<!-- New list -->
<form method="POST" action="{% url 'siae:favorite_lists' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<div class="modal-body home-content-body">
<label class="mb-2 d-inline-block font-weight-bold" for="id_new_favorite_list">Créer une {% if user.favorite_list_count %}nouvelle {% endif %}liste</label>
<div class="form-row">
<div class="form-group fr-col mb-0">
<input type="text" name="new_favorite_list" id="id_new_favorite_list" class="form-control form-control-sm" placeholder="Entretien des locaux, achat de masque…" required>
</div>
<div class="form-group fr-col-auto mb-0">
<button class="btn btn-sm {% if user.favorite_list_count %}btn-outline-primary{% else %}btn-primary{% endif %}" type="submit" name="action" value="create">Créer</button>
</div>
<dialog class="fr-modal" id="favorite_item_add_modal" role="dialog" aria-modal="true" aria-labelledby="favorite_item_add_modal_title">
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
<div class="fr-col-12 fr-col-md-8 fr-col-lg-6">
<div class="fr-modal__body">
<div class="fr-modal__header">
<button class="fr-btn--close fr-btn" aria-controls="favorite_item_add_modal">Fermer</button>
</div>
</div>
</form>
<div class="fr-modal__content">
<h3 id="favorite_item_add_modal_title" class="fr-modal__title">
Liste d'achat favoris
</h3>
<!-- New list -->
<form method="post" action="{% url 'siae:favorite_lists' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<div class="fr-input-group">
<label class="fr-label" for="id_new_favorite_list">Créer une {% if user.favorite_list_count %}nouvelle {% endif %}liste</label>
<input type="text" name="new_favorite_list" id="id_new_favorite_list" class="fr-input" placeholder="Entretien des locaux, achat de masque…" required>
</div>
<button class="fr-btn {% if user.favorite_list_count %}fr-btn--secondary{% endif %}" type="submit" name="action" value="create">Créer</button>
</form>

<!-- Existing list(s) -->
{% if user.favorite_list_count %}
<form method="POST" action="{% url 'siae:favorite_lists' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<div class="modal-body home-content-body pt-0">
<hr data-text="ou" />
<div class="form-group">
<label>Choisir une liste existante</label>
<ul class="list-group">
{% for favorite_list in user.favorite_lists.all %}
<li class="list-group-item d-flex justify-content-between align-items-center">
<div class="custom-control custom-radio w-100">
<input class="custom-control-input" type="radio" name="favorite_list" value="{{ favorite_list.id }}" id="{{ favorite_list.id }}" required>
<label class="custom-control-label white-space-nowrap d-block" for="{{ favorite_list.id }}">{{ favorite_list.name }}</label>
</div>
<span class="fs-xs badge badge-marche-light badge-pill">{{ favorite_list.siaes.count }}</span>
</li>
{% endfor %}
</ul>
</div>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-primary" type="submit" name="action" value="add">Enregistrer</button>
<!-- Existing list(s) -->
{% if user.favorite_list_count %}
<form method="post" action="{% url 'siae:favorite_lists' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<p class="fr-hr-or">ou</p>

<div class="fr-input-group">
<fieldset class="fr-fieldset" id="favorite_exist_list_radio" aria-labelledby="favorite_exist_list_radio_legend">
<legend class="fr-fieldset__legend--regular fr-fieldset__legend" id="favorite_exist_list_radio_legend">
Choisir une liste existante
</legend>
{% for favorite_list in user.favorite_lists.all %}
<div class="fr-fieldset__element">
<div class="fr-radio-group fr-radio-rich">
<input value="{{ favorite_list.id }}" type="radio" id="favorite_exist_list_radio-{{ favorite_list.id }}" name="favorite_list" required>
<label class="fr-label" for="favorite_exist_list_radio-{{ favorite_list.id }}">
{{ favorite_list.name }} <span class="fr-badge">{{ favorite_list.siaes.count }}</span>
</label>
</div>
</div>
{% endfor %}
</fieldset>
</div>
<button class="fr-btn" type="submit" name="action" value="add">Enregistrer</button>
</form>
{% endif %}
</div>
</form>
{% endif %}
</div>
</div>
</div>
</div>
</div>
</dialog>
52 changes: 31 additions & 21 deletions lemarche/templates/favorites/_favorite_item_remove_modal.html
Original file line number Diff line number Diff line change
@@ -1,24 +1,34 @@
<div class="modal fade modal-siae" id="favorite_item_remove_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="modalTitle">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modalTitle">Supprimer</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>
<form method="POST" action="{% url 'dashboard_favorites:item_delete' favorite_list.slug|default:'favorite-list-slug' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<div class="modal-body home-content-body">
<p class="font-weight-bold">
Supprimer la structure <strong>{% if siae %}{{ siae.name_display }}{% else %}<span id="siae-name-display"></span>{% endif %}</strong> de votre liste d'achat ?
</p>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-outline-primary" type="button" data-dismiss="modal" aria-label="Fermer">Annuler</button>
<button class="btn btn-sm btn-primary" type="submit">Confirmer</button>
<dialog class="fr-modal" id="favorite_item_remove_modal" role="dialog" aria-modal="true" aria-labelledby="favorite_item_remove_modal_title">
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
<div class="fr-col-12 fr-col-md-8 fr-col-lg-6">
<div class="fr-modal__body">
<div class="fr-modal__header">
<button class="fr-btn--close fr-btn" aria-controls="favorite_item_remove_modal">Fermer</button>
</div>
<div class="fr-modal__content">
<h3 id="favorite_item_remove_modal_title" class="fr-modal__title">
Supprimer
</h3>
<p>
Supprimer la structure <strong>{% if siae %}{{ siae.name_display }}{% else %}<span id="siae-name-display"></span>{% endif %}</strong> de votre liste d'achat ?
</p>
</div>
<div class="fr-modal__footer">
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg">
<form method="post" action="{% url 'dashboard_favorites:item_delete' favorite_list.slug|default:'favorite-list-slug' siae.slug|default:'siae-slug-to-replace' %}">
{% csrf_token %}
<button class="fr-btn fr-btn--icon-left" type="submit">
Confirmer
</button>
</form>
<button class="fr-btn fr-btn--icon-left fr-btn--secondary" aria-controls="favorite_item_remove_modal" aria-label="Fermer">
Annuler
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</dialog>
50 changes: 31 additions & 19 deletions lemarche/templates/favorites/_favorite_list_delete_modal.html
Original file line number Diff line number Diff line change
@@ -1,22 +1,34 @@
<div class="modal fade modal-siae" id="favorite_list_delete_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="modalTitle">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modalTitle">Supprimer</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>
<form method="POST" action="{% url 'dashboard_favorites:list_delete' favorite_list.slug %}">
{% csrf_token %}
<div class="modal-body home-content-body">
<p class="font-weight-bold">Voulez vous supprimer cette liste d'achat ?</p>
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-outline-primary" type="button" data-dismiss="modal" aria-label="Fermer">Annuler</button>
<button class="btn btn-sm btn-primary" type="submit">Confirmer</button>
<dialog class="fr-modal" id="favorite_list_delete_modal" role="dialog" aria-modal="true" aria-labelledby="favorite_list_delete_modal_title">
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
<div class="fr-col-12 fr-col-md-8 fr-col-lg-6">
<div class="fr-modal__body">
<div class="fr-modal__header">
<button class="fr-btn--close fr-btn" aria-controls="favorite_list_delete_modal">Fermer</button>
</div>
<div class="fr-modal__content">
<h3 id="favorite_item_remove_modal_title" class="fr-modal__title">
Supprimer
</h3>
<p>
Voulez vous supprimer la liste d'achat <strong>{{ favorite_list.name }}</strong> ?
</p>
</div>
<div class="fr-modal__footer">
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg">
<form method="post" action="{% url 'dashboard_favorites:list_delete' favorite_list.slug %}">
{% csrf_token %}
<button class="fr-btn fr-btn--icon-left" type="submit">
Confirmer
</button>
</form>
<button class="fr-btn fr-btn--icon-left fr-btn--secondary" aria-controls="favorite_list_delete_modal" aria-label="Fermer">
Annuler
</button>
</div>
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</dialog>
54 changes: 34 additions & 20 deletions lemarche/templates/favorites/_favorite_list_edit_modal.html
Original file line number Diff line number Diff line change
@@ -1,23 +1,37 @@
<div class="modal fade modal-siae" id="favorite_list_edit_modal" tabindex="-1" role="dialog" aria-modal="true" data-backdrop="static" data-keyboard="false" aria-labelledby="modalTitle">
<div class="modal-dialog modal-dialog-centered">
<div class="modal-content">
<div class="modal-header">
<h3 class="modal-title" id="modalTitle">Modifier</h3>
<button type="button" class="close" data-dismiss="modal" aria-label="Fermer">
<i class="ri-close-line"></i>
</button>
</div>
<form method="POST" action="{% url 'dashboard_favorites:list_edit' favorite_list.slug %}">
{% csrf_token %}
<div class="modal-body home-content-body">
<p class="font-weight-bold">Modifier le nom de la liste</p>
<input type="text" class="form-control form-control-sm" name="name" value="{{ favorite_list.name }}" required />
</div>
<div class="modal-footer">
<button class="btn btn-sm btn-outline-primary" type="button" data-dismiss="modal" aria-label="Fermer">Annuler</button>
<button class="btn btn-sm btn-primary" type="submit">Confirmer</button>
<dialog class="fr-modal" id="favorite_list_edit_modal" role="dialog" aria-modal="true" aria-labelledby="favorite_list_edit_modal_title">
<div class="fr-container fr-container--fluid fr-container-md">
<div class="fr-grid-row fr-grid-row--center">
<div class="fr-col-12 fr-col-md-8 fr-col-lg-6">
<div class="fr-modal__body">
<div class="fr-modal__header">
<button class="fr-btn--close fr-btn" aria-controls="favorite_list_edit_modal">Fermer</button>
</div>
<div class="fr-modal__content">
<h3 id="favorite_list_edit_modal_title" class="fr-modal__title">
Modifier
</h3>
<form method="post" action="{% url 'dashboard_favorites:list_edit' favorite_list.slug %}">
{% csrf_token %}
<div class="fr-input-group">
<label for="id_favorite_list_edit_modal_name" class="fr-label">
Modifier le nom de la liste*
</label>
<input type="text" name="name" value="{{ favorite_list.name }}" class="fr-input" required="" id="id_favorite_list_edit_modal_name">
</div>
<div class="fr-btns-group fr-btns-group--right fr-btns-group--inline-reverse fr-btns-group--inline-lg">
<button class="fr-btn fr-btn--icon-left" type="submit">
Enregistrer
</button>
<button class="fr-btn fr-btn--icon-left fr-btn--secondary" aria-controls="favorite_list_edit_modal" aria-label="Fermer" type="button">
Annuler
</button>
</div>
</form>
</div>
<div class="fr-modal__footer">
</div>
</div>
</form>
</div>
</div>
</div>
</div>
</dialog>
Loading

0 comments on commit b544881

Please sign in to comment.