From d1442587bc3e6a036f7fd3f2659d9fb7b507519c Mon Sep 17 00:00:00 2001 From: NoeBerdoz Date: Thu, 22 Aug 2024 16:13:43 +0200 Subject: [PATCH] pre-commit --- .../static/src/js/website_widgets.js | 110 +++++++++--------- .../templates/project_donation_page.xml | 2 +- 2 files changed, 57 insertions(+), 55 deletions(-) diff --git a/crowdfunding_compassion/static/src/js/website_widgets.js b/crowdfunding_compassion/static/src/js/website_widgets.js index feaddfe..9711b15 100644 --- a/crowdfunding_compassion/static/src/js/website_widgets.js +++ b/crowdfunding_compassion/static/src/js/website_widgets.js @@ -35,62 +35,64 @@ odoo.define("crowdfunding_compassion.website_widgets", function (require) { // Handle donation card selection publicWidget.registry.CustomAmountSelection = publicWidget.Widget.extend({ - selector: '#custom-amount-card', - events: { - 'click': '_checkCustomCard', - }, - - start: function () { - this._super.apply(this, arguments); - // Attach click event listener to all card options except custom amount card - const otherCardsInputs = document.querySelectorAll('input[name="amount"]:not(#custom-amount-card)'); - otherCardsInputs.forEach(card => { - card.addEventListener('click', this._onCardClick.bind(this)); - }); - - // Attach input event listener to custom-amount-field - const customAmountField = document.getElementById('custom-amount-field'); - customAmountField.addEventListener('input', this._onInput.bind(this)); - }, - - // Check the custom amount card when custom amount field changes - _onInput: function () { - const customAmountField = document.getElementById('custom-amount-field'); - - if (customAmountField) { - const amount = customAmountField.value.trim(); - const isAmountNotEmpty = amount !== ''; - - if (isAmountNotEmpty) { - this._checkCustomCard(); - } - } - }, - - // Check the custom amount card and uncheck the others - _checkCustomCard: function (event) { - const customAmountCard = document.getElementById('custom-amount-card'); - const otherCardsInputs = document.querySelectorAll('input[name="amount"]:not(#custom-amount-card):not(#custom-amount-field)'); - - if (customAmountCard && otherCardsInputs) { - - customAmountCard.checked = true; - - otherCardsInputs.forEach(input => { - input.checked = false; - }); - } - }, - - // Uncheck the custom amount card when any other card option is clicked - _onCardClick: function (event) { - const customAmountCard = document.getElementById('custom-amount-card'); - if (customAmountCard) { - customAmountCard.checked = false; - } + selector: "#custom-amount-card", + events: { + click: "_checkCustomCard", + }, + + start: function () { + this._super.apply(this, arguments); + // Attach click event listener to all card options except custom amount card + const otherCardsInputs = document.querySelectorAll( + 'input[name="amount"]:not(#custom-amount-card)' + ); + otherCardsInputs.forEach((card) => { + card.addEventListener("click", this._onCardClick.bind(this)); + }); + + // Attach input event listener to custom-amount-field + const customAmountField = document.getElementById("custom-amount-field"); + customAmountField.addEventListener("input", this._onInput.bind(this)); + }, + + // Check the custom amount card when custom amount field changes + _onInput: function () { + const customAmountField = document.getElementById("custom-amount-field"); + + if (customAmountField) { + const amount = customAmountField.value.trim(); + const isAmountNotEmpty = amount !== ""; + + if (isAmountNotEmpty) { + this._checkCustomCard(); } + } + }, + + // Check the custom amount card and uncheck the others + _checkCustomCard: function (event) { + const customAmountCard = document.getElementById("custom-amount-card"); + const otherCardsInputs = document.querySelectorAll( + 'input[name="amount"]:not(#custom-amount-card):not(#custom-amount-field)' + ); + + if (customAmountCard && otherCardsInputs) { + customAmountCard.checked = true; - }); + otherCardsInputs.forEach((input) => { + input.checked = false; + }); + } + }, + + // Uncheck the custom amount card when any other card option is clicked + _onCardClick: function (event) { + const customAmountCard = document.getElementById("custom-amount-card"); + if (customAmountCard) { + customAmountCard.checked = false; + } + }, + }); // EDIT PROJECT FORM publicWidget.registry.EditProjectForm = publicWidget.Widget.extend({ diff --git a/crowdfunding_compassion/templates/project_donation_page.xml b/crowdfunding_compassion/templates/project_donation_page.xml index 4768e6c..3aa8c46 100644 --- a/crowdfunding_compassion/templates/project_donation_page.xml +++ b/crowdfunding_compassion/templates/project_donation_page.xml @@ -430,7 +430,7 @@ name="amount" t-att-value="amount" min="1" - /> + />

CHF