From 6aa176211a4972bde91c90b68548f90868602dd4 Mon Sep 17 00:00:00 2001 From: Raphael Odini Date: Thu, 23 Nov 2023 15:16:34 +0100 Subject: [PATCH] Only display field if kind=BUYER selected --- lemarche/templates/auth/signup.html | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lemarche/templates/auth/signup.html b/lemarche/templates/auth/signup.html index 2d8d60069..b5e39e3a1 100644 --- a/lemarche/templates/auth/signup.html +++ b/lemarche/templates/auth/signup.html @@ -53,6 +53,7 @@

Inscription


Informations structure + {% bootstrap_field form.buyer_kind_detail form_group_class="buyer-kind-detail-form-group form-group form-group-required d-none" %} {% bootstrap_field form.partner_kind form_group_class="partner-kind-form-group form-group form-group-required d-none" %} {% bootstrap_field form.company_name form_group_class="company-name-form-group form-group form-group-required d-none" %} {% bootstrap_field form.position form_group_class="position-form-group form-group form-group-required d-none" %} @@ -113,15 +114,17 @@

Inscription

* - add survey checkbox * - if the user is BUYER: * - make phone field required + * - add buyer_kind_detail field (and make it required) * - add position field (and make it required) * - add survey checkbox for newsletter */ document.addEventListener('DOMContentLoaded', function() { let phoneInput = document.getElementById('id_phone'); - let companyNameSiaeFormGroupDiv = document.getElementsByClassName('company-name-siae-form-group')[0]; + let buyerKindDetailInput = document.getElementById('id_buyer_kind_detail'); + let partnerKindInput = document.getElementById('id_partner_kind'); let companyNameInput = document.getElementById('id_company_name'); + let companyNameSiaeFormGroupDiv = document.getElementsByClassName('company-name-siae-form-group')[0]; let positionInput = document.getElementById('id_position'); - let partnerKindInput = document.getElementById('id_partner_kind'); let acceptSurveyInput = document.getElementById('id_accept_survey'); let acceptShareContactInput = document.getElementById('id_accept_share_contact_to_external_partners'); let statsSignupBuyerContent = document.getElementById('statsSignupBuyer'); @@ -143,11 +146,13 @@

Inscription

} if (radio.value === 'BUYER') { + toggleInputElement(true, element=buyerKindDetailInput, required=true); toggleInputElement(true, element=positionInput, required=true); toggleInputElement(true, element=phoneInput, required=true); statsSignupBuyerContent.classList.remove('d-none'); toggleInputElement(true, element=sectorsInput, required=false); } else { + toggleInputElement(false, element=buyerKindDetailInput, required=false); toggleInputElement(false, element=positionInput, required=false); toggleInputElement(true, element=phoneInput, required=false); statsSignupBuyerContent.classList.add('d-none');