feat(go): M6.6.1 — QR payment popup modal on /adults and /juniors
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
All checks were successful
Deploy to K8s / deploy (push) Successful in 9s
Replace bare <a href=/qr> Pay buttons with <button data-*> elements that open an in-page #qrModal (matching Python's showPayQR UX), driven by a new payment-qr.js vanilla-JS IIFE module. Remove the now-dead qrHref / qrHrefAll template helpers from render.go. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -442,6 +442,23 @@ tr:hover {
|
||||
}
|
||||
|
||||
/* QR Modal styles */
|
||||
#qrModal {
|
||||
display: none !important;
|
||||
position: fixed;
|
||||
top: 0;
|
||||
left: 0;
|
||||
width: 100vw;
|
||||
height: 100vh;
|
||||
background-color: rgba(0, 0, 0, 0.9);
|
||||
z-index: 9999;
|
||||
justify-content: center;
|
||||
align-items: center;
|
||||
}
|
||||
|
||||
#qrModal.active {
|
||||
display: flex !important;
|
||||
}
|
||||
|
||||
#qrModal .modal-content {
|
||||
max-width: 400px;
|
||||
text-align: center;
|
||||
|
||||
60
go/internal/web/static/js/payment-qr.js
Normal file
60
go/internal/web/static/js/payment-qr.js
Normal file
@@ -0,0 +1,60 @@
|
||||
(function () {
|
||||
'use strict';
|
||||
|
||||
const container = document.getElementById('filterContainer');
|
||||
if (!container) return;
|
||||
const bankAccount = container.dataset.bankAccount || '';
|
||||
|
||||
const modal = document.getElementById('qrModal');
|
||||
const titleEl = document.getElementById('qrTitle');
|
||||
const imgEl = document.getElementById('qrImg');
|
||||
const accountEl = document.getElementById('qrAccount');
|
||||
const amountEl = document.getElementById('qrAmount');
|
||||
const messageEl = document.getElementById('qrMessage');
|
||||
if (!modal || !titleEl || !imgEl || !accountEl || !amountEl || !messageEl) return;
|
||||
|
||||
// Convert "YYYY-MM" → "MM/YYYY"; "+"-joined ranges converted piece-wise.
|
||||
// Mirrors templates/adults.html showPayQR logic.
|
||||
function toCzechMonth(rawMonth) {
|
||||
return rawMonth.split('+')
|
||||
.map(function (p) { return p.replace(/^(\d{4})-(\d{2})$/, '$2/$1'); })
|
||||
.join('+');
|
||||
}
|
||||
|
||||
function showQR(name, amount, month, rawMonth) {
|
||||
var numericMonth = toCzechMonth(rawMonth);
|
||||
var message = name + ': ' + numericMonth;
|
||||
|
||||
titleEl.innerText = 'Payment for ' + month;
|
||||
accountEl.innerText = bankAccount;
|
||||
amountEl.innerText = amount;
|
||||
messageEl.innerText = message;
|
||||
|
||||
imgEl.src = '/qr?'
|
||||
+ 'account=' + encodeURIComponent(bankAccount)
|
||||
+ '&amount=' + encodeURIComponent(amount)
|
||||
+ '&message=' + encodeURIComponent(message);
|
||||
|
||||
modal.classList.add('active');
|
||||
}
|
||||
|
||||
function closeQR() {
|
||||
modal.classList.remove('active');
|
||||
}
|
||||
|
||||
document.addEventListener('click', function (ev) {
|
||||
var btn = ev.target.closest('.pay-btn');
|
||||
if (!btn) return;
|
||||
ev.preventDefault();
|
||||
showQR(
|
||||
btn.dataset.name,
|
||||
btn.dataset.amount,
|
||||
btn.dataset.month,
|
||||
btn.dataset.rawMonth
|
||||
);
|
||||
});
|
||||
|
||||
document.addEventListener('keydown', function (e) {
|
||||
if (e.key === 'Escape' && modal.classList.contains('active')) closeQR();
|
||||
});
|
||||
}());
|
||||
Reference in New Issue
Block a user