Fixed some shit making buttons double press sometimes
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
import os
|
||||
from flask import Blueprint, render_template, request, redirect, url_for, jsonify, current_app
|
||||
from flask_login import login_required, current_user
|
||||
from werkzeug.utils import secure_filename
|
||||
from core.db import get_db_connection
|
||||
from core.utils import download_image
|
||||
from core.events import socketio
|
||||
@@ -50,6 +51,31 @@ def upsert():
|
||||
conn.commit()
|
||||
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'])
|
||||
@login_required
|
||||
def delete(barcode):
|
||||
|
||||
@@ -67,7 +67,7 @@
|
||||
<div class="col-8">
|
||||
<label class="form-label text-muted small mb-1">Precio Unitario</label>
|
||||
<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 class="col-4">
|
||||
<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"
|
||||
placeholder="$0"
|
||||
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>
|
||||
<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
|
||||
@@ -119,7 +119,7 @@
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<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 class="modal-footer d-flex">
|
||||
<button class="btn btn-secondary flex-grow-1" data-bs-dismiss="modal">Cancelar</button>
|
||||
@@ -1539,6 +1539,7 @@
|
||||
|
||||
// 3. The Money Button: Enter
|
||||
if (event.code === 'NumpadEnter' || event.key === 'Enter') {
|
||||
if (event.repeat) return;
|
||||
|
||||
if (itemIndexToRemove !== null) {
|
||||
event.preventDefault();
|
||||
@@ -1562,7 +1563,7 @@
|
||||
|
||||
// 4. The Varios Button: +
|
||||
if (event.code === 'NumpadAdd' || event.key === '+') {
|
||||
if (isTyping) return;
|
||||
if (isTyping || event.repeat) return;
|
||||
event.preventDefault();
|
||||
openVariosModal();
|
||||
return;
|
||||
@@ -1570,7 +1571,7 @@
|
||||
|
||||
// 5. The Oops Button: - (Remove last item)
|
||||
if (event.code === 'NumpadSubtract' || event.key === '-') {
|
||||
if (isTyping) return;
|
||||
if (isTyping || event.repeat || itemIndexToRemove !== null) return;
|
||||
if (!openModal && cart.length > 0) {
|
||||
event.preventDefault();
|
||||
removeItem(cart.length - 1);
|
||||
@@ -1580,7 +1581,7 @@
|
||||
|
||||
// 6. The Speedrun Button: * (Venta Rápida)
|
||||
if (event.code === 'NumpadMultiply' || event.key === '*') {
|
||||
if (isTyping) return;
|
||||
if (isTyping || event.repeat) return;
|
||||
event.preventDefault();
|
||||
openQuickSaleModal();
|
||||
return;
|
||||
@@ -1592,11 +1593,6 @@
|
||||
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
|
||||
========================================= */
|
||||
|
||||
Reference in New Issue
Block a user