From 8ff5dd51a33fa19d109fb333c73dc95006197483 Mon Sep 17 00:00:00 2001 From: Nathaniel Hammond Date: Fri, 13 Oct 2023 14:25:18 +0100 Subject: [PATCH] Remove JS noise from address primary settings --- .../dist/shop/_private/address/fields.twig | 20 ++++-------------- .../src/shop/_private/address/fields.twig | 21 ++++--------------- 2 files changed, 8 insertions(+), 33 deletions(-) diff --git a/example-templates/dist/shop/_private/address/fields.twig b/example-templates/dist/shop/_private/address/fields.twig index 77bfb0a8db..e0fa3299c4 100644 --- a/example-templates/dist/shop/_private/address/fields.twig +++ b/example-templates/dist/shop/_private/address/fields.twig @@ -198,29 +198,17 @@ Outputs address form fields for editing an address. {% if showPrimaryCheckboxes %}
- {{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }} - + {{ hiddenInput('isPrimaryBilling', 0) }} +
- {{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }} - + {{ hiddenInput('isPrimaryShipping', 0) }} +
{% endif %} {% js %} -{% if showPrimaryCheckboxes %} -document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => { - el.addEventListener('change', ev => { - let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`); - if (ev.target.checked) { - primaryInput.value = 1; - } else { - primaryInput.value = 0; - } - }); -}); -{% endif %} document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => { const countryCode = ev.target.value; diff --git a/example-templates/src/shop/_private/address/fields.twig b/example-templates/src/shop/_private/address/fields.twig index 6fa6ebf00b..2af88ecfa4 100755 --- a/example-templates/src/shop/_private/address/fields.twig +++ b/example-templates/src/shop/_private/address/fields.twig @@ -198,30 +198,17 @@ Outputs address form fields for editing an address. {% if showPrimaryCheckboxes %}
- {{ input('hidden', 'isPrimaryBilling', address.isPrimarybilling ? 1 : 0) }} - + {{ hiddenInput('isPrimaryBilling', 0) }} +
- {{ input('hidden', 'isPrimaryShipping', address.isPrimaryShipping ? 1 : 0) }} - + {{ hiddenInput('isPrimaryShipping', 0) }} +
{% endif %} {% js %} -{% if showPrimaryCheckboxes %} -document.querySelectorAll('input[type=checkbox][data-primary-input]').forEach(el => { - el.addEventListener('change', ev => { - let primaryInput = document.querySelector(`input[name="${ev.target.dataset.primaryInput}"]`); - if (ev.target.checked) { - primaryInput.value = 1; - } else { - primaryInput.value = 0; - } - }); -}); -{% endif %} - document.querySelector('select#{{ 'countryCode'|namespaceInputId(addressName) }}').addEventListener('change', ev => { const countryCode = ev.target.value; const stateSelect = document.querySelector('select#{{ 'administrativeArea'|namespaceInputId(addressName) }}');