possibility to copy order link

This commit is contained in:
Laetitia Getti 2023-05-22 11:11:06 +02:00
parent 87b192adc7
commit d0f180de19
7 changed files with 56 additions and 4 deletions

View file

@ -59,7 +59,7 @@
</table>
{% if error_message %}<p class="has-text-danger">{{ error_message }}</p>{% endif %}
<br>
<p class="title">Vos informations</p>
<p class="subtitle">Vos informations</p>
<div class="columns">
<div class="column">
<p><label for="first_name">Prénom : </label>

View file

@ -7,6 +7,7 @@
{% block content %}
<div class="buttons">
<a class="button is-light" href={% url 'order:grouped_order_detail' grouped_order.id %}>Retour à la page de commande</a>
<a class="button is-primary" href="{% url 'order:index' %}">Mes commandes</a>
</div>
<div class="box is-info">
<div class="columns">
@ -24,6 +25,22 @@
</div>
</div>
</div>
<div class="box">
<p class="title">Partager et imprimer</p>
<div class="columns">
<div class="column">
<p>Pour partager cette commande, il vous suffit de copier ce lien et de l'envoyer à vos connaissances : </p>
<input class="input custom-width" type="text" value={{ share_link }} id="shareLink" disabled>
<button class="button is-info" onclick="copyLink()">Copier le lien</button>
</div>
<div class="column">
<p>Pour vous aider à distribuer les produits le jour J, vous pouvez imprimer la liste des commandes :
<a href="">ici</a></p>
</div>
</div>
</div>
<div class="box">
<p class="title">Produits commandés</p>
<table class="table">
@ -81,3 +98,19 @@
</table>
</div>
{% endblock %}
<script>
{% block extra_js %}
function copyLink() {
// Get the text field
var copyText = document.getElementById("shareLink");
// Select the text field
copyText.select();
copyText.setSelectionRange(0, 99999); // For mobile devices
// Copy the text inside the text field
navigator.clipboard.writeText(copyText.value);
}
{% endblock %}
</script>

View file

@ -71,9 +71,18 @@ class GroupedOrderOverview(UserPassesTestMixin, generic.DetailView):
return self.get_object().orga == self.request.user
def get(self, request, *args, **kwargs):
# Compute grouped order total price before display
self.get_object().compute_total_price()
return super().get(self, request, *args, **kwargs)
def get_context_data(self, **kwargs):
context = super(GroupedOrderOverview, self).get_context_data(**kwargs)
# Add share link to context
context["share_link"] = self.request.build_absolute_uri(
reverse("order:grouped_order_detail", args=(self.get_object().pk,))
)
return context
class GroupedOrderCreateView(LoginRequiredMixin, generic.CreateView):
"""View for creating a new grouped order"""

View file

@ -10375,6 +10375,10 @@ a.navbar-item:hover {
border: #e9b049 1px solid !important;
}
.input.custom-width {
width: unset;
}
@media screen and (max-width: 1023px) {
table {
display: block;

View file

@ -1,3 +1,4 @@
// Buttons
.button
white-space: normal
height: auto
@ -10,3 +11,7 @@
color: $bright-black !important
&.is-light
border: $beige 1px solid !important
// Input
.input.custom-width
width: unset

View file

@ -12,5 +12,5 @@
@import "./base/global"
@import "./base/navbar"
@import "./base/content"
@import "./base/buttons"
@import "./base/form"
@import "./base/table"

View file

@ -140,4 +140,5 @@
});
});
{% block extra_js %}{% endblock %}
</script>