feat(tilbud): 'Gå til seddel' button showing how many offers are selected
Ticking an offer already adds it to the shopping list instantly (it shows in the Lübeck-tilbud section), but that wasn't visible. Add a fixed 'N valgt · Gå til seddel' button that appears once anything is selected, so the link between the checklist and the list is obvious and you can jump straight to it.
This commit is contained in:
@@ -117,14 +117,27 @@
|
||||
{% endfor %}
|
||||
|
||||
</div>
|
||||
|
||||
<a class="golist" id="golist" href="/"
|
||||
style="display:none;position:fixed;right:14px;bottom:14px;z-index:9999;padding:11px 18px;border-radius:24px;background:#2d6a4f;color:#fff;text-decoration:none;font:600 14px/1 var(--sans);box-shadow:0 3px 12px rgba(0,0,0,.28)">🛒 <b id="golist-n">0</b> valgt · Gå til seddel →</a>
|
||||
|
||||
<script>
|
||||
let pickCount = {{ picked_count }};
|
||||
|
||||
// Picking is instant — a tick adds the offer to the shopping list right away
|
||||
// (it shows in the "Lübeck-tilbud" section there). This just mirrors the count
|
||||
// and the "go to list" button.
|
||||
function updatePick() {
|
||||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
||||
document.getElementById('golist-n').textContent = pickCount;
|
||||
document.getElementById('golist').style.display = pickCount > 0 ? 'block' : 'none';
|
||||
}
|
||||
|
||||
async function togglePick(cb, id) {
|
||||
const picked = cb.checked;
|
||||
cb.closest('.offer').classList.toggle('picked', picked);
|
||||
pickCount += picked ? 1 : -1;
|
||||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
||||
updatePick();
|
||||
try {
|
||||
await (window.cittiFetch || fetch)('/api/offers/pick', {
|
||||
method: 'POST',
|
||||
@@ -135,7 +148,7 @@ async function togglePick(cb, id) {
|
||||
cb.checked = !picked;
|
||||
cb.closest('.offer').classList.toggle('picked', !picked);
|
||||
pickCount += picked ? -1 : 1;
|
||||
document.getElementById('pick-count').textContent = pickCount + ' på seddel';
|
||||
updatePick();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -166,6 +179,8 @@ async function refreshOffers() {
|
||||
btn.textContent = '⟳ Opdater'; btn.disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
updatePick();
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user