From 04e4cc0cc651f56a5c573f3d3f103446c99def37 Mon Sep 17 00:00:00 2001 From: Halfdan Mouritzen Date: Thu, 18 Jan 2024 09:54:34 +0100 Subject: [PATCH] Email page : Disable/enable the "Make Primary" button according to which email is selected --- src/project/templates/account/email.html | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/src/project/templates/account/email.html b/src/project/templates/account/email.html index 1dc31e9..5251e26 100644 --- a/src/project/templates/account/email.html +++ b/src/project/templates/account/email.html @@ -17,10 +17,10 @@ {% csrf_token %}
- - - - + + + +
@@ -45,6 +45,7 @@ {% if emailaddress.primary or user.emailaddress_set.count == 1 %} checked="checked" {% endif %} + class="{% if emailaddress.primary %}primary_email{% endif %}" />
@@ -104,6 +105,15 @@ } }); } + + let radio_actions = document.getElementsByName('email'); + if (radio_actions.length) { + for (radio of radio_actions) { + radio.addEventListener("change", function (e) { + document.getElementById('action_primary').disabled = e.target.classList.contains('primary_email') + }); + } + } })();