several fixes to payment applet styling & script
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful

This commit is contained in:
Disco DeDisco
2026-03-24 14:13:44 -04:00
parent f347af7eff
commit 18898c7a0f
3 changed files with 44 additions and 28 deletions

View File

@@ -21,27 +21,7 @@ const initWallet = () => {
saveBtn.hidden = false;
cancelBtn.hidden = false;
const section = addBtn.closest('section');
const rowPx = 3 * parseFloat(getComputedStyle(document.documentElement).fontSize);
const updateRows = () => {
const sectionTop = section.getBoundingClientRect().top;
let maxBottom = sectionTop;
for (const child of section.children) {
if (child.hidden) continue;
maxBottom = Math.max(maxBottom, child.getBoundingClientRect().bottom);
}
const padBot = parseFloat(getComputedStyle(section).paddingBottom);
const rows = Math.ceil((maxBottom - sectionTop + padBot) / rowPx) + 1;
section.style.setProperty('--applet-rows', String(rows));
};
paymentEl.on('ready', () => {
updateRows();
const stripeContainer = document.getElementById('id_stripe_payment_element');
if (stripeContainer) {
const obs = new ResizeObserver(updateRows);
obs.observe(stripeContainer);
section._stripeObs = obs;
}
});
section.style.setProperty('--applet-rows', '15');
});
saveBtn.addEventListener('click', async () => {
@@ -68,8 +48,7 @@ const initWallet = () => {
saveBtn.hidden = true;
cancelBtn.hidden = true;
const section = cancelBtn.closest('section');
section.style.setProperty('--applet-rows', '2');
if (section._stripeObs) { section._stripeObs.disconnect(); section._stripeObs = null; }
section.style.setProperty('--applet-rows', '3');
});
cancelBtn.addEventListener('click', () => {
@@ -81,8 +60,7 @@ const initWallet = () => {
saveBtn.hidden = true;
cancelBtn.hidden = true;
const section = cancelBtn.closest('section');
section.style.setProperty('--applet-rows', '2');
if (section._stripeObs) { section._stripeObs.disconnect(); section._stripeObs = null; }
section.style.setProperty('--applet-rows', '3');
});
};

View File

@@ -61,7 +61,7 @@ class WalletViewAppletContextTest(TestCase):
)
Applet.objects.get_or_create(
slug="wallet-payment",
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 2, "context": "wallet"},
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 3, "context": "wallet"},
)
self.client.force_login(self.user)
@@ -96,7 +96,7 @@ class ToggleWalletAppletsTest(TestCase):
)[0]
Applet.objects.get_or_create(
slug="wallet-payment",
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 2, "context": "wallet"},
defaults={"name": "Payment Methods", "grid_cols": 6, "grid_rows": 3, "context": "wallet"},
)
self.client.force_login(self.user)