diff --git a/gestaoRaul/db.sqlite3 b/gestaoRaul/db.sqlite3 index 4736644..f38d75c 100644 Binary files a/gestaoRaul/db.sqlite3 and b/gestaoRaul/db.sqlite3 differ diff --git a/gestaoRaul/products/__pycache__/views.cpython-313.pyc b/gestaoRaul/products/__pycache__/views.cpython-313.pyc index 5df9b4b..55c6a7e 100644 Binary files a/gestaoRaul/products/__pycache__/views.cpython-313.pyc and b/gestaoRaul/products/__pycache__/views.cpython-313.pyc differ diff --git a/gestaoRaul/products/templates/products.html b/gestaoRaul/products/templates/products.html index b39b04c..c16936f 100644 --- a/gestaoRaul/products/templates/products.html +++ b/gestaoRaul/products/templates/products.html @@ -17,12 +17,17 @@ Produtos {% block 'body' %} - +
-
-
+
+ +
- @@ -77,6 +82,7 @@ Produtos
+ {% csrf_token %}

Cadastro de Produto


@@ -92,7 +98,8 @@ Produtos
- + +
diff --git a/gestaoRaul/products/views.py b/gestaoRaul/products/views.py index a352198..686fe49 100644 --- a/gestaoRaul/products/views.py +++ b/gestaoRaul/products/views.py @@ -35,8 +35,9 @@ def onOffProduct(request): return redirect('products') def editProduct(request, productId): - # id = request.POST.get('productId') - product_id = productId + print('wwwwwwwwwwwwwwwwwwwwwwww ', request.POST.get('productId'),' ooooooooooo') + product_id = int(request.POST.get('productId')) + # product_id = productId product = Product.objects.get(id=product_id) product.name = request.POST.get('name') product.description = request.POST.get('description') @@ -44,4 +45,11 @@ def editProduct(request, productId): product.quantity = request.POST.get('qtd') product.category = Categories.objects.get(id = int(request.POST.get('select-categorie'))) product.save() - return redirect('products') \ No newline at end of file + print(request.GET.get("search-product")) + product = request.GET.get("search-product") + if product == None: + product = '' + products = Product.objects.filter(name__icontains=product) + return render(request, "htmx_components/products/htmx_search_products.html", {"products": products}) + # return render(request, 'products.html') + # return redirect('/products') \ No newline at end of file diff --git a/gestaoRaul/templates/static/products/css/products.css b/gestaoRaul/templates/static/products/css/products.css index 3dfd91a..ff54869 100644 --- a/gestaoRaul/templates/static/products/css/products.css +++ b/gestaoRaul/templates/static/products/css/products.css @@ -76,6 +76,11 @@ input, textarea { margin: 0 auto; } +.grid-top { + display: flex; + width: 100%; + } + .card { width: 100%; height: 120px; diff --git a/gestaoRaul/templates/static/products/js/products.js b/gestaoRaul/templates/static/products/js/products.js index c20b2e1..9d781c3 100644 --- a/gestaoRaul/templates/static/products/js/products.js +++ b/gestaoRaul/templates/static/products/js/products.js @@ -1,5 +1,22 @@ function openModal() { document.getElementById('Modal-create-product').style.display = 'block'; + var productId = document.getElementById('productId'); + var productName = document.getElementById('productName'); + var productPrice = document.getElementById('productPrice'); + var productDescription = document.getElementById('productDescription'); + var productqtd = document.getElementById('productqtd'); + var categorie = document.getElementById('select-categorie'); + var buttonEdit = document.getElementById('edit'); + var buttonSave = document.getElementById('save'); + buttonEdit.style.display = 'none'; + buttonSave.style.display = 'block'; + + productId.value = ''; + productName.value = ''; + productPrice.value = ''; + productDescription.value =''; + productqtd.value = ''; + categorie.value = 1; } function closeModal() { @@ -8,14 +25,19 @@ function closeModal() { function editProduct(id) { + openModal(); + var buttonSave = document.getElementById('save'); + var buttonEdit = document.getElementById('edit'); + buttonSave.style.display = 'none'; + buttonEdit.style.display = 'block'; var productId = document.getElementById('productId'); var productName = document.getElementById('productName'); var productPrice = document.getElementById('productPrice'); var productDescription = document.getElementById('productDescription'); var productqtd = document.getElementById('productqtd'); var categorie = document.getElementById('select-categorie'); - openModal(); - // productId.innerHTML = id; + + productId.value = id; productName.value = document.getElementById('name-'+id).innerHTML; var preco = document.getElementById('price-'+id).innerHTML; preco = preco.replace('R$ ', ''); @@ -23,7 +45,7 @@ function editProduct(id) { productPrice.value = preco; productDescription.value = document.getElementById('description-'+id).value; productqtd.value = document.getElementById('quantity-'+id).innerHTML; - console.log(document.getElementById('h-category-'+id).value) + // console.log(document.getElementById('h-category-'+id).value) categorie.value = document.getElementById('h-category-'+id).value; // const url = `/products/editProduct/${id}/`;