Tighten Recent Orders table layout and labels UI

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-10-24 13:36:26 +03:30
parent def96d1f0a
commit b5e91f3dde
4 changed files with 158 additions and 52 deletions

View File

@@ -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); }

View File

@@ -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';