diff --git a/slips/models.py b/slips/models.py index 4edc328..c004ec2 100644 --- a/slips/models.py +++ b/slips/models.py @@ -55,6 +55,10 @@ class Order(models.Model): def custom_count(self): return sum(int(line['count']) for line in (self.custom_labels or [])) + @property + def box_weight(self): + return self.canister_weight * self.canisters_per_box + def apply_weight(self): """Derive canister/box counts from total_weight (create path).""" self.canister_count = math.ceil(self.total_weight / self.canister_weight) diff --git a/slips/static/slips/css/style.css b/slips/static/slips/css/style.css index 6691d1a..913981c 100644 --- a/slips/static/slips/css/style.css +++ b/slips/static/slips/css/style.css @@ -513,15 +513,93 @@ input:focus, select:focus { overflow-x: auto; } +.table-wrap-capped { + max-height: calc(100dvh - 10rem); + overflow: auto; +} + +/* Keep td as table-cell so width:1% shrinks the column; flex lives inside. */ +.labels-cell { + width: 1%; +} + +.label-counts { + display: inline-flex; + flex-direction: column; + align-items: stretch; + gap: 0.35rem; + vertical-align: middle; +} + +.label-counts > .count-stepper, +.label-counts > .mono, +.label-counts > [id^="custom-"], +.label-counts .custom-label-list, +.label-counts .custom-label-list .count-stepper, +.label-counts .custom-label-list .mono { + width: 100%; + box-sizing: border-box; +} + +.label-counts > [id^="custom-"]:empty { + display: none; +} + +.label-counts > [id^="custom-"], +.label-counts .custom-label-list { + display: flex; + flex-direction: column; + align-items: stretch; + gap: 0.35rem; +} + +.label-counts .count-stepper { + display: grid; + grid-template-columns: minmax(max-content, 1fr) 1.5rem 2.25rem 1.5rem; + align-items: center; + justify-items: center; + gap: 0.35rem; +} + +.label-counts .count-stepper .stepper-label { + justify-self: start; + margin-inline-start: 0; + white-space: nowrap; +} + +.status-cell { + white-space: nowrap; +} + +.status-cell .badge + .badge, +.status-cell .badge + button.badge { + margin-inline-start: 0.35rem; +} + +button.badge { + cursor: pointer; + font: inherit; + font-size: 0.75rem; + font-weight: 600; + text-transform: uppercase; + letter-spacing: 0.05em; +} + +button.badge:hover { + filter: brightness(0.92); +} + .data-table { width: 100%; border-collapse: collapse; - text-align: left; + text-align: start; } .data-table th, .data-table td { padding: 0.85rem 1rem; border-bottom: 1px solid var(--border); + text-align: start; + vertical-align: middle; } @media (min-width: 1400px) { @@ -565,7 +643,7 @@ input:focus, select:focus { letter-spacing: 0.05em; } -.badge-pending { background: rgba(245, 158, 11, 0.1); color: var(--warning); border: 1px solid rgba(245, 158, 11, 0.2); } +.badge-pending { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); } .badge-done { background: rgba(16, 185, 129, 0.1); color: var(--success); border: 1px solid rgba(16, 185, 129, 0.2); } .badge-cancelled { background: rgba(239, 68, 68, 0.1); color: var(--danger); border: 1px solid rgba(239, 68, 68, 0.2); } .badge-accent { background: var(--accent-soft); color: var(--brand-hover); border: 1px solid color-mix(in srgb, var(--accent) 30%, transparent); } diff --git a/slips/static/slips/js/i18n.js b/slips/static/slips/js/i18n.js index d477a16..f4e7ca6 100644 --- a/slips/static/slips/js/i18n.js +++ b/slips/static/slips/js/i18n.js @@ -32,6 +32,7 @@ const translations = { 'boxes': 'Boxes', 'canisters_unit': 'Canisters', 'boxes_unit': 'Boxes', + 'labels': 'Labels', 'custom': 'Custom', 'custom_unit': 'Custom', 'custom_labels': 'Custom Labels', @@ -41,6 +42,9 @@ const translations = { 'pages_needed': 'Pages Needed', 'total_pages': 'Pages', 'status_pending': 'Pending', + 'status_done': 'Done', + 'status_printing': 'Printing', + 'status_cancelled': 'Cancelled', 'add_to_queue': 'Add to Print Queue', 'recent_orders': 'Recent Orders', 'status': 'Status', @@ -87,6 +91,7 @@ const translations = { 'boxes': 'تعداد کارتن', 'canisters_unit': 'گالن', 'boxes_unit': 'کارتن', + 'labels': 'برچسبها', 'custom': 'سفارشی', 'custom_unit': 'سفارشی', 'custom_labels': 'برچسب سفارشی', @@ -96,6 +101,9 @@ const translations = { 'pages_needed': 'تعداد صفحات', 'total_pages': 'صفحات', 'status_pending': 'در انتظار', + 'status_done': 'انجام شد', + 'status_printing': 'در حال چاپ', + 'status_cancelled': 'لغو شده', 'add_to_queue': 'افزودن به صف چاپ', 'recent_orders': 'سفارشات اخیر', 'status': 'وضعیت', @@ -146,6 +154,15 @@ function applyLanguage(lang) { } }); + document.querySelectorAll('[data-i18n-title]').forEach(el => { + const key = el.getAttribute('data-i18n-title'); + if (translations[lang][key]) el.title = translations[lang][key]; + }); + document.querySelectorAll('[data-i18n-aria]').forEach(el => { + const key = el.getAttribute('data-i18n-aria'); + if (translations[lang][key]) el.setAttribute('aria-label', translations[lang][key]); + }); + // Button shows the language you can switch to const toggleBtn = document.getElementById('lang-label'); if (toggleBtn) { @@ -218,12 +235,18 @@ async function adjustCount(id, field, delta) { } } +function formatWeight(w) { + const n = Number(w); + if (!Number.isFinite(n)) return String(w); + return Number.isInteger(n) ? String(n) : String(parseFloat(n.toFixed(6))); +} + function renderCustomLabels(id, labels, pending) { const cell = document.getElementById(`custom-${id}`); if (!cell) return; const lines = (labels || []).filter((line) => line && Number(line.count) > 0); if (!lines.length) { - cell.textContent = '—'; + cell.replaceChildren(); return; } const list = document.createElement('div'); @@ -231,16 +254,17 @@ function renderCustomLabels(id, labels, pending) { lines.forEach((line, i) => { const weight = Number(line.weight); const count = Number(line.count); + const weightLabel = formatWeight(weight); const row = document.createElement('div'); if (!pending) { row.className = 'mono'; - row.textContent = `${weight} kg × ${count}`; + row.textContent = `${weightLabel} kg × ${count}`; } else { row.className = 'count-stepper'; row.dataset.weight = String(weight); const label = document.createElement('span'); label.className = 'stepper-label'; - label.textContent = `${weight} kg`; + label.textContent = `${weightLabel} kg`; const down = document.createElement('button'); down.type = 'button'; down.className = 'stepper-btn'; diff --git a/slips/templates/slips/entry.html b/slips/templates/slips/entry.html index aff823c..831134e 100644 --- a/slips/templates/slips/entry.html +++ b/slips/templates/slips/entry.html @@ -82,19 +82,16 @@
| # | Product | Batch | -Canisters | -Boxes | -Custom | +Labels | Pages | Status | -{{ o.id }} | {{ o.product.code }} | {{ o.batch_number }} | -
- {% if o.status == 'pending' %}
-
-
- {{ o.canister_count }}
-
-
- {% else %}
- {{ o.canister_count }}
- {% endif %}
- |
-
- {% if o.status == 'pending' %}
-
-
- {{ o.box_count }}
-
-
- {% else %}
- {{ o.box_count }}
- {% endif %}
- |
-
- {% if o.custom_labels %}
-
+
+ |
{% if o.status == 'pending' %}
- {% for line in o.custom_labels %}
-
- {{ line.weight }} kg
-
- {{ line.count }}
-
+
- {% else %}
- —
- {% endif %}
+ {{ o.canister_weight|floatformat:-2 }} kg
+
+ {{ o.canister_count }}
+
+
+
+ {{ o.box_weight|floatformat:-2 }} kg
+
+ {{ o.box_count }}
+
- {% endfor %}
{% else %}
- {% for line in o.custom_labels %}
- {{ line.weight }} kg × {{ line.count }}
- {% endfor %}
+ {{ o.canister_weight|floatformat:-2 }} kg × {{ o.canister_count }}
+ {{ o.box_weight|floatformat:-2 }} kg × {{ o.box_count }}
{% endif %}
+
+ {% if o.custom_labels %}
+
+ {% if o.status == 'pending' %}
+ {% for line in o.custom_labels %}
+
+ {% endif %}
+
+ {{ line.weight|floatformat:-2 }} kg
+
+ {{ line.count }}
+
+
+ {% endfor %}
+ {% else %}
+ {% for line in o.custom_labels %}
+ {{ line.weight|floatformat:-2 }} kg × {{ line.count }}
+ {% endfor %}
+ {% endif %}
+ {{ o.canister_pages|add:o.box_pages }} |
- {{ o.get_status_display }} |
-
+ |
{% if o.status == 'pending' %}
-
+ ⏳ Pending
+
+ {% elif o.status == 'done' %}
+ ✓ Done
+ {% elif o.status == 'printing' %}
+ 🖨 Printing
+ {% else %}
+ ✕ Cancelled
{% endif %}
|
{% empty %}
- No orders yet | No orders yet | |
|---|---|---|---|---|---|---|---|---|---|