feat: page mesas_map, popover com lista de comandas associadas com nome, total, e link para abrir a comanda. mesas livre cor diferente e não cria popover.

This commit is contained in:
2025-01-28 20:57:53 -03:00
parent c8119609ea
commit 0534b896ad
6 changed files with 207 additions and 55 deletions

Binary file not shown.

View File

@@ -1,9 +1,10 @@
{% extends "base.html" %} {% extends "base.html" %}
{% load static %} {% load static %}
{% load custom_filter_tag %}
{% block 'head' %} {% block 'head' %}
<link rel="stylesheet" href="{% static 'mesas/css/mesas.css' %}"> <link rel="stylesheet" href="{% static 'mesas/css/mesas_map.css' %}">
<script src="{% static 'mesas/js/mesas_map.js' %}"></script> <script src="{% static 'mesas/js/mesas_map.js' %}"></script>
{% endblock %} {% endblock %}
@@ -24,29 +25,7 @@ RRB&C - Mapa de Mesas
background-image: url("{% static 'midia/mapMesa.webp' %}" ); background-image: url("{% static 'midia/mapMesa.webp' %}" );
background-size: cover; background-size: cover;
position: relative; position: relative;
} }
#scroll {
display: grid;
position: relative;
scrollbar-width: thin;
}
@media screen and (max-width: 730px) {
#scroll {
margin: 10px;
overflow: scroll;
}
#mapa {
margin: 0px;
}
}
</style> </style>
<h1>Mapa de Mesas</h1> <h1>Mapa de Mesas</h1>
@@ -57,11 +36,10 @@ RRB&C - Mapa de Mesas
<div <div
id="{{eixo.x}}-{{eixo.y}}" id="{{eixo.x}}-{{eixo.y}}"
class="espaco" class="espaco"
style="background-color: rgba(0, 0, 255, 0); style="
width: 50px;
height: 50px;
left: {{eixo.y}}px; left: {{eixo.y}}px;
top: {{eixo.x}}px;position: absolute" > top: {{eixo.x}}px;
">
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
@@ -72,18 +50,44 @@ RRB&C - Mapa de Mesas
{% for mesa in mesas %} {% for mesa in mesas %}
{% if mesa.active == True %} {% if mesa.active == True %}
<div id="{{mesa.id}}" class="m-card" ondragend="saveLocal()" draggable="true" style=" background-color: indianred;" >{{mesa.name}} <input type="text" hidden value="{{mesa.location}}"> </div>
{% else %}
<div id="{{mesa.id}}" class="m-card" ondragend="saveLocal()" draggable="true" > <button style="border: none;background-color: rgba(240, 248, 255, 0);padding: 0px; font-size: 12px;color: black;" popovertarget="my-pop-{{mesa.id}}"> {{mesa.name}} </ style="border: none;background-color: aliceblue;padding: 0px;"><input type="text" hidden value="{{mesa.location}}"></div>
<div id="my-pop-{{mesa.id}}" popover <div
style="width: 200px; id="{{mesa.id}}"
height: 200px;"> class="m-card"
{{mesa.id}} ondragend="saveLocal()"
{{mesa.name}} draggable="true">
<button
class="button-popover"
popovertarget="my-pop-{{mesa.id}}">
{{mesa.name}} {{mesa.name}}
</button>
<input type="text" hidden value="{{mesa.location}}">
</div> </div>
<div id="my-pop-{{mesa.id}}" popover class="popover">
<h4>{{mesa.name}}</h4>
{% for comanda in comandas %}
{% if comanda.mesa.id == mesa.id %}
<div >
<a href="{% url 'viewcomanda' %}?parametro={{ comanda.id }}">
{{comanda.name}}🔗
</a>
{{ comanda.id | total }}
</div>
{% endif %}
{% endfor %}
</div>
{% else %}
<div
style="background-color: rgb(148, 255, 127);"
id="{{mesa.id}}"
class="m-card"
ondragend="saveLocal()"
draggable="true" >
{{mesa.name}}
<input type="text" hidden value="{{mesa.location}}">
</div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}

View File

