Add Products tab with edit, remove, and backup
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -31,6 +31,7 @@
|
||||
</a>
|
||||
<div class="nav-links">
|
||||
<a href="{% url 'entry' %}" class="nav-link {% block nav_entry_active %}{% endblock %}" data-i18n="data_entry">ثبت اطلاعات</a>
|
||||
<a href="{% url 'products' %}" class="nav-link {% block nav_products_active %}{% endblock %}" data-i18n="products">محصولات</a>
|
||||
<a href="{% url 'print_queue' %}" class="nav-link {% block nav_print_active %}{% endblock %}" data-i18n="print_queue">صف چاپ</a>
|
||||
<a href="{% url 'calibrate' %}" class="nav-link" data-i18n="calibrate">کالیبراسیون</a>
|
||||
</div>
|
||||
|
||||
@@ -23,29 +23,6 @@
|
||||
</option>
|
||||
{% endfor %}
|
||||
</select>
|
||||
<button type="button" class="btn btn-sm btn-ghost" onclick="showAddProduct()" data-i18n="add_product">+ Add New Product</button>
|
||||
</div>
|
||||
|
||||
<!-- Add Product Inline (hidden) -->
|
||||
<div id="add-product-panel" class="sub-panel" style="display:none;">
|
||||
<div class="form-row">
|
||||
<div class="form-group">
|
||||
<label for="new-code" data-i18n="product_code">Product Code</label>
|
||||
<input type="text" id="new-code" placeholder="ICJ/000">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="new-desc" data-i18n="description">Description</label>
|
||||
<input type="text" id="new-desc" placeholder="DIGITAL INK ...">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="new-weight" data-i18n="default_weight">Default Weight</label>
|
||||
<input type="number" id="new-weight" value="5" step="1" min="1">
|
||||
</div>
|
||||
</div>
|
||||
<div class="form-actions-inline">
|
||||
<button type="button" class="btn btn-accent btn-sm" onclick="addProduct()" data-i18n="save">Save</button>
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="hideAddProduct()" data-i18n="cancel">Cancel</button>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="form-group">
|
||||
|
||||
90
slips/templates/slips/products.html
Normal file
90
slips/templates/slips/products.html
Normal file
@@ -0,0 +1,90 @@
|
||||
{% extends 'slips/base.html' %}
|
||||
{% load static %}
|
||||
|
||||
{% block title %}Products — Lithium | Print Label{% endblock %}
|
||||
{% block nav_products_active %}active{% endblock %}
|
||||
|
||||
{% block content %}
|
||||
<div class="page-grid">
|
||||
<!-- Add / Edit Product -->
|
||||
<section class="card glass-card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title" id="product-form-title" data-i18n="add_product">+ Add New Product</h2>
|
||||
<span class="card-badge badge-accent">📦</span>
|
||||
</div>
|
||||
<form id="product-form" class="form-stack">
|
||||
<input type="hidden" id="edit-id" value="">
|
||||
<div class="form-group">
|
||||
<label for="prod-code" data-i18n="product_code">Product Code</label>
|
||||
<input type="text" id="prod-code" required placeholder="ICJ/000">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="prod-desc" data-i18n="description">Description</label>
|
||||
<input type="text" id="prod-desc" required placeholder="DIGITAL INK ...">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="prod-weight" data-i18n="default_weight">Default Weight</label>
|
||||
<input type="number" id="prod-weight" value="5" step="1" min="1" required>
|
||||
</div>
|
||||
<div class="form-actions-inline">
|
||||
<button type="submit" class="btn btn-accent" id="product-save-btn" data-i18n="save">Save</button>
|
||||
<button type="button" class="btn btn-ghost" id="product-cancel-btn" style="display:none;" onclick="cancelEdit()" data-i18n="cancel">Cancel</button>
|
||||
</div>
|
||||
</form>
|
||||
</section>
|
||||
|
||||
<!-- Product List -->
|
||||
<section class="card glass-card">
|
||||
<div class="card-header">
|
||||
<h2 class="card-title" data-i18n="products">Products</h2>
|
||||
<div class="card-actions">
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="backupProducts()" data-i18n="backup">Backup</button>
|
||||
<button type="button" class="btn btn-ghost btn-sm" onclick="document.getElementById('restore-file').click()" data-i18n="restore">Restore</button>
|
||||
<input type="file" id="restore-file" accept="application/json,.json" hidden onchange="restoreProducts(this)">
|
||||
<span class="card-badge badge-muted" id="product-count">{{ products|length }}</span>
|
||||
</div>
|
||||
</div>
|
||||
<div class="table-wrap">
|
||||
<table class="data-table" id="products-table">
|
||||
<thead>
|
||||
<tr>
|
||||
<th data-i18n="product_code">Code</th>
|
||||
<th data-i18n="description">Description</th>
|
||||
<th data-i18n="default_weight">Weight</th>
|
||||
<th></th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody id="products-body">
|
||||
{% for p in products %}
|
||||
<tr id="product-row-{{ p.id }}">
|
||||
<td class="mono">{{ p.code }}</td>
|
||||
<td>{{ p.description }}</td>
|
||||
<td class="mono">{{ p.default_net_weight }}</td>
|
||||
<td>
|
||||
<button type="button" class="btn btn-ghost btn-sm"
|
||||
data-id="{{ p.id }}"
|
||||
data-code="{{ p.code }}"
|
||||
data-desc="{{ p.description }}"
|
||||
data-weight="{{ p.default_net_weight }}"
|
||||
onclick="editProduct(this)"
|
||||
data-i18n="edit">Edit</button>
|
||||
<button type="button" class="btn btn-ghost btn-sm btn-danger"
|
||||
onclick="deleteProduct({{ p.id }})"
|
||||
data-i18n="remove">Remove</button>
|
||||
</td>
|
||||
</tr>
|
||||
{% empty %}
|
||||
<tr><td colspan="4" class="empty-state" data-i18n="no_products">No products yet</td></tr>
|
||||
{% endfor %}
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</section>
|
||||
</div>
|
||||
|
||||
<div id="toast" class="toast"></div>
|
||||
{% endblock %}
|
||||
|
||||
{% block extra_scripts %}
|
||||
<script src="{% static 'slips/js/products.js' %}"></script>
|
||||
{% endblock %}
|
||||
Reference in New Issue
Block a user