feat(mobile): show estimate + ½kg price per item on phones
The estimate column is hidden on phones, so add a small 'est X kr · ½kg Y kr' line under each item name, shown only on mobile. The ½kg (per-500g) price is computed for weight items (line price ÷ kg × 0.5). The est column (desktop) and this line now show the *computed* per-row price (offer price × quantity, or quantity-scaled estimate), so each row matches what the total adds up.
This commit is contained in:
@@ -71,6 +71,7 @@
|
|||||||
.item-name { padding: 0.7rem 0.5rem; font-size: 14px; }
|
.item-name { padding: 0.7rem 0.5rem; font-size: 14px; }
|
||||||
.item-name .note { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
|
.item-name .note { font-size: 11px; color: var(--muted); display: block; margin-top: 1px; }
|
||||||
.item-name .de { font-size: 10px; color: #b0aba3; display: block; margin-top: 0; font-style: italic; }
|
.item-name .de { font-size: 10px; color: #b0aba3; display: block; margin-top: 0; font-style: italic; }
|
||||||
|
.item-name .row-est-m { display: none; font-size: 10px; color: var(--muted); font-family: var(--mono); margin-top: 2px; }
|
||||||
.badge { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-left: 5px; vertical-align: middle; font-weight: 500; }
|
.badge { display: inline-block; font-size: 9px; padding: 1px 5px; border-radius: 3px; margin-left: 5px; vertical-align: middle; font-weight: 500; }
|
||||||
.badge-card { background: var(--blue-light); color: var(--blue); }
|
.badge-card { background: var(--blue-light); color: var(--blue); }
|
||||||
.badge-kasse { background: var(--amber-light); color: var(--amber); }
|
.badge-kasse { background: var(--amber-light); color: var(--amber); }
|
||||||
@@ -169,6 +170,7 @@
|
|||||||
.header-actions { flex-direction: row; align-items: center; }
|
.header-actions { flex-direction: row; align-items: center; }
|
||||||
.item-row { grid-template-columns: 28px 1fr 64px 78px; }
|
.item-row { grid-template-columns: 28px 1fr 64px 78px; }
|
||||||
.item-est { display: none; }
|
.item-est { display: none; }
|
||||||
|
.item-name .row-est-m { display: block; }
|
||||||
.col-headers { grid-template-columns: 28px 1fr 64px 78px; }
|
.col-headers { grid-template-columns: 28px 1fr 64px 78px; }
|
||||||
.col-h:nth-child(4) { display: none; }
|
.col-h:nth-child(4) { display: none; }
|
||||||
.extra-item-row { grid-template-columns: 28px 1fr auto auto; }
|
.extra-item-row { grid-template-columns: 28px 1fr auto auto; }
|
||||||
@@ -266,6 +268,7 @@
|
|||||||
{% if item.get('note') %}<span class="note">{{ item.note }}</span>{% endif %}
|
{% if item.get('note') %}<span class="note">{{ item.note }}</span>{% endif %}
|
||||||
{% set d = deals.get(item.key) %}
|
{% set d = deals.get(item.key) %}
|
||||||
{% if d %}<a class="deal" href="/tilbud" title="{{ d.heading }} ({{ d.catalog }})">🏷 på tilbud: {{ "{:.2f}".format(d.price_eur).replace(".",",") }} € ≈ {{ "{:.0f}".format(d.price_eur * eur_dkk) }} kr. · {{ d.heading_da or d.heading }}</a>{% endif %}
|
{% if d %}<a class="deal" href="/tilbud" title="{{ d.heading }} ({{ d.catalog }})">🏷 på tilbud: {{ "{:.2f}".format(d.price_eur).replace(".",",") }} € ≈ {{ "{:.0f}".format(d.price_eur * eur_dkk) }} kr. · {{ d.heading_da or d.heading }}</a>{% endif %}
|
||||||
|
<span class="row-est-m"></span>
|
||||||
</div>
|
</div>
|
||||||
<div class="item-qty">
|
<div class="item-qty">
|
||||||
<input type="text" value="{{ s.get('qty') or item.qty }}" placeholder="{{ item.qty }}"
|
<input type="text" value="{{ s.get('qty') or item.qty }}" placeholder="{{ item.qty }}"
|
||||||
@@ -709,16 +712,34 @@ function recalcAll() {
|
|||||||
// picked offers), live from each row's data-est. Reflects add/remove/pick.
|
// picked offers), live from each row's data-est. Reflects add/remove/pick.
|
||||||
let est = 0;
|
let est = 0;
|
||||||
document.querySelectorAll('[data-est]').forEach(r => {
|
document.querySelectorAll('[data-est]').forEach(r => {
|
||||||
|
const qi = r.querySelector('.item-qty input');
|
||||||
const offer = offerLineDkk(r); // real offer price if matched
|
const offer = offerLineDkk(r); // real offer price if matched
|
||||||
if (offer != null) { est += offer; return; }
|
let line;
|
||||||
let base = parseFloat(r.dataset.est) || 0;
|
if (offer != null) {
|
||||||
const qi = r.querySelector('.item-qty input'); // scale estimate with quantity
|
line = offer;
|
||||||
if (qi) {
|
} else {
|
||||||
|
line = parseFloat(r.dataset.est) || 0;
|
||||||
|
if (qi) { // scale estimate with quantity
|
||||||
const cur = qtyNum(qi.value.trim() || qi.placeholder);
|
const cur = qtyNum(qi.value.trim() || qi.placeholder);
|
||||||
const def = qtyNum(qi.placeholder);
|
const def = qtyNum(qi.placeholder);
|
||||||
if (cur != null && def != null && def > 0) base = base * (cur / def);
|
if (cur != null && def != null && def > 0) line = line * (cur / def);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
est += line;
|
||||||
|
|
||||||
|
// Per-row display: computed estimate + ½kg price (for weight items). The
|
||||||
|
// est column is hidden on phones, so also fill the mobile sub-line.
|
||||||
|
if (qi) {
|
||||||
|
const col = r.querySelector('.item-est');
|
||||||
|
if (col) col.textContent = line > 0 ? Math.round(line).toLocaleString('da-DK') : '—';
|
||||||
|
const sub = r.querySelector('.row-est-m');
|
||||||
|
if (sub) {
|
||||||
|
const kg = qtyToKg(qi.value.trim() || qi.placeholder);
|
||||||
|
const per500 = (kg > 0 && line > 0) ? Math.round(line / kg * 0.5) : null;
|
||||||
|
sub.textContent = (line > 0 ? 'est ' + Math.round(line).toLocaleString('da-DK') + ' kr' : '')
|
||||||
|
+ (per500 ? ' · ½kg ' + per500 + ' kr' : '');
|
||||||
|
}
|
||||||
}
|
}
|
||||||
est += base;
|
|
||||||
});
|
});
|
||||||
document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';
|
document.getElementById('stat-est').textContent = est > 0 ? Math.round(est).toLocaleString('da-DK') : '—';
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user