feat: arrastar mesas tambem para depósito

This commit is contained in:
2025-01-03 15:58:44 -03:00
parent 42f3e02b0d
commit a2d751e88f
4 changed files with 27 additions and 5 deletions

Binary file not shown.

View File

@@ -34,22 +34,25 @@ RRB&C - Mapa de Mesas
style="background-color: rgba(0, 0, 255, 0); style="background-color: rgba(0, 0, 255, 0);
width: 50px; width: 50px;
height: 50px; height: 50px;
left: {{eixo.y}}px; left: {{eixo.y}}px;
top: {{eixo.x}}px;position: absolute"> top: {{eixo.x}}px;position: absolute" >
</div> </div>
{% endfor %} {% endfor %}
</div> </div>
<h2>Depósito</h2>
<div id="drop" >
{% 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=" position: absolute; background-color: indianred;" >{{mesa.name}} <input type="text" hidden value="{{mesa.location}}"> </div> <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 %} {% else %}
<div id="{{mesa.id}}" class="m-card" ondragend="saveLocal()" draggable="true" >{{mesa.name}} <input type="text" hidden value="{{mesa.location}}"></div> <div id="{{mesa.id}}" class="m-card" ondragend="saveLocal()" draggable="true" >{{mesa.name}} <input type="text" hidden value="{{mesa.location}}"></div>
{% endif %} {% endif %}
{% endfor %} {% endfor %}
</div>
{% endblock %} {% endblock %}

View File

@@ -54,4 +54,15 @@
.espaco { .espaco {
border: 0.3px solid #cccccc56; border: 0.3px solid #cccccc56;
padding: 0px; padding: 0px;
}
#drop {
display: flex;
background-color: rgb(75, 75, 75);
border-radius: 15px;
padding: 15px;
margin: 15px;
min-height: 300px;
max-width: 1370px;
} }

View File

@@ -44,8 +44,13 @@ function saveLocal() {
const mesaElement = event.target; const mesaElement = event.target;
const targetElement = event.target.parentNode; const targetElement = event.target.parentNode;
const mesaId = mesaElement.id const mesaId = mesaElement.id
const targetId = targetElement.id; const targetId = targetElement.id;
const parentNodeClass = targetElement.classList.value
console.log(parentNodeClass)
if (parentNodeClass == 'espaco' || targetId == 'drop'){
const url = `/mesas/locationMesa/${mesaId}/${targetId}/`; const url = `/mesas/locationMesa/${mesaId}/${targetId}/`;
var resposta = fetch(url, {method: 'POST', var resposta = fetch(url, {method: 'POST',
headers: {'Content-Type': 'application/json', headers: {'Content-Type': 'application/json',
@@ -61,6 +66,9 @@ var resposta = fetch(url, {method: 'POST',
console.log(document.cookie) console.log(document.cookie)
console.error('Erro ao salvar local:', error); console.error('Erro ao salvar local:', error);
}); });
}else{
alert('Aqui não pode!!!')
}
} }