From a1bfb25abf990a0e017da7e36c45a0c981ef4ada Mon Sep 17 00:00:00 2001 From: Shiro-Nek0 Date: Thu, 19 Mar 2026 23:20:23 -0300 Subject: [PATCH] edit product from html to modal --- app.py | 2 +- templates/admin_productos.html | 69 +++++++++++++++++++++++---- templates/edit_producto.html | 86 ---------------------------------- templates/macros/modals.html | 64 +++++++++++++++++++++++++ 4 files changed, 125 insertions(+), 96 deletions(-) delete mode 100644 templates/edit_producto.html create mode 100644 templates/macros/modals.html diff --git a/app.py b/app.py index f0a0223..a307883 100644 --- a/app.py +++ b/app.py @@ -489,7 +489,7 @@ def manage_products(): c.execute("SELECT id, name FROM zonas ORDER BY name") zonas = c.fetchall() - c.execute('''SELECT p.id, p.name, p.price, p.commission, z.name + c.execute('''SELECT p.id, p.name, p.price, p.commission, z.name, p.zona_id FROM productos p JOIN zonas z ON p.zona_id = z.id ORDER BY z.name, p.name''') diff --git a/templates/admin_productos.html b/templates/admin_productos.html index 4eaadfb..a1f0ec7 100644 --- a/templates/admin_productos.html +++ b/templates/admin_productos.html @@ -1,5 +1,5 @@ {% extends "macros/base.html" %} - +{% from 'macros/modals.html' import confirm_modal, edit_product_modal %} {% block title %}Catálogo de Productos{% endblock %} @@ -19,6 +19,8 @@ {% endif %} {% endwith %} +{{ edit_product_modal(zonas) }} +
Agregar Nuevo Producto
@@ -79,10 +81,30 @@ ${{ "{:,.0f}".format(prod[2]).replace(',', '.') }} ${{ "{:,.0f}".format(prod[3]).replace(',', '.') }} - Editar -
- -
+ + + + + {{ confirm_modal( + id='deleteProd' ~ prod[0], + title='Eliminar Producto', + message='¿Estás seguro de que deseas eliminar "' ~ prod[1] ~ '"?', + action_url=url_for('delete_product', id=prod[0]), + btn_class='btn-danger', + btn_text='Eliminar permanentemente' + ) }} {% else %} @@ -94,16 +116,45 @@
+{% endblock %} + +{% block scripts %} + -{% endblock %} \ No newline at end of file diff --git a/templates/macros/modals.html b/templates/macros/modals.html new file mode 100644 index 0000000..a83b46f --- /dev/null +++ b/templates/macros/modals.html @@ -0,0 +1,64 @@ +{% macro confirm_modal(id, title, message, action_url, btn_class='btn-primary', btn_text='Confirmar') %} + +{% endmacro %} + +{% macro edit_product_modal(zonas) %} + +{% endmacro %} \ No newline at end of file