mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-03-11 03:40:20 +00:00
Change the paymentmethod controller to handle both desc and form
Add tests as well Update _payment.html.haml Update _payment.html.haml
This commit is contained in:
committed by
Matt-Yorkley
parent
53d01b1275
commit
3063b041d1
@@ -1,9 +1,25 @@
|
||||
import { Controller } from "stimulus";
|
||||
export default class extends Controller {
|
||||
static targets = ["panel"];
|
||||
static targets = ["paymentMethod"];
|
||||
|
||||
connect() {
|
||||
this.hideAll();
|
||||
}
|
||||
|
||||
selectPaymentMethod(event) {
|
||||
this.panelTarget.innerHTML = `<span>${event.target.dataset.paymentmethodDescription}</span>`;
|
||||
this.panelTarget.style.display = "block";
|
||||
this.hideAll();
|
||||
const paymentMethodContainerId = event.target.dataset.paymentmethodId;
|
||||
const paymentMethodContainer = document.getElementById(
|
||||
paymentMethodContainerId
|
||||
);
|
||||
paymentMethodContainer.style.display = "block";
|
||||
}
|
||||
|
||||
hideAll() {
|
||||
Array.from(
|
||||
document.getElementsByClassName("paymentmethod-container")
|
||||
).forEach((e) => {
|
||||
e.style.display = "none";
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user