Fixed some shit making buttons double press sometimes
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
import os
|
import os
|
||||||
from flask import Blueprint, render_template, request, redirect, url_for, jsonify, current_app
|
from flask import Blueprint, render_template, request, redirect, url_for, jsonify, current_app
|
||||||
from flask_login import login_required, current_user
|
from flask_login import login_required, current_user
|
||||||
|
from werkzeug.utils import secure_filename
|
||||||
from core.db import get_db_connection
|
from core.db import get_db_connection
|
||||||
from core.utils import download_image
|
from core.utils import download_image
|
||||||
from core.events import socketio
|
from core.events import socketio
|
||||||
@@ -50,6 +51,31 @@ def upsert():
|
|||||||
conn.commit()
|
conn.commit()
|
||||||
return redirect(url_for('inventory.inventory'))
|
return redirect(url_for('inventory.inventory'))
|
||||||
|
|
||||||
|
@inventory_bp.route('/upload_image', methods=['POST'])
|
||||||
|
@login_required
|
||||||
|
def upload_image():
|
||||||
|
if 'image' not in request.files:
|
||||||
|
return jsonify({"error": "No image file provided"}), 400
|
||||||
|
|
||||||
|
file = request.files['image']
|
||||||
|
barcode = request.form.get('barcode', '')
|
||||||
|
|
||||||
|
if not barcode:
|
||||||
|
return jsonify({"error": "No barcode provided"}), 400
|
||||||
|
|
||||||
|
if file.filename == '':
|
||||||
|
return jsonify({"error": "Empty file"}), 400
|
||||||
|
|
||||||
|
cache_dir = current_app.config['CACHE_DIR']
|
||||||
|
ext = '.jpg'
|
||||||
|
local_filename = f"{secure_filename(barcode)}{ext}"
|
||||||
|
local_path = os.path.join(cache_dir, local_filename)
|
||||||
|
|
||||||
|
file.save(local_path)
|
||||||
|
|
||||||
|
image_url = f"/static/cache/{local_filename}"
|
||||||
|
return jsonify({"image_url": image_url}), 200
|
||||||
|
|
||||||
@inventory_bp.route('/delete/<barcode>', methods=['POST'])
|
@inventory_bp.route('/delete/<barcode>', methods=['POST'])
|
||||||
@login_required
|
@login_required
|
||||||
def delete(barcode):
|
def delete(barcode):
|
||||||
|
|||||||
@@ -67,7 +67,7 @@
|
|||||||
<div class="col-8">
|
<div class="col-8">
|
||||||
<label class="form-label text-muted small mb-1">Precio Unitario</label>
|
<label class="form-label text-muted small mb-1">Precio Unitario</label>
|
||||||
<input type="number" id="custom-price" class="form-control" placeholder="Ej: 1500"
|
<input type="number" id="custom-price" class="form-control" placeholder="Ej: 1500"
|
||||||
onkeydown="if(event.key === 'Enter') addCustomProduct()">
|
onkeydown="if(event.key === 'Enter') { event.stopPropagation(); addCustomProduct(); }">
|
||||||
</div>
|
</div>
|
||||||
<div class="col-4">
|
<div class="col-4">
|
||||||
<label class="form-label text-muted small mb-1">Tipo</label>
|
<label class="form-label text-muted small mb-1">Tipo</label>
|
||||||
@@ -101,7 +101,7 @@
|
|||||||
<input type="text" inputmode="numeric" id="varios-price-input" class="form-control form-control-lg text-center fw-bold fs-4"
|
<input type="text" inputmode="numeric" id="varios-price-input" class="form-control form-control-lg text-center fw-bold fs-4"
|
||||||
placeholder="$0"
|
placeholder="$0"
|
||||||
oninput="let v = this.value.replace(/\D/g, ''); this.value = v ? parseInt(v, 10).toLocaleString('es-CL') : '';"
|
oninput="let v = this.value.replace(/\D/g, ''); this.value = v ? parseInt(v, 10).toLocaleString('es-CL') : '';"
|
||||||
onkeydown="if(event.key === 'Enter') addVariosToCart()">
|
onkeydown="if(event.key === 'Enter') { event.stopPropagation(); addVariosToCart(); }">
|
||||||
</div>
|
</div>
|
||||||
<button class="btn btn-warning w-100 py-3 fw-bold" onclick="addVariosToCart()">
|
<button class="btn btn-warning w-100 py-3 fw-bold" onclick="addVariosToCart()">
|
||||||
<i class="bi bi-cart-plus me-1"></i> Agregar al Carrito
|
<i class="bi bi-cart-plus me-1"></i> Agregar al Carrito
|
||||||
@@ -119,7 +119,7 @@
|
|||||||
</div>
|
</div>
|
||||||
<div class="modal-body">
|
<div class="modal-body">
|
||||||
<input type="number" id="weight-input" class="form-control form-control-lg" step="1"
|
<input type="number" id="weight-input" class="form-control form-control-lg" step="1"
|
||||||
placeholder="Ej: 500" onkeydown="if(event.key === 'Enter') confirmWeight()">
|
placeholder="Ej: 500" onkeydown="if(event.key === 'Enter') { event.stopPropagation(); confirmWeight(); }">
|
||||||
</div>
|
</div>
|
||||||
<div class="modal-footer d-flex">
|
<div class="modal-footer d-flex">
|
||||||
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">Cancelar</button>
|
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">Cancelar</button>
|
||||||
@@ -1539,6 +1539,7 @@
|
|||||||
|
|
||||||
// 3. The Money Button: Enter
|
// 3. The Money Button: Enter
|
||||||
if (event.code === 'NumpadEnter' || event.key === 'Enter') {
|
if (event.code === 'NumpadEnter' || event.key === 'Enter') {
|
||||||
|
if (event.repeat) return;
|
||||||
|
|
||||||
if (itemIndexToRemove !== null) {
|
if (itemIndexToRemove !== null) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
@@ -1562,7 +1563,7 @@
|
|||||||
|
|
||||||
// 4. The Varios Button: +
|
// 4. The Varios Button: +
|
||||||
if (event.code === 'NumpadAdd' || event.key === '+') {
|
if (event.code === 'NumpadAdd' || event.key === '+') {
|
||||||
if (isTyping) return;
|
if (isTyping || event.repeat) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
openVariosModal();
|
openVariosModal();
|
||||||
return;
|
return;
|
||||||
@@ -1570,7 +1571,7 @@
|
|||||||
|
|
||||||
// 5. The Oops Button: - (Remove last item)
|
// 5. The Oops Button: - (Remove last item)
|
||||||
if (event.code === 'NumpadSubtract' || event.key === '-') {
|
if (event.code === 'NumpadSubtract' || event.key === '-') {
|
||||||
if (isTyping) return;
|
if (isTyping || event.repeat || itemIndexToRemove !== null) return;
|
||||||
if (!openModal && cart.length > 0) {
|
if (!openModal && cart.length > 0) {
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
removeItem(cart.length - 1);
|
removeItem(cart.length - 1);
|
||||||
@@ -1580,7 +1581,7 @@
|
|||||||
|
|
||||||
// 6. The Speedrun Button: * (Venta Rápida)
|
// 6. The Speedrun Button: * (Venta Rápida)
|
||||||
if (event.code === 'NumpadMultiply' || event.key === '*') {
|
if (event.code === 'NumpadMultiply' || event.key === '*') {
|
||||||
if (isTyping) return;
|
if (isTyping || event.repeat) return;
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
openQuickSaleModal();
|
openQuickSaleModal();
|
||||||
return;
|
return;
|
||||||
@@ -1592,11 +1593,6 @@
|
|||||||
itemIndexToRemove = null;
|
itemIndexToRemove = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Safety cleanup: If you close the remove modal with ESC or the Eject button, clear the memory
|
|
||||||
document.getElementById('removeConfirmModal').addEventListener('hidden.bs.modal', function () {
|
|
||||||
itemIndexToRemove = null;
|
|
||||||
});
|
|
||||||
|
|
||||||
/* =========================================
|
/* =========================================
|
||||||
9. DOOM EASTER EGG LOGIC
|
9. DOOM EASTER EGG LOGIC
|
||||||
========================================= */
|
========================================= */
|
||||||
|
|||||||
Reference in New Issue
Block a user