refactor: remoção do htmx do excluir item da comanda | feedback da exclusão

This commit is contained in:
2025-07-01 12:28:47 -03:00
parent 377fac4f1c
commit fe00c4da90
10 changed files with 151 additions and 189 deletions

View File

@@ -53,12 +53,22 @@ def removeProductComanda(request, productComanda_id):
'id':order.id,
'speak': f'Pedido cancelado! {order.id_product.name}.'
})
asyncio.run(enviar_mensagem(msg))
# asyncio.run(enviar_mensagem(msg))
# order.delete()
consumo = ProductComanda.objects.filter(comanda=comanda)
valores = somar(consumo,comanda)
else:
product_comanda.delete()
consumo = ProductComanda.objects.filter(comanda=comanda)
valores = somar(consumo,comanda)
return render(request, "htmx_components/comandas/htmx_list_products_in_comanda.html",{'config':config, 'valores': valores,'parcials':parcial,'consumo': consumo, 'comanda':comanda})
return render(request,
"htmx_components/comandas/htmx_list_products_in_comanda.html",
{'config':config,
'valores': valores,
'parcials':parcial,
'consumo': consumo,
'comanda':comanda})
else:
pass

View File

@@ -103,7 +103,7 @@ Detalhes {{comanda.name}}
{% for item in consumo%}
<tr>
<tr id="item-{{item.id}}">
<td id="id-for-print-{{item.id}}">
<spam style="cursor: pointer;" onclick="inforOrders({{item.id}})">
{{item.product.name}}</spam>
@@ -131,13 +131,12 @@ Detalhes {{comanda.name}}
{% if comanda.status != 'OPEN'%}
{% else %}
<td>
<img
src="{% static 'midia/icons/delete.svg' %}"
style="width: 35px; height: 35px; cursor: pointer;"
hx-get="{% url 'removeProductComanda' item.id %} "
hx-trigger="click"
hx-target="#list-products-comanda"
hx-confirm="Tem certeza que deseja excluir o produto {{item.product.name}}?" >
>
</img>
</td>
{% endif %}
@@ -180,30 +179,21 @@ Detalhes {{comanda.name}}
<button class="btn-secondary" onclick="modal_payment_parcial()">Pagamento Parcial</button>
</div>
<div id="addProduct" class="popover">
<!-- <div id="productForm" > -->
<div hidden id="addProduct" >
{% csrf_token %}
<input type="text" oninput="searchProduct()" id="search-product" name="search-product" placeholder="Buscar Produto" ><br>
<div id="product-list" class="grid-list-products">
{% for product in products %}
<div class="card-product" onclick="addProductComanda({{product.id}}, {{comanda.id}}, '{{product.cuisine}}')" >
{{product.name}} <br>
R$ {{product.price}}
</div >
{% endfor %}
</div>
<!-- </div> -->
</div>
<dialog id="payment-comanda" style="display: none;" >
<article>
<form action="{% url 'paymentComanda' comanda.id %}" method="post">

View File

@@ -22,7 +22,7 @@ urlpatterns = [
htmx_urlpatterns = [
path('removeProductComanda<int:productComanda_id>/', htmx_views.removeProductComanda, name='removeProductComanda'),
path('removeProductComanda/<int:productComanda_id>/', htmx_views.removeProductComanda, name='removeProductComanda'),
path('reopenComanda<int:comanda_id>/', htmx_views.reopenComanda, name='reopenComanda'),
path('paymentComanda<int:comanda_id>/', htmx_views.paymentComanda, name='paymentComanda'),
path('paymentParcial<int:comanda_id>/', htmx_views.paymentParcial, name='paymentParcial'),