Merge pull request 'worktree-citti-arkiver-tur' (#11) from worktree-citti-arkiver-tur into main
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 49s
All checks were successful
Build and Deploy citti / build-and-deploy (push) Successful in 49s
Reviewed-on: #11
This commit was merged in pull request #11.
This commit is contained in:
@@ -78,7 +78,7 @@
|
||||
.item-qty { padding: 0.35rem 0.4rem; }
|
||||
.item-qty input { width: 100%; border: 1px solid var(--border); border-radius: 5px; padding: 6px 5px; font-size: 11px; font-family: var(--mono); background: var(--bg); color: var(--muted); text-align: center; outline: none; transition: border-color 0.15s, background 0.15s; cursor: text; min-height: 32px; }
|
||||
.item-qty input:focus { border-color: var(--accent); background: white; color: var(--text); }
|
||||
.item-qty input.modified { color: var(--accent); font-weight: 500; border-color: #f0b8ab; background: var(--accent-light); }
|
||||
.item-qty input.modified { color: var(--green); font-weight: 500; border-color: #a8d5bc; background: var(--green-light); }
|
||||
.item-est { padding: 0.7rem 0.5rem; font-size: 12px; font-family: var(--mono); color: var(--muted); text-align: right; }
|
||||
.item-actual { padding: 0.45rem 0.75rem 0.45rem 0.5rem; }
|
||||
.item-actual input { width: 100%; border: 1px solid var(--border); border-radius: 6px; padding: 5px 8px; font-size: 13px; font-family: var(--mono); background: var(--bg); color: var(--text); text-align: right; outline: none; transition: border-color 0.15s, background 0.15s; }
|
||||
@@ -617,7 +617,7 @@ function updateQty(input) {
|
||||
input.classList.toggle('modified', input.value.trim() !== '' && input.value.trim() !== defaultQty);
|
||||
const price = parseFloat(row.querySelector('.item-actual input').value);
|
||||
const checked = row.querySelector('input[type=checkbox]').checked ? 1 : 0;
|
||||
computeMeals(); // meat portions / dinner days react to qty
|
||||
recalcAll(); // meal stats + estimate (offer prices) react to qty
|
||||
clearTimeout(debounceTimers[key + '_qty']);
|
||||
debounceTimers[key + '_qty'] = setTimeout(() => saveToServer(key, isNaN(price) ? null : price, checked), 600);
|
||||
}
|
||||
@@ -642,6 +642,12 @@ function qtyToPacks(s) {
|
||||
const m = (s || '').match(/([\d.]+)\s*stk/i);
|
||||
return m ? parseFloat(m[1]) : 0;
|
||||
}
|
||||
// Leading number of a quantity string ("6 × ½ kg" -> 6, "8 dåser" -> 8), used to
|
||||
// scale a fixed line estimate when the quantity changes.
|
||||
function qtyNum(s) {
|
||||
const m = (s || '').replace(',', '.').replace(/~/g, '').replace(/½/g, '0.5').match(/([\d.]+)/);
|
||||
return m ? parseFloat(m[1]) : null;
|
||||
}
|
||||
function curQty(row) {
|
||||
const inp = row.querySelector('.item-qty input');
|
||||
return inp ? (inp.value.trim() || inp.placeholder) : '';
|
||||
@@ -702,7 +708,15 @@ function recalcAll() {
|
||||
let est = 0;
|
||||
document.querySelectorAll('[data-est]').forEach(r => {
|
||||
const offer = offerLineDkk(r); // real offer price if matched
|
||||
est += (offer != null) ? offer : (parseFloat(r.dataset.est) || 0);
|
||||
if (offer != null) { est += offer; return; }
|
||||
let base = parseFloat(r.dataset.est) || 0;
|
||||
const qi = r.querySelector('.item-qty input'); // scale estimate with quantity
|
||||
if (qi) {
|
||||
const cur = qtyNum(qi.value.trim() || qi.placeholder);
|
||||
const def = qtyNum(qi.placeholder);
|
||||
if (cur != null && def != null && def > 0) base = base * (cur / def);
|
||||
}
|
||||
est += base;
|
||||
});
|
||||
document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';
|
||||
|
||||
|
||||
Reference in New Issue
Block a user