@@ -1,15 +1,17 @@
from django.shortcuts import render from django.shortcuts import render
from django.http import JsonResponse from django.http import JsonResponse
from comandas.models import Comanda
from mesas.models import Mesa from mesas.models import Mesa
from gestaoRaul.decorators import group_required
def mesas(request): def mesas(request):
mesas = Mesa.objects.all() mesas = Mesa.objects.all()
return render(request, 'mesas.html', {'mesas': mesas}) return render(request, 'mesas.html', {'mesas': mesas, })
@group_required(groupName='Garçom')
def mapMesas(request): def mapMesas(request):
eixosXY = [] eixosXY = []
for i in range(0,27): for i in range(0,27):
@@ -18,7 +20,16 @@ def mapMesas(request):
eixosXY.append(item) eixosXY.append(item)
mesas = Mesa.objects.all() mesas = Mesa.objects.all()
return render(request, 'mesas_map.html', {'mesas': mesas, 'eixosXY': eixosXY}) comandas = Comanda.objects.filter(status__in=["OPEN", "PAYING"])
for mesa in mesas:
for comanda in comandas:
if mesa.id == comanda.mesa.id:
mesa.active = True
break
for mesa in mesas:
print(mesa.active)
return render(request, 'mesas_map.html', {'comandas': comandas,'mesas': mesas, 'eixosXY': eixosXY})
def locationMesa(request, mesaId, location): def locationMesa(request, mesaId, location):
print('inicioul') print('inicioul')

View File

@@ -19,7 +19,7 @@
color: #333; color: #333;
transition: transform 0.2s; transition: transform 0.2s;
} }
.m-card { /* .m-card {
width: 50px; width: 50px;
height: 50px; height: 50px;
background-color: #f2f2f2; background-color: #f2f2f2;
@@ -32,20 +32,20 @@
color: #333; color: #333;
transition: transform 0.2s; transition: transform 0.2s;
cursor: move; cursor: move;
} } */
.card:hover { .card:hover {
transform: scale(1.05); transform: scale(1.05);
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3); box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
} }
.m-card:hover { /* .m-card:hover {
transform: scale(1.05); transform: scale(1.05);
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3); box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
} } */
/*
.elemento { .elemento {
position: absolute; position: absolute;
} }
@@ -63,4 +63,4 @@
padding: 15px; padding: 15px;
min-height: 300px; min-height: 300px;
max-width: 1400px; max-width: 1400px;
} } */

View File

@@ -0,0 +1,137 @@
@keyframes jump {
0% {
transform: scale(0.0);
}
70% {
transform: scale(1.2);
}
100% {
transform: scale(1);
}
}
.m-card {
width: 50px;
height: 50px;
background-color: #ff9797;
border-radius: 15px;
box-shadow: 5px 5px 10px rgba(0, 0, 0, 0.2);
text-align: center;
line-height: 50px;
font-size: 10px;
font-weight: bold;
color: #333;
transition: transform 0.2s;
cursor: move;
}
.m-card:hover {
transform: scale(1.05);
box-shadow: 10px 10px 20px rgba(0, 0, 0, 0.3);
}
.elemento {
position: absolute;
}
.espaco {
border: 0.3px solid #cccccc56;
padding: 0px;
background-color: rgba(0, 0, 255, 0);
width: 50px;
height: 50px;
position: absolute
}
.popover{
width: 300px;
height: 400px;
top: 20%;
left: 25%;
padding: 20px;
background-color: #f2f2f29d;
border-radius: 15px;
border: none;
box-shadow: 0px 0px 8px rgba(0, 0, 0, 0.2);
text-align: justify;
line-height: 50px;
font-size: 18px;
font-weight: bold;
color: #333;
transition: transform 0.2s;
animation: jump 0.7s;
}
.popover div {
display: flex;
color: #333;
width: 100%;
justify-content: space-between;
}
.popover > h4 {
color: #333;
justify-self: center;
}
.popover a {
text-decoration: none;
color: #333;
justify-self: center;
}
.popover::backdrop {
background-color: rgba(0, 0, 0, 0.5);
backdrop-filter: blur(5px);
/* animation: jump 0.2s; */
}
.button-popover {
border: none;
background-color: rgba(240, 248, 255, 0);
padding: 0px;
font-size: 12px;
color: black;
}
#drop {
display: flex;
background-color: rgb(75, 75, 75);
border-radius: 15px;
padding: 15px;
min-height: 300px;
max-width: 1400px;
}
#scroll {
display: grid;
position: relative;
scrollbar-width: thin;
}
@media screen and (max-width: 730px) {
#scroll {
margin: 10px;
overflow: scroll;
}
#mapa {
margin: 0px;
}
.popover {
left: 15%;
width: 70%;
}
}