Files
openfoodnetwork/app/webpacker/controllers/paymentmethod_controller.js
Jean-Baptiste Bellet 3063b041d1 Change the paymentmethod controller to handle both desc and form
Add tests as well

Update _payment.html.haml

Update _payment.html.haml
2021-12-07 16:23:39 +00:00

26 lines
604 B
JavaScript

import { Controller } from "stimulus";
export default class extends Controller {
static targets = ["paymentMethod"];
connect() {
this.hideAll();
}
selectPaymentMethod(event) {
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";
});
}
